.
This commit is contained in:
parent
e67e4a13b5
commit
c5d16114b8
31
.functions/dotfiles.sh
Normal file
31
.functions/dotfiles.sh
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
function dotf(){
|
||||||
|
/usr/bin/git --git-dir="$HOME"/.dotfiles --work-tree="$HOME" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
dotfiles_status(){
|
||||||
|
case $1 in
|
||||||
|
check_error)
|
||||||
|
result="$(/usr/bin/git --git-dir="$HOME"/.dotfiles --work-tree="$HOME" status --short 2> /dev/null)"
|
||||||
|
# shellcheck disable=SC2181
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
echo YES
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
check_status)
|
||||||
|
result="$(/usr/bin/git --git-dir="$HOME"/.dotfiles --work-tree="$HOME" status --short 2> /dev/null)"
|
||||||
|
if [[ -n "$result" ]]; then
|
||||||
|
echo YES
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
check_push)
|
||||||
|
result="$(/usr/bin/git --git-dir="$HOME"/.dotfiles --work-tree="$HOME" status --short 2> /dev/null)"
|
||||||
|
if [[ -z "$result" ]]; then
|
||||||
|
result="$(/usr/bin/git --git-dir="$HOME"/.dotfiles --work-tree="$HOME" cherry -v )"
|
||||||
|
if [[ -n "$result" ]]; then
|
||||||
|
echo YES
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
@ -5,6 +5,8 @@ function set_bash_prompt () {
|
|||||||
local GIT_BRANCH=""
|
local GIT_BRANCH=""
|
||||||
local PYTHON_ENV=""
|
local PYTHON_ENV=""
|
||||||
local K8S_CURRENT_CONTEXT=""
|
local K8S_CURRENT_CONTEXT=""
|
||||||
|
local DOTF=""
|
||||||
|
local STATUS=""
|
||||||
|
|
||||||
local COLOR_OFF='\033[0m'
|
local COLOR_OFF='\033[0m'
|
||||||
local COLOR_DIVIDER="\033[0;32m"
|
local COLOR_DIVIDER="\033[0;32m"
|
||||||
@ -16,6 +18,8 @@ function set_bash_prompt () {
|
|||||||
local COLOR_PATH="\033[0;37m"
|
local COLOR_PATH="\033[0;37m"
|
||||||
local COLOR_EXIT_STATUS="[\033[1;37m\033[41m"
|
local COLOR_EXIT_STATUS="[\033[1;37m\033[41m"
|
||||||
local COLOR_KUBERNETES="\033[1;37m\033[44m"
|
local COLOR_KUBERNETES="\033[1;37m\033[44m"
|
||||||
|
local COLOR_TODO="'\033[1;30m''\033[43m'"
|
||||||
|
local COLOR_DOTF="\033[1;30m\033[45m"
|
||||||
|
|
||||||
local CURRENT_CONTEXT=""
|
local CURRENT_CONTEXT=""
|
||||||
|
|
||||||
@ -29,7 +33,21 @@ function set_bash_prompt () {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PS1="\n${COLOR_DIVIDER}┌──(${COLOR_USERNAME}\u${COLOR_USERHOSTAT}@${COLOR_HOSTNAME}\h${COLOR_DIVIDER})─[${COLOR_PATH}\w${COLOR_DIVIDER}]${EXIT_STATUS}${PYTHON_ENV}${K8S_CURRENT_CONTEXT}${GIT_BRANCH}"
|
if [[ $(type -t dotfiles_status) == function ]];then
|
||||||
|
if [[ $(dotfiles_status check_error) == YES ]];then
|
||||||
|
DOTF="${COLOR_DOTF}E"
|
||||||
|
elif [[ $(dotfiles_status check_status) ]];then
|
||||||
|
DOTF="${COLOR_DOTF}."
|
||||||
|
elif [[ $(dotfiles_status check_push) ]];then
|
||||||
|
DOTF="${COLOR_DOTF}p"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n $DOTF ]];then
|
||||||
|
STATUS="${COLOR_DIVIDER}[${DOTF}${COLOR_DIVIDER}]"
|
||||||
|
fi
|
||||||
|
|
||||||
|
PS1="\n${COLOR_DIVIDER}┌──(${COLOR_USERNAME}\u${COLOR_USERHOSTAT}@${COLOR_HOSTNAME}\h${COLOR_DIVIDER})─[${COLOR_PATH}\w${COLOR_DIVIDER}]${EXIT_STATUS}${STATUS}${PYTHON_ENV}${K8S_CURRENT_CONTEXT}${GIT_BRANCH}"
|
||||||
PS1="${PS1}\n${COLOR_DIVIDER}└─\$${COLOR_OFF} "
|
PS1="${PS1}\n${COLOR_DIVIDER}└─\$${COLOR_OFF} "
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user