Skip to content

Instantly share code, notes, and snippets.

@themightychris
Created December 26, 2017 21:25
Show Gist options
  • Save themightychris/02d8b7485acf459cbcc3d0b3dba87a42 to your computer and use it in GitHub Desktop.
Save themightychris/02d8b7485acf459cbcc3d0b3dba87a42 to your computer and use it in GitHub Desktop.
BLACK="\033[01;30m"
MAGENTA="\033[1;31m"
ORANGE="\033[1;33m"
GREEN="\033[1;32m"
PURPLE="\033[1;35m"
WHITE="\033[1;37m"
BOLD=""
RESET="\033[m"
PROMPT_HOSTNAME="$(hostname)"
PROMPT_SYMBOL="⚡ "
PROMPT_SITE="\[${BOLD}${MAGENTA}\]$PROMPT_HOSTNAME"
PROMPT_GIT_WORKTREE="\$(git rev-parse --show-toplevel 2>/dev/null)"
PROMPT_GIT_RELATIVE="\$(realpath --relative-to=\"$PROMPT_GIT_WORKTREE\" .)"
PROMPT_LAYER="\[${BOLD}${ORANGE}\]\$(basename \"$PROMPT_GIT_WORKTREE\")"
PROMPT_BRANCH="\[$PURPLE\]\$(git symbolic-ref --short -q HEAD 2> /dev/null)\[$GREEN\]\$([[ -n \$(git status --porcelain 2> /dev/null) ]] && echo \"**\")"
PROMPT_GIT="$PROMPT_LAYER#$PROMPT_BRANCH\[$WHITE\] on $PROMPT_SITE\[$WHITE\]:\[$GREEN\]$PROMPT_GIT_RELATIVE"
PROMPT_REG="$PROMPT_SITE\[$WHITE\]:\[$GREEN\]\w"
export PS1="\$([[ -n \"$PROMPT_GIT_WORKTREE\" ]] && echo \"$PROMPT_GIT\" || echo \"$PROMPT_REG\")\[$WHITE\]\n$PROMPT_SYMBOL\[$RESET\]"
export PS2="\[$ORANGE\]→ \[$RESET\]"
@themightychris
Copy link
Author

themightychris commented Dec 26, 2017

Installation

Save to home directory:

wget -O ~/.bash_prompt https://gist.githubusercontent.com/themightychris/02d8b7485acf459cbcc3d0b3dba87a42/raw/16a53ae4eccffe3de9587f922e800dfd676e10c4/.bash_prompt

Try it out:

source ~/.bash_prompt

Make it permanent:

echo "source ~/.bash_prompt" >> ~/.bashrc

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