怎样debian下命令行终端显示短路径

来源:互联网 发布:编程序软件 编辑:程序博客网 时间:2024/05/22 12:56

 

$ 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='\W\$ 'fiunset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dircase "$TERM" inxterm*|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取得工作目录名称,所以只会列出最后一个目录

0 0