You are not logged in.
Pages: 1
(Hopefully this is in the right sub-forum)
I setup my PS1 console prompt too be very clean: "[directory/]>"
however I don't like the tilde abbreviation used when in my home directory "[~/]>". I would like instead for it too show the actual folder name "[evan/]>". I didn't see any prompt escapse similar to \w that wouldn't abbreviate my home directory as the tilde so Instead I did this
PS1=[\e[0;34m$(pwd | cut -d '/' -f $(($(pwd | grep -o '/' | wc -l) + 1)))/\e[0m]>
My question is: Is there a better, simpler, way too do this? I am still very new too the bash scripting language so hardly know many tricks just yet.
Thanks!
Offline
There is a list of escapes on the Wiki: I think you are after \W
Offline
Sorry Evan, I misread your post...
Offline
$PWD is automatically set by bash, so you don't need to use $(pwd)
To cut off up to and including the last slash, you can use ${PWD##*/}
Offline
$PWD is automatically set by bash, so you don't need to use $(pwd)
To cut off up to and including the last slash, you can use ${PWD##*/}
This is exactly what I was looking for! If you don't mind could you explain what the ##* does?
Edit: Nevermind, http://www.gnu.org/software/bash/manual … -Expansion explains whats going on here quite well!
Thanks!
Last edited by EvanPurkhiser (2010-08-20 01:55:25)
Offline
You could also use something like this:
PROMPT_COMMAND="PS1=\"\`hostname\`:\`pwd\` ${LOGNAME}> \""
PS1="\h:${PWD} \u> "
Offline
Pages: 1