Moved the git color to the end of the profile
This commit is contained in:
parent
e387131f25
commit
1550bd2e81
1 changed files with 48 additions and 68 deletions
116
.profile
116
.profile
|
|
@ -14,74 +14,6 @@ if [ -n "$BASH_VERSION" ]; then
|
||||||
if [ -f "$HOME/.bashrc" ]; then
|
if [ -f "$HOME/.bashrc" ]; then
|
||||||
. "$HOME/.bashrc"
|
. "$HOME/.bashrc"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Add the git prompt in the PS1
|
|
||||||
|
|
||||||
if [ -n "$force_color_prompt" ]; then
|
|
||||||
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
|
|
||||||
# We have color support; assume it's compliant with Ecma-48
|
|
||||||
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
|
|
||||||
# a case would tend to support setf rather than setaf.)
|
|
||||||
color_prompt=yes
|
|
||||||
else
|
|
||||||
color_prompt=
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$color_prompt" = yes ]; then
|
|
||||||
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
|
|
||||||
else
|
|
||||||
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
|
|
||||||
fi
|
|
||||||
|
|
||||||
# store colors
|
|
||||||
MAGENTA="\[\033[0;35m\]"
|
|
||||||
YELLOW="\[\033[01;33m\]"
|
|
||||||
BLUE="\[\033[00;34m\]"
|
|
||||||
LIGHT_GRAY="\[\033[0;37m\]"
|
|
||||||
CYAN="\[\033[0;36m\]"
|
|
||||||
GREEN="\[\033[00;32m\]"
|
|
||||||
RED="\[\033[0;31m\]"
|
|
||||||
VIOLET='\[\033[01;35m\]'
|
|
||||||
|
|
||||||
function color_my_prompt {
|
|
||||||
local __user_and_host="$GREEN\u@\h"
|
|
||||||
local __cur_location="$BLUE\W" # capital 'W': current directory, small 'w': full file path
|
|
||||||
local __git_branch_color="$GREEN"
|
|
||||||
local __prompt_tail="$VIOLET$"
|
|
||||||
local __user_input_color="$GREEN"
|
|
||||||
local __git_branch=$(__git_ps1);
|
|
||||||
|
|
||||||
# colour branch name depending on state
|
|
||||||
if [[ "${__git_branch}" =~ "*" ]]; then # if repository is dirty
|
|
||||||
__git_branch_color="$RED"
|
|
||||||
elif [[ "${__git_branch}" =~ "$" ]]; then # if there is something stashed
|
|
||||||
__git_branch_color="$YELLOW"
|
|
||||||
elif [[ "${__git_branch}" =~ "%" ]]; then # if there are only untracked files
|
|
||||||
__git_branch_color="$LIGHT_GRAY"
|
|
||||||
elif [[ "${__git_branch}" =~ "+" ]]; then # if there are staged files
|
|
||||||
__git_branch_color="$CYAN"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Build the PS1 (Prompt String)
|
|
||||||
PS1="$__user_and_host $__cur_location$__git_branch_color$__git_branch $__prompt_tail$__user_input_color "
|
|
||||||
}
|
|
||||||
|
|
||||||
# configure PROMPT_COMMAND which is executed each time before PS1
|
|
||||||
export PROMPT_COMMAND=color_my_prompt
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# if .git-prompt.sh exists, set options and execute it
|
|
||||||
if [ -f ~/.git-prompt.sh ]; then
|
|
||||||
GIT_PS1_SHOWDIRTYSTATE=true
|
|
||||||
GIT_PS1_SHOWSTASHSTATE=true
|
|
||||||
GIT_PS1_SHOWUNTRACKEDFILES=true
|
|
||||||
GIT_PS1_SHOWUPSTREAM="auto"
|
|
||||||
GIT_PS1_HIDE_IF_PWD_IGNORED=true
|
|
||||||
GIT_PS1_SHOWCOLORHINTS=true
|
|
||||||
. ~/.git-prompt.sh
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# set PATH so it includes user's private bin if it exists
|
# set PATH so it includes user's private bin if it exists
|
||||||
|
|
@ -93,3 +25,51 @@ fi
|
||||||
if [ -d "$HOME/.local/bin" ] ; then
|
if [ -d "$HOME/.local/bin" ] ; then
|
||||||
PATH="$HOME/.local/bin:$PATH"
|
PATH="$HOME/.local/bin:$PATH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Everything related to git
|
||||||
|
# store colors
|
||||||
|
MAGENTA="\[\033[0;35m\]"
|
||||||
|
YELLOW="\[\033[01;33m\]"
|
||||||
|
BLUE="\[\033[00;34m\]"
|
||||||
|
LIGHT_GRAY="\[\033[0;37m\]"
|
||||||
|
CYAN="\[\033[0;36m\]"
|
||||||
|
GREEN="\[\033[00;32m\]"
|
||||||
|
RED="\[\033[0;31m\]"
|
||||||
|
VIOLET='\[\033[01;35m\]'
|
||||||
|
|
||||||
|
function color_my_prompt {
|
||||||
|
local __user_and_host="$GREEN\u@\h"
|
||||||
|
local __cur_location="$BLUE\w" # capital 'W': current directory, small 'w': full file path
|
||||||
|
local __git_branch_color="$GREEN"
|
||||||
|
local __prompt_tail="$VIOLET$"
|
||||||
|
local __user_input_color="$GREEN"
|
||||||
|
local __git_branch=$(__git_ps1);
|
||||||
|
|
||||||
|
# colour branch name depending on state
|
||||||
|
if [[ "${__git_branch}" =~ "*" ]]; then # if repository is dirty
|
||||||
|
__git_branch_color="$RED"
|
||||||
|
elif [[ "${__git_branch}" =~ "$" ]]; then # if there is something stashed
|
||||||
|
__git_branch_color="$YELLOW"
|
||||||
|
elif [[ "${__git_branch}" =~ "%" ]]; then # if there are only untracked files
|
||||||
|
__git_branch_color="$LIGHT_GRAY"
|
||||||
|
elif [[ "${__git_branch}" =~ "+" ]]; then # if there are staged files
|
||||||
|
__git_branch_color="$CYAN"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build the PS1 (Prompt String)
|
||||||
|
PS1="$__user_and_host $__cur_location$__git_branch_color$__git_branch $__prompt_tail$__user_input_color "
|
||||||
|
}
|
||||||
|
|
||||||
|
# configure PROMPT_COMMAND which is executed each time before PS1
|
||||||
|
export PROMPT_COMMAND=color_my_prompt
|
||||||
|
|
||||||
|
# if .git-prompt.sh exists, set options and execute it
|
||||||
|
if [ -f ~/.git-prompt.sh ]; then
|
||||||
|
GIT_PS1_SHOWDIRTYSTATE=true
|
||||||
|
GIT_PS1_SHOWSTASHSTATE=true
|
||||||
|
GIT_PS1_SHOWUNTRACKEDFILES=true
|
||||||
|
GIT_PS1_SHOWUPSTREAM="auto"
|
||||||
|
GIT_PS1_HIDE_IF_PWD_IGNORED=true
|
||||||
|
GIT_PS1_SHOWCOLORHINTS=true
|
||||||
|
. ~/.git-prompt.sh
|
||||||
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue