I have the following in my .bash_profile (from a similar question here:
PROMPT_COMMAND='pwd2=$(sed "s:\([^/]\)[^/]*/:\1/:g" <<<$PWD)'
PS1='\u@\h:$pwd2\$ '
However, if the current directory is within a .dir (such as ~/.vim/bundle/) then the prompt just displays a .:
chris@DeathStar:/U/c/./bundle$
I would like it instead to retain 1 char for all dirnames unless it has a dot, in which case it would show two, like this:
chris@DeathStar:/U/c/.v/bundle$
Even better would be if I also have the home directory represented by a ~
like this:
chris@DeathStar:~/.v/bundle$
Any ideas?
pwd
command if you want to get the whole directory? That means use\W
instead\w
. This solution is simple and work for me.