Okay, the "trouble" is this:
[lars@titan ~]$
This is the default bash prompt. Now, thats fine enough, but lets jump to another directory.:
[lars@titan lib]$
Where am I now? Which directory is this? Hm?
Since the RedHat prompt only shows the current directory, and NOT the full path, it can be any number of directories:
- /lib
- /usr/lib/
- /usr/src/linux/lib/
- /usr/local/lib/
- /opt/lib
- /var/lib
- ~/lib
- ...
Luckily, it is easy to change the prompt. Just add this to your ~/.bashrc
PS1='\u@\h:\w\$ '
PS2='> '
This gives you:
lars@dream:~$
And lets now jump to another directory:
lars@dream:/usr/local/lib$
See? No more 'pwd'! Finally a more sane and useful Bash prompt!
You can find more prompt variables in the Bash manual.
A slightly more fancy variant of the above, is to make the prompt bold:
BOLD="\[\033[1m\]"
OFF="\[\033[m\]"
PS1="${BOLD}\u@\h:\w \$${OFF} "
PS2="${BOLD}>${OFF} "
Just add it to your ~/.bashrc, and it will look like this:
lars@titan:~$
You can pimp your prompt with colors and all kinds off information. Read the Bash Prompt HOWTO for more.
No comments:
Post a Comment