Bash PS1 in Linux
Chatting with a friend, he said he had such a confusion when using Ubuntu: using the cd command in bash, after entering some deep directories, or after directories with very long names, the bash command prompt is so long that every command will wrap
Hadoop-mapred @ hdp32:/etc/opt/directorynameisfuckingsolong/my/name/is/spazzzz $
This is similar to the above situation... this is the problem with the bash command prompt variable PS1. Here PS1 uses the complete path name:
- echo $PS1
- \[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$
Here, the parameter \ w is used to show the complete path. If you only want to display the current path, change w to W, and the problem is solved! (As for where to modify it, you need to check the linux release, some of which are in the/etc/profile and some are in ~ /. Bash_profile) as in the previous situation, the display becomes
Hadoop-mapred @ hdp32: spazzzz $
This is not much better.
PS: Meaning of some variables
\ D: represents the date, in the format of weekday month date, for example, "Mon Aug 1" \ H: complete host name. The name is fc4.linux \ h: only the first name of the host. In the preceding example, the name is fc4 ,. linux is omitted \ t: The display time is in the 24-hour format, for example, HH: MM: SS \ T: The display time is in the 12-hour format \ A: The display time is in the 24-hour format: HH: MM \ u: Account name of the current user \ v: BASH version \ w: complete working directory name. In the home directory ~ Replace \ W: Use basename to get the name of the working directory. Therefore, only the last directory \ # is listed. For example, if it is root, the prompt is: #, the common user is: {debian_chroot: + ($ debian_chroot)}, which means that if the debian_chroot file exists in/etc, the contents of the debian_chroot file are appended to the command prompt.