Last active
September 15, 2018 21:46
-
-
Save mdlinville/51f8d9191bb3a4690bcc598c3e3363b3 to your computer and use it in GitHub Desktop.
Bash profile debugging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Change these to where your git-completion.bash and git-prompt.sh live | |
# If you don't have them locally, get them from: | |
# https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh | |
# https://github.com/git/git/blob/master/contrib/completion/git-completion.bash | |
GIT_COMPLETION_FILE="/usr/local/git/current/share/git-core/git-completion.bash" | |
GIT_PROMPT_FILE="/usr/local/git/current/share/git-core/git-prompt.sh" | |
# Git tab-completion | |
if [ -f ${GIT_COMPLETION_FILE} ]; then | |
source "${GIT_COMPLETION_FILE}" | |
fi | |
# Stuff to create a basic prompt | |
# Color codes -- to add more, see https://misc.flogisoft.com/bash/tip_colors_and_formatting | |
GREEN='\[\e[32m\]' | |
CYAN='\[\e[36m\]' | |
YELLOW='\[\e[33m\]' | |
RED='\[\e[31m\]' | |
LTGREEN='\[\e[92m\]' | |
LTCYAN='\[\e[96m\]' | |
LTYELLOW='\[\e[93m\]' | |
LTRED='\[\e[91m\]' | |
LTGRAY='\[\e[37m\]' | |
RESET='\[\e[0m\]' | |
# Splitting out the parts of the prompt for maintainability | |
# To change the color of a part of the prompt, change its variable | |
# to one of the above | |
bash_prompt() { | |
# user | |
PS1_USER="${LTGREEN}\\u${RESET}" | |
# at-sign | |
PS1_AT="${LTRED}@${RESET}" | |
# host | |
PS1_HOST="${LTGREEN}\\h${RESET}" | |
# current working directory (not full path) | |
PS1_DIR="${CYAN}\\W${RESET}" | |
# Git prompt to show extra info when in a git repo | |
if [ -f ${GIT_PROMPT_FILE} ]; then | |
source "${GIT_PROMPT_FILE}" | |
# Configure git-prompt | |
GIT_PS1_SHOWDIRTYSTATE=true | |
GIT_PS1_SHOWSTASHSTATE=false | |
GIT_PS1_SHOWCOLORHINTS=true | |
GIT_PS1_SHOWUNTRACKEDFILES=false | |
# Create the git prompt element of the prompt | |
PS1_GIT_STATUS="${YELLOW}\$(__git_ps1)${RESET}" | |
# Build up the real prompt | |
PS1="[${PS1_USER}${PS1_AT}${PS1_HOST} ${PS1_DIR}]${PS1_GIT_STATUS}\$ " | |
else # if you don't have git-prompt.sh in the path | |
PS1="[${PS1_USER}${PS1_AT}${PS1_HOST} ${PS1_DIR}]\$ " | |
fi | |
} | |
bash_prompt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment