Ubuntu18.04 Modify terminal path display

Ubuntu18.04 Modify terminal path display


Preface

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

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

Insert image description here

method

Open the .bashrc file

gedit ~/.bashrc

Find the following part of the code:

Insert image description here
将上面 if 中的 PS1 删掉 \u@\ h, w 改为大写 然后下面 PS1 中的 w 也改为大写,即可。可以选择注释也可以替换。

The final result is:

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

exhibit

Insert image description here
Now, the terminal only displays the current path, which is much more comfortable to watch.

Guess you like

Origin blog.csdn.net/qq_42535748/article/details/129975746