Skip to content

Instantly share code, notes, and snippets.

@edysmp
Last active September 4, 2023 20:32
Show Gist options
  • Save edysmp/d4c80d641b7a0d43c23ebb6c2953c263 to your computer and use it in GitHub Desktop.
Save edysmp/d4c80d641b7a0d43c23ebb6c2953c263 to your computer and use it in GitHub Desktop.
Edys' custom bash prompt
HOST:
source /usr/lib/git-core/git-sh-prompt
export PS1='\e[0;30m\e[106m\u \w\e[0;36m\e[40m$(__git_ps1 " (%s)")\e[m\n\$ '
WEB CONTAINER:
export PS1='\e[0;30m\e[47m\u \w\e\e[m\n$ '
@edysmp
Copy link
Author

edysmp commented Sep 4, 2023

ZSH

#GIT_PROMPT
parse_git_branch() {
    git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p'
}
COLOR_DEF='%f'
COLOR_USR='%F{243}'
COLOR_DIR='%F{197}'
COLOR_GIT='%F{39}'
# About the prefixed `$`: https://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_03.html#:~:text=Words%20in%20the%20form%20%22%24',by%20the%20ANSI%2DC%20standard.
NEWLINE=$'\n'
# Set zsh option for prompt substitution
setopt PROMPT_SUBST
export PROMPT='${COLOR_USR}%n@%M ${COLOR_DIR}%d ${COLOR_GIT}$(parse_git_branch)${COLOR_DEF}${NEWLINE}%% '
#END_GIT_PROMPT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment