Modify the Linux terminal prompt path length
In Linux, the default path prompts the complete path, which takes a long line and may occupy the full width! As shown below:
Bkjia @ Ubuntu :~ /Trunk-new/build_dir/target-mips_34kc_uClibc-0.9.33.2/linux-ar71xx_generic/net/netfilter/effeccials $
It basically occupies 80% of the terminal width. If you can change it to show only the name of the last folder!
Modification method:
Vim ~ /. Bashrc
Search PS1
56 if ["$ color_prompt" = yes]; then
57 PS1 = '$ {debian_chroot: + ($ debian_chroot)} \ [\ 033 [01; 32m \] \ u @ \ h \ [\ 033 [00m \]: \ [\ 033 [01; 34m \] \ W \ [\ 033 [00m \] \ $'
58 else
59 PS1 = '$ {debian_chroot: + ($ debian_chroot)} \ u @ \ h: \ W \ $'
60 fi
Find the preceding text. Note that the value of the environment variable in PS1 is the current user, \ h is the host name, \ w is the complete path, and \ W is the simple path, change w to W!
If or else takes effect, you can try it all. Mine is else.
Run the command after modification
$ Source ~ /. Bashrc
You can apply it! Result
Bkjia @ ubuntu: commercials $
Is it concise.
This article permanently updates the link address: