Original URL: http://jingyan.baidu.com/article/3d69c5516c129df0ce02d77b.html
Ubuntu default terminal, after entering many layers of the directory, the front of the prompt will show the full path, so that the command line is too long and uncomfortable, now teach you a way to modify the command line to display only the last level directory name of the current directory, so it looks good, The full path name can be seen with PWD.
Tools/Materials
Method/Step
Locate the configuration file to backup first: CP ~/.BASHRC ~/.bashrc-bak
Find configuration file modification: VI ~/.BASHRC
Backup is to prevent configuration modification error, can be restored;
Here is my/home/vagrant/.bashrc, really changed to just one line of code:
Found: ps1= ' ${debian_chroot:+ ($debian _chroot)}\[email protected]\h:\w\$ '
Change the lowercase w to uppercase W to save, execute SOURCE/HOME/VAGRANT/.BASHRC or restart the terminal on the line.
The last level can be displayed, and the current full path can be viewed.
Original URL: http://www.linuxidc.com/Linux/2011-10/44289.htm chat with friends, he said he used Ubuntu when there will be such a confusion: under the use of the CD command under Bash, into some deep directory, Or a directory with a very long directory name, Bash's command prompt is so long that each command will be wrapped.Hadoop[email protected]:/etc/opt/directorynameisfuckingsolong/my/name/is/spazzzz$
Similar to the situation above ... This is the case with Bash's command-prompt variable PS1, where the PS1 uses the full path name:
- echo $PS 1
- \[\e]0;\[email protected]\h: \w\a\]${debian_chroot:+ ($debian _chroot)}\[email protected]\h:\w\$
Here the description of the situation is \w this parameter, it indicates that the full path display if only want to display the current path, the W will be changed to solve the problem! (As for where to change, this need to look at the distribution of Linux, some in/etc/profile, some in the ~/.bash_profile) as in the case of the earlier, the display becomes[Email protected]:spazzzz$
This is not much better.
PS: Some variable meanings
\d: Represents the date, in the format weekday month date, for example: "Mon 1" \h: Full host name. The name is Fc4.linux \h: Take the first name of the host only, as in the example above, then the fc4,.linux is omitted \ t: The display time is 24-hour format, such as: HH:MM:SS \ t: Display time is 12 hours format \a: Display time is 24 hours format: hh:mm \u : The current user's account name \v:bash version information \w: The full working directory name. The home directory will replace the \w: using basename to get the working directory name, so only the last directory \#: The first command issued \$: prompt character, if it is root, the prompt is: #, the normal user is: {debian_chroot:+ ($debian _ chroot)} This means that if there is a debian_chroot file under/etc, the contents of the Debian_chroot file are appended to the command prompt.
"Go" How to fix Ubuntu terminal inside display path name too long