您的位置:首页 > 其它

Ubuntu 14 下,命令行终端显示短路径

2016-07-17 10:41 369 查看
Ubuntu的终端命令行默认是长路径,即把路径深度全部显示出来,操作起来不是很方便,下面介绍命令行显示短路径的操作:

$ vi ~/.bashrc

找到PS1= 的行,将\w(小写)改成\W(大写)


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\$ '

PS1='${debian_chroot:+($debian_chroot)}\u@\h:\W\$ '

fi

unset color_prompt force_color_prompt

# 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"

PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \W\a\]$PS1"

;;

*)

;;

esac


保存,执行下面的命令或重启终端

$ source ~/.bashrc

执行上面步骤后,在终端页就短路径显示当前路径了。

PS1:就是用户平时的提示符。 echo $PS1 可以查看PS1变量:

\h :主机名字

\u :当前用户的账号名称

\w :完整的工作目录名称。家目录会以 ~代替

\W :利用basename取得工作目录名称,所以只会列出最后一个目录
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: