91 lines
2.3 KiB
Bash
91 lines
2.3 KiB
Bash
git-home() {
|
|
git --git-dir="$HOME/.git_home/" --work-tree="$HOME" "$@"
|
|
}
|
|
|
|
noerr() {
|
|
"$@" 2>/dev/null
|
|
}
|
|
|
|
alias gh='git-home'
|
|
alias highlight='grep -U999999 --color=always'
|
|
|
|
export PATH=$PATH:$HOME/.mgr_config/bin
|
|
|
|
FG_BLK="\001$(tput setaf 0)\002"
|
|
FG_RED="\001$(tput setaf 1)\002"
|
|
FG_GRN="\001$(tput setaf 2)\002"
|
|
FG_YEL="\001$(tput setaf 3)\002"
|
|
FG_BLU="\001$(tput setaf 4)\002"
|
|
FG_MGN="\001$(tput setaf 5)\002"
|
|
FG_CYN="\001$(tput setaf 6)\002"
|
|
FG_WHT="\001$(tput setaf 7)\002"
|
|
FG_DEF="\001$(tput setaf 9)\002"
|
|
|
|
BG_BLK="\001$(tput setab 0)\002"
|
|
BG_RED="\001$(tput setab 1)\002"
|
|
BG_GRN="\001$(tput setab 2)\002"
|
|
BG_YEL="\001$(tput setab 3)\002"
|
|
BG_BLU="\001$(tput setab 4)\002"
|
|
BG_MGN="\001$(tput setab 5)\002"
|
|
BG_CYN="\001$(tput setab 6)\002"
|
|
BG_WHT="\001$(tput setab 7)\002"
|
|
BG_DEF="\001$(tput setab 9)\002"
|
|
|
|
BOLD="\001$(tput bold)\002"
|
|
|
|
RST="\001$(tput sgr0)\002"
|
|
|
|
git_root() {
|
|
git rev-parse --show-toplevel 2> /dev/null
|
|
}
|
|
|
|
prompt_function() {
|
|
prompt=""
|
|
|
|
HOST_COLOR_ID=$(( 16#$(hostname | md5sum | cut -f1 -d' ') % 7 + 1)) # [1, 7]
|
|
HOST_COLOR="${RST}\001$(tput setaf $HOST_COLOR_ID)\002"
|
|
GIT_COLOR="${RST}${FG_CYN}"
|
|
DIR_COLOR="${RST}${FG_YEL}"
|
|
WARN_COLOR="${RST}${BOLD}${FG_RED}"
|
|
|
|
if [[ "$(whoami)" == root ]]; then
|
|
prompt+="${WARN_COLOR}"
|
|
else
|
|
prompt+="${HOST_COLOR}"
|
|
fi
|
|
prompt+="$(whoami)@$(hostname)${RST}:"
|
|
if root=$(git_root); then
|
|
# If in a git repository, only print the path relative to the repo root
|
|
path=$(git rev-parse --show-prefix)
|
|
ref=$(git symbolic-ref --short -q HEAD)
|
|
if [[ $ref == "" ]]; then
|
|
ref="${WARN_COLOR}detached${GIT_COLOR}"
|
|
fi
|
|
dirty=$(git diff-index --quiet HEAD)
|
|
prompt+="${GIT_COLOR}[$(basename $root)@${ref}:${DIR_COLOR}${path}${fg}${GIT_COLOR}]${RST}"
|
|
else
|
|
# If not in a git repo, print the full path
|
|
prompt+="${DIR_COLOR}[$(dirs)]${RST}"
|
|
fi
|
|
|
|
printf "$prompt\$ "
|
|
}
|
|
|
|
PS1="\$(prompt_function)"
|
|
|
|
# Add doom emacs to path
|
|
export PATH=$PATH:$HOME/.emacs.d/bin/
|
|
|
|
export EDITOR="emacs"
|
|
export VISUAL="emacs"
|
|
|
|
# Special sauce for better vterm integration in emacs
|
|
if [[ "$INSIDE_EMACS" = 'vterm' ]] \
|
|
&& [[ -n ${EMACS_VTERM_PATH} ]] \
|
|
&& [[ -f ${EMACS_VTERM_PATH}/etc/emacs-vterm-bash.sh ]]; then
|
|
source ${EMACS_VTERM_PATH}/etc/emacs-vterm-bash.sh
|
|
|
|
alias find-file="vterm_cmd find-file"
|
|
alias magit="vterm_cmd magit"
|
|
fi
|