Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230
Customize your Bash Prompt
- None1975
- df -h | participant
- Posts: 1404
- Joined: 2015-11-29 18:23
- Location: Russia, Kaliningrad
- Has thanked: 46 times
- Been thanked: 68 times
Customize your Bash Prompt
Hello guys Here is a nice project- EzPrompt Easy Bash PS1 Generator. It is is a project of nice guy-Josh Matthews. Very easy to customizing your Bash Prompt.
OS: Debian 12.4 Bookworm / DE: Enlightenment
Debian Wiki | DontBreakDebian, My config files on github
Debian Wiki | DontBreakDebian, My config files on github
- Head_on_a_Stick
- Posts: 14114
- Joined: 2014-06-01 17:46
- Location: London, England
- Has thanked: 81 times
- Been thanked: 133 times
Re: Customize your Bash Prompt
Here's one not in your link:
That code will cause the error status of the last command to be printed in red text but only if it is non-zero (ie, if the command failed in some way).
Example .bashrc:
Looks like this:
EDIT: it also works for mksh, if you prefer a lighter, faster, less buggy shell
Code: Select all
\e[31m${?#0}\e[0m\
Example .bashrc:
Code: Select all
PS1='\h: \w \e[31m${?#0}\e[0m\$ '
EDIT: it also works for mksh, if you prefer a lighter, faster, less buggy shell
deadbang
- Head_on_a_Stick
- Posts: 14114
- Joined: 2014-06-01 17:46
- Location: London, England
- Has thanked: 81 times
- Been thanked: 133 times
Re: Customize your Bash Prompt
Actually, I was wrong about that but you might want to tell Mr. Matthews about the built-in function I posted above because his function:Head_on_a_Stick wrote:Here's one not in your link
Code: Select all
function nonzero_return() {
RETVAL=$?
[ $RETVAL -ne 0 ] && echo "$RETVAL"
}
deadbang
- None1975
- df -h | participant
- Posts: 1404
- Joined: 2015-11-29 18:23
- Location: Russia, Kaliningrad
- Has thanked: 46 times
- Been thanked: 68 times
Re: Customize your Bash Prompt
Thank you, Head_on_a_Stick. I’m going to let him know.Actually, I was wrong about that but you might want to tell Mr. Matthews about the built-in function I posted above because his function:
OS: Debian 12.4 Bookworm / DE: Enlightenment
Debian Wiki | DontBreakDebian, My config files on github
Debian Wiki | DontBreakDebian, My config files on github
- Head_on_a_Stick
- Posts: 14114
- Joined: 2014-06-01 17:46
- Location: London, England
- Has thanked: 81 times
- Been thanked: 133 times
Re: Customize your Bash Prompt
such a useful addition to any prompt!Head_on_a_Stick wrote:Here's one not in your link:That code will cause the error status of the last command to be printed in red text but only if it is non-zero (ie, if the command failed in some way).Code: Select all
\e[31m${?#0}\e[0m\
Example .bashrc:Looks like this:Code: Select all
PS1='\h: \w \e[31m${?#0}\e[0m\$ '
EDIT: it also works for mksh, if you prefer a lighter, faster, less buggy shell