linux环境前缀太长 屏幕占满

2019-06-11  本文已影响0人  默写年华Antifragile
image.png

如图所示,用户名+主机名+地址,当进入的目录比较多时,几乎占满了整个屏幕
实际上可以通过修改环境变量让这个变短

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的值 \u@\h:\w\$
其中 \u表示用户名username 后面的@就是@符号
\h表示主机名hostname 然后是冒号:
最后是\w表示当前路径 后面跟着$

if [ "$color_prompt" = yes ]; then
    #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:\[\033[01;34m\]\W\[\033[00m\]\$ '
else
    #PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
    PS1='${debian_chroot:+($debian_chroot)}\u:\W\$ '
上一篇 下一篇

猜你喜欢

热点阅读