仅当当前目录发生更改时,我才想对bash shell提示符(= PS1)加下划线。 我试过了。仅当pwd发生改变时才强调bash提示
在.bashrc
文件我写
DIR_CHANGED=
function cd {
builtin cd "[email protected]"
DIR_CHANGED=1
}
function dir_ul {
# if $DIR_CHANGED is 1, draw underline
if [ x == x$DIR_CHANGED ]; then echo -en '\033[0;34m'; else echo -en '\033[4;34m'; fi
export DIR_CHANGED=''
}
export PS1='$(dir_ul)\w$(tput sgr0)$ '
但没有奏效。
我该如何解决?
这可能有助于:[如何调试bash脚本?](http://unix.stackexchange.com/q/155551/74329) – Cyrus