ubuntu缩短终端路径名称显示

来源:互联网 发布:阿里云1m带宽慢不慢 编辑:程序博客网 时间:2024/05/16 05:39
有时候遇到目录名称过长或者太多层路径嵌套,导致终端显示的路径名实在太长,不方便操作,如下图:



可以通过改  .bashrc  来缩短名称显示:
if [ "$color_prompt" = yes ]; then
    #kevin,20141202 PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]\$ '
else
    #kevin,20141202 PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\W\$ '
fi
unset color_prompt force_color_prompt

大写的W代表当前目录,小写的代表完整路径,你需要把下面一行的改为大写W


完了之后保存, source .bashrc, 就OK了。 再来看这个路径:




只显示当前所在目录的名称了!

1 0
原创粉丝点击