Ubuntu18.04 修改终端路径显示

Ubuntu18.04 修改终端路径显示


前言

相信很多人都遇到过以下这种情况:

终端显示的路径几乎占满了一行,看着非常不爽

在这里插入图片描述

方法

打开 .bashrc文件

gedit ~/.bashrc

找到以下部分代码:

在这里插入图片描述
将上面 if 中的 PS1 删掉 \u@\ h, w 改为大写 然后下面 PS1 中的 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\]\[\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\$ '  

展示

在这里插入图片描述
现在,终端只显示当前路径,看着舒服多了

猜你喜欢

转载自blog.csdn.net/qq_42535748/article/details/129975746
今日推荐