Skip to content

Instantly share code, notes, and snippets.

@glebm
Created February 21, 2011 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glebm/837247 to your computer and use it in GitHub Desktop.
Save glebm/837247 to your computer and use it in GitHub Desktop.
tee -a
export EDITOR=`which vim`
#-----------------------------------------------------------------------------
# Prompts
#-----------------------------------------------------------------------------
set_prompts() {
# regular colors
local DEFAULT="\[\033[0m\]" # standard terminal fg color
local BLACK="\[\033[0;30m\]"
local RED="\[\033[0;31m\]"
local GREEN="\[\033[0;32m\]"
local YELLOW="\[\033[0;33m\]"
local BLUE="\[\033[0;34m\]"
local MAGENTA="\[\033[0;35m\]"
local CYAN="\[\033[0;36m\]"
local WHITE="\[\033[0;37m\]"
# emphasized/bold colors
local EM_BLACK="\[\033[1;30m\]"
local EM_RED="\[\033[1;31m\]"
local EM_GREEN="\[\033[1;32m\]"
local EM_YELLOW="\[\033[1;33m\]"
local EM_BLUE="\[\033[1;34m\]"
local EM_MAGENTA="\[\033[1;35m\]"
local EM_CYAN="\[\033[1;36m\]"
local EM_WHITE="\[\033[1;37m\]"
# background colors
local BG_BLACK="\[\033[40m\]"
local BG_RED="\[\033[41m\]"
local BG_GREEN="\[\033[42m\]"
local BG_YELLOW="\[\033[43m\]"
local BG_BLUE="\[\033[44m\]"
local BG_MAGENTA="\[\033[45m\]"
local BG_CYAN="\[\033[46m\]"
local BG_WHITE="\[\033[47m\]"
# Default prompts
PS1="${EM_GREEN}\u ${EM_BLUE}\w"
PS2="${EM_BLUE}>${DEFAULT} "
PS3=$PS2
PS4="${EM_BLUE}+${DEFAULT} "
# Special red-colored prompts for root
if [ "$UID" = 0 ]; then
PS1="${EM_RED}\u ${EM_RED}\w${EM_GREEN}${EM_RED}"
PS2="${EM_RED}>${DEFAULT} "
PS3=$PS2
PS4="${EM_RED}+${DEFAULT} "
fi
PS1="${PS1}${EM_WHITE}\$(__git_ps1 ' (%s)') ${EM_GREEN}\$${DEFAULT} "
# Special prompt for Debian: Include variable identifying the chroot you work in in the prompt
# (copied from default Debian .bashrc file, never actually tested)
if [ -z "$debian_chroot" ] && [ -r "/etc/debian_chroot" ]; then
export debian_chroot=$(cat /etc/debian_chroot)
PS1="${debian_chroot:+($debian_chroot)}${PS1}"
fi
export PS1 PS2 PS3 PS4
}
set_prompts
unset -f set_prompts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment