I'd like to use the \w
variable in .bashrc
, but I want the prompt to highlight the current end-directory. Something like this:
/usr/local/<strong>bin</strong>
How can I do that?
PS1='${PWD%/*}/\[\e[33;1m\]${PWD##*/}\[\e[0m\] \$: '
use bash'isms to manipulate the $PWD for the last component. COlorize, and add yet even more meta for bash escapes.
Substitute different numbers for 33 for different colors.
personally i hate the path in the prompt, it moves across the screen. I prefer in the titlebar.
PROMPT_COMMAND='echo -ne "\e]0;$USER@${HOSTNAME%%.*}: $(pwd -P)\a"'
EDIT changed Quotes on PS1 to single quotes, since it needs to be evaluated every time it's printed, not just once when it's read. Thanks @Gordon
Use something like $(dirname \w)/\[$(tput bold)\]$(basename \w)\[$(tput sgr0)\]
in $PS1
. Don't forget the single quotes.