Personally, my prompt string is defined in my .bashrc file as PS1='\[\033[1;32m\]\w $\[\033 [0m\] '. The environment variable PS1 is your main prompt string. This funky-looking command sets my prompt to display the current directory (the \w part) followed by a $ in bright green.
Here is a list of all the escape characters you can use:
\a ASCII bell character (07)
\d Day Month Year
\e ASCII escape character (033)
\h host base name
\H hostname
\j # of jobs
\l shell terminal device base name
\n newline
\r carriage return
\s shell name
\t 24 hour HH:MM:SS
\T 12 hour HH:MM:SS
\@ 12 hour am/pm time
\u current user
\v bash version
\V bash version + patch
\w current directory
\W current directory base name
\! command history #
\# command #
\$ #(UID 0) or $(UID not 0)
\nnn octal nnn(ex \854)
\\ backslash
\[ begin of embedded control sequence
\] end sequence Example $PS1="[\T][\u][\w]$ " The prompt string may look like this,
[5:45:45][username][~/documents]$
To permanently change your prompt in Bash, edit .bashrc and enter a line such as,
PS1=desired-prompt-string; export PS1
You may need to create the .bashrc file in your home directory if it does not exist. After you add that line, your prompt string should permanently be set. If this does not work, try adding the above in your .bash_profile in you home directory(once again, if it does not exit, create it).
No comments:
Post a Comment