add custom error handling for command not found
Enhance user experience by displaying errors in red when a command is not found in the shell environment.
This commit is contained in:
parent
c93727503e
commit
ac7683930b
6
bashrc
6
bashrc
|
@ -167,6 +167,12 @@ function calculate_git_alignment() {
|
|||
# Set up prompt command to draw divider, update git status, and calculate alignment
|
||||
PROMPT_COMMAND="draw_prompt_divider; my_gitstatus_prompt_update; calculate_git_alignment"
|
||||
|
||||
# Custom command_not_found_handle function to show errors in red
|
||||
command_not_found_handle() {
|
||||
echo -e "\033[01;31mbash: $1: command not found\033[00m" >&2
|
||||
return 127
|
||||
}
|
||||
|
||||
# Set PS1 with user@host, directory on first line, dynamically aligned git status, prompt on third line
|
||||
PS1='\[\033[01;32m\]\u@\h\[\033[00m\] \[\033[1;34m\]\w\[\033[00m\]\n${GITSTATUS_PROMPT:+$GIT_ALIGNMENT_PADDING$GITSTATUS_PROMPT\n}└── \[\033[01;$((31+!$?))m\]\$\[\033[00m\] \[\e]0;\u@\h: \w\a\]'
|
||||
|
||||
|
|
Loading…
Reference in New Issue