dotfiles/home/.bash_prompt

52 lines
1 KiB
Bash
Raw Permalink Normal View History

2014-06-20 16:13:16 +02:00
# defines __git_ps1
if [ -r ~/.bash_git ]; then
2014-06-20 16:13:16 +02:00
GIT_PS1_SHOWCOLORHINTS=1
GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWSTASHSTATE=1
GIT_PS1_SHOWUNTRACKEDFILES=1
GIT_PS1_SHOWUPSTREAM="auto"
source ~/.bash_git
PROMPT_COMMAND=show_prompt
fi
2016-03-27 21:21:00 +02:00
# iTerm shell integration
2021-08-26 10:35:41 +02:00
if [ "${TERM_PROGRAM}" = "iTerm.app" ]; then
source ~/.homesick/repos/dotfiles/iterm2/iterm2_integration.sh
fi
2016-03-27 21:21:00 +02:00
2014-06-20 16:13:16 +02:00
function show_prompt {
local EXIT="$?"
2014-06-20 16:13:16 +02:00
# Time
2021-08-26 10:40:51 +02:00
local pre='\[\e[01;35m\]\t '
2014-06-20 16:13:16 +02:00
local post
# Check last return value
if [ $EXIT != 0 ]; then
2021-08-26 10:40:51 +02:00
pre+='\[\e[31m\]⬤'
else
2021-08-26 10:40:51 +02:00
pre+='\[\e[32m\]⬤'
2014-06-20 16:13:16 +02:00
fi
2021-08-26 10:40:51 +02:00
pre+=' \[\e[;37m\]\j \l '
2014-06-24 14:34:08 +02:00
2014-06-20 16:13:16 +02:00
# Test if root
2014-12-30 23:22:34 +01:00
if [ $EUID -ne 0 ]; then
2014-06-20 16:13:16 +02:00
pre+='\[\e[01;34m\]\u\[\e[01;33m\]@\[\e[01;36m\]\H'
post='\[\e[01;34m\]\w'
else
pre+='\[\e[31m\]\u\[\e[01;33m\]@\[\e[01;36m\]\H'
post='\[\e[01;33m\]\w'
fi
2021-08-26 10:40:51 +02:00
post+='\[\e[;37m\]\n \[\e[01;30m\]\# \[\e[31m\]\$ \[\e[00m\]'
2014-06-20 16:13:16 +02:00
2021-08-26 10:40:51 +02:00
if [[ $(git config --default true --get prompt.show) == "false" ]]; then
PS1="$pre $post"
else
__git_ps1 "$pre " "$post" '\[\e[01;30m\](%s\[\e[01;30m\]) '
fi
2014-06-20 16:13:16 +02:00
}