feat: exit code right
This commit is contained in:
parent
bcbe1a4335
commit
432e5a1e03
66
.bashrc
66
.bashrc
@ -20,13 +20,13 @@ if type shopt 2>/dev/null 1>&2; then
|
||||
shopt -s dirspell
|
||||
|
||||
shopt -s histappend
|
||||
PROMPT_COMMAND='history -a'
|
||||
fi
|
||||
|
||||
export HISTSIZE=10000
|
||||
export HISTIGNORE="&:l[lsa\.]:[bf]g:exit:q:clear:c:history:h"
|
||||
|
||||
|
||||
|
||||
parse_git_branch() {
|
||||
|
||||
if ! [ -x "$(which git)" ]; then
|
||||
@ -67,32 +67,54 @@ virtualenv_info() {
|
||||
fi
|
||||
}
|
||||
|
||||
close_color='\[\e[m\]'
|
||||
red_color='\[\033[1;31m\]'
|
||||
|
||||
prompt_color='\[\033[;32m\]'
|
||||
info_color='\[\033[1;34m\]'
|
||||
prompt_symbol='㉿'
|
||||
end_symbol='$'
|
||||
rightprompt()
|
||||
{
|
||||
if [[ $1 -ne 0 ]]; then
|
||||
printf "%*s" $COLUMNS "$1 ⨯"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
if [ "$EUID" -eq 0 ]; then # Change prompt colors and symbols for root user
|
||||
prompt_color='\[\033[;94m\]'
|
||||
info_color='\[\033[1;31m\]'
|
||||
end_symbol='#'
|
||||
fi
|
||||
PROMPT_COMMAND=__prompt_command
|
||||
|
||||
__prompt_command() {
|
||||
|
||||
local EXIT="$?"
|
||||
|
||||
close_color='\[\e[m\]'
|
||||
red_color='\[\033[1;31m\]'
|
||||
|
||||
prompt_color='\[\033[;32m\]'
|
||||
info_color='\[\033[1;34m\]'
|
||||
prompt_symbol='㉿'
|
||||
end_symbol='$'
|
||||
|
||||
|
||||
|
||||
if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" ]]; then
|
||||
prompt_symbol='📡'
|
||||
fi
|
||||
if [ "$EUID" -eq 0 ]; then # Change prompt colors and symbols for root user
|
||||
prompt_color='\[\033[;94m\]'
|
||||
info_color='\[\033[1;31m\]'
|
||||
end_symbol='#'
|
||||
fi
|
||||
|
||||
|
||||
export VIRTUAL_ENV_DISABLE_PROMPT=1
|
||||
VENV_="\$(virtualenv_info)";
|
||||
if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" ]]; then
|
||||
prompt_symbol='📡'
|
||||
fi
|
||||
|
||||
|
||||
export VIRTUAL_ENV_DISABLE_PROMPT=1
|
||||
|
||||
VENV_="\$(virtualenv_info)"
|
||||
BRANCH_="\$(parse_git_branch)"
|
||||
TERMINAL_NAME="\[\e]2;${0^^}\a\]"
|
||||
|
||||
if [ $EXIT != 0 ]; then
|
||||
PS1="$TERMINAL_NAME\n$prompt_color┌─${VENV_}─($close_color$info_color\u$prompt_symbol\H$close_color$prompt_color)-[$close_color\w$prompt_color]$close_color $red_color${BRANCH_}$close_color\n\[$(tput sc; rightprompt $EXIT; tput rc)\]$prompt_color└─$close_color$info_color$end_symbol$close_color "
|
||||
else
|
||||
PS1="$TERMINAL_NAME\n$prompt_color┌─${VENV_}─($close_color$info_color\u$prompt_symbol\H$close_color$prompt_color)-[$close_color\w$prompt_color]$close_color $red_color${BRANCH_}$close_color\n$prompt_color└─$close_color$info_color$end_symbol$close_color "
|
||||
fi
|
||||
|
||||
PS2="> "
|
||||
}
|
||||
|
||||
BRANCH_="\$(parse_git_branch)";
|
||||
|
||||
# last
|
||||
PS1="\n$prompt_color┌─${VENV_}─($close_color$info_color\u$prompt_symbol\H$close_color$prompt_color)-[$close_color\w$prompt_color]$close_color $red_color${BRANCH_}$close_color\n$prompt_color└─$close_color$info_color$end_symbol$close_color "
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user