onsdag 12 maj 2010

Hardcore bash PS1 prompt

This is the PS1 bash prompt I've been using for a while now. It shows the line number in bash history and the latest exit code. As well as the common info such as username, hostname and full pathname. Put this line in the startscript for bash, for me its ~/.bashrc (in a quite recent ubuntu release). It might be needed in ~/.bash_login as well.
PS1=\!,$? \u@\h:\w\$
export PS1
Example:
502,0 username@hostname:/etc/init.d$ ls omgthisfiledoesnotexist
ls: cannot access omgthisfiledoesnotexist: No such file or directory
503,2 username@hostname:/etc/init.d$

With this PS1 prompt it's very easy to backtrace to where the command occured using the history command.

Inga kommentarer:

Skicka en kommentar