从命令行,长目录路径可以占据整行:
也有人问过类似的问题:
采取的步骤:
/etc/bash.bashrc
sudo gedit bash.bashrc
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\ W \$ '
您可能有自己的PS1
定义~/.bashrc
(除非您是根用户)覆盖系统范围/etc/bash.bashrc
(没有颜色)。你应该PS1
在那里编辑。
在我~/.bashrc
的PS1
东西看起来像这样(默认的 Debian 伸展):
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
# 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
Run Code Online (Sandbox Code Playgroud)
第一个定义是带有颜色的定义。更改\w
到\W
你的~/.bashrc
,你应该是好的。