Skip to content

Instantly share code, notes, and snippets.

@eze-kiel
Last active February 28, 2023 09:32
Show Gist options
  • Save eze-kiel/bb09b4a4c8545780fb7455152fd0b6ed to your computer and use it in GitHub Desktop.
Save eze-kiel/bb09b4a4c8545780fb7455152fd0b6ed to your computer and use it in GitHub Desktop.
# prompt customization for .bashrc
# `root` has a red prompt, others a yellow/brown one.
# If we are connected remotely, `@<hostname>` shows first.
build_ps1() {
local prompt_color='\[\e[33m\]'
local host=''
[[ $UID -eq 0 ]] && prompt_color='\[\e[1;31m\]'
[[ $SSH_TTY ]] && host="@$HOSTNAME "
echo "${prompt_color}${host}\w\[\e[0m\]"
}
PS1="$(build_ps1)\$(__git_ps1) \$ "
PS2='\\ '
PS4='+ $LINENO: '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment