feat: exit code right
This commit is contained in:
parent
bcbe1a4335
commit
432e5a1e03
34
.bashrc
34
.bashrc
@ -20,13 +20,13 @@ if type shopt 2>/dev/null 1>&2; then
|
|||||||
shopt -s dirspell
|
shopt -s dirspell
|
||||||
|
|
||||||
shopt -s histappend
|
shopt -s histappend
|
||||||
PROMPT_COMMAND='history -a'
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export HISTSIZE=10000
|
export HISTSIZE=10000
|
||||||
export HISTIGNORE="&:l[lsa\.]:[bf]g:exit:q:clear:c:history:h"
|
export HISTIGNORE="&:l[lsa\.]:[bf]g:exit:q:clear:c:history:h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
parse_git_branch() {
|
parse_git_branch() {
|
||||||
|
|
||||||
if ! [ -x "$(which git)" ]; then
|
if ! [ -x "$(which git)" ]; then
|
||||||
@ -67,6 +67,20 @@ virtualenv_info() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rightprompt()
|
||||||
|
{
|
||||||
|
if [[ $1 -ne 0 ]]; then
|
||||||
|
printf "%*s" $COLUMNS "$1 ⨯"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PROMPT_COMMAND=__prompt_command
|
||||||
|
|
||||||
|
__prompt_command() {
|
||||||
|
|
||||||
|
local EXIT="$?"
|
||||||
|
|
||||||
close_color='\[\e[m\]'
|
close_color='\[\e[m\]'
|
||||||
red_color='\[\033[1;31m\]'
|
red_color='\[\033[1;31m\]'
|
||||||
|
|
||||||
@ -83,16 +97,24 @@ if [ "$EUID" -eq 0 ]; then # Change prompt colors and symbols for root user
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" ]]; then
|
if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" ]]; then
|
||||||
prompt_symbol='📡'
|
prompt_symbol='📡'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
export VIRTUAL_ENV_DISABLE_PROMPT=1
|
export VIRTUAL_ENV_DISABLE_PROMPT=1
|
||||||
VENV_="\$(virtualenv_info)";
|
|
||||||
|
|
||||||
BRANCH_="\$(parse_git_branch)";
|
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="> "
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# 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