Ubuntu中让终端只显示当前路径,而不显示绝对路径

来源:互联网 发布:腾讯云域名和ip绑定 编辑:程序博客网 时间:2024/05/29 19:43


想要将Ubuntu的终端,中的绝对路径的显示,变成当前路径(文件夹)的话,则需要去修改自己的.bashrc,将其中的小写的w,改为大写的W即可:

(1)针对终端的标题title

1
2
3
4
5
6
7
8
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

改为:

1
2
3
4
5
6
7
8
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \W\a\]$PS1"
    ;;
*)
    ;;
esac

 

(2)针对终端的当前显示prompt

1
2
3
4
5
6
if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

改为:

1
2
3
4
5
6
if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\W\$ '
fi
unset color_prompt force_color_prompt
原创粉丝点击