Skip to content

Instantly share code, notes, and snippets.

@4x8Matrix
Last active June 19, 2024 12:46
Show Gist options
  • Select an option

  • Save 4x8Matrix/5a8b931959bab3a8c38ba7d7b47854a4 to your computer and use it in GitHub Desktop.

Select an option

Save 4x8Matrix/5a8b931959bab3a8c38ba7d7b47854a4 to your computer and use it in GitHub Desktop.
bash-prompt
function _setprompt {
local NOCOLOR="\[\033[0m\]"
local INFO_COLOR='\[\033[1;34m\]'
local PROMPT_COLOR='\[\033[1;32m\]'
function _parse_git_branch() {
if [ -n "$(git rev-parse --git-dir 2> /dev/null)" ]; then
if [ "$(git rev-list --count --all)" != "0" ]; then
echo -e "-[${INFO_COLOR}$(git rev-parse --abbrev-ref HEAD)${PROMPT_COLOR}]"
else
echo -e "-[${INFO_COLOR}Unknown${PROMPT_COLOR}]"
fi
fi
}
PS1="${PROMPT_COLOR}┌──(${INFO_COLOR}\u@\h${PROMPT_COLOR})$(_parse_git_branch)${PROMPT_COLOR}-[${INFO_COLOR}\w${PROMPT_COLOR}]\n└─${INFO_COLOR}$ "
PS2="${DARKGRAY}>${NOCOLOR} "
PS3="Number: "
PS4="${DARKGRAY}+${NOCOLOR} "
}
export PROMPT_COMMAND='_setprompt'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment