Skip to content

Instantly share code, notes, and snippets.

@MikeMitterer
Last active July 6, 2023 10:00
Show Gist options
  • Save MikeMitterer/4f45c67751f7e9f0b3c6cb23eeb12b4a to your computer and use it in GitHub Desktop.
Save MikeMitterer/4f45c67751f7e9f0b3c6cb23eeb12b4a to your computer and use it in GitHub Desktop.
Prompt for Bash (.bashrc) + ZSH (.zshrc)
# ZSH -------------------------------------------------------------------------
# https://zsh.sourceforge.io/Doc/Release/Prompt-Expansion.html
#
# ZSH default colors:
# black, red, green, yellow, blue, magenta, cyan and white
_USER_COLOR="%{$fg_bold[blue]%}"
PROMPT="${_USER_COLOR}%n%f@%{$fg_bold[green]%}%M%f:"
PROMPT+=' %{$fg[yellow]%}%c%{$reset_color%} $(git_prompt_info)'
# Bash -----------------------------------------------------------------------
# https://en.wikipedia.org/wiki/ANSI_escape_code#3-bit_and_4-bit
# https://www.gnu.org/software/bash/manual/html_node/Controlling-the-Prompt.html
#
_GREEN="\[\033[01;32m\]"
_RED="\[\033[01;31m\]"
_BLUE="\[\033[01;34m\]"
_YELLOW="\[\033[01;33m\]"
_RESET="\[\033[00m\]"
_USER_COLOR="${_BLUE}"
if [ "$color_prompt" = yes ]; then
PS1="${debian_chroot:+($debian_chroot)}${_USER_COLOR}\u${_RESET}@${_GREEN}\H${_RESET}: ${_YELLOW}\W${_RESET} "
else
PS1='${debian_chroot:+($debian_chroot)}\u@\H:\w\$ '
fi
unset color_prompt force_color_prompt _USER_COLOR _GREEN _RED _BLUE _YELLOW _RESET
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment