Skip to content

Instantly share code, notes, and snippets.

@shyam-habarakada
Created April 3, 2017 16:04
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 shyam-habarakada/e7a82d87fa46ad88dd02a04249e5d2bf to your computer and use it in GitHub Desktop.
Save shyam-habarakada/e7a82d87fa46ad88dd02a04249e5d2bf to your computer and use it in GitHub Desktop.
# add this to your ~/.bash_profile to get a bash prompt like
# ~/your-path (git-branch-name) /dockerMachineName/ $
function color_my_prompt {
local __user_and_host="\[\033[01;32m\]\u@\h"
local __cur_location="\[\033[01;34m\]\w"
local __git_branch_color="\[\033[31m\]"
local __git_branch='`command git branch 2> /dev/null | /usr/bin/grep -e ^* | sed -E s/^\\\\\*\ \(.+\)$/\(\\\\\1\)\ /`'
local __docker_machine_name_color="\[\033[36m\]"
local __docker_machine_name='`if [ $DOCKER_MACHINE_NAME ]; then echo "/$DOCKER_MACHINE_NAME/ "; fi`'
local __prompt_tail="\[\033[35m\]$"
local __last_color="\[\033[00m\]"
export PS1="$__cur_location $__git_branch_color$__git_branch$__docker_machine_name_color$__docker_machine_name$__prompt_tail$__last_color "
}
color_my_prompt
@shyam-habarakada
Copy link
Author

shyam-habarakada commented Apr 3, 2017

Depending on your terminal theme, it will look similar to this,

image

master is the git branch and manager is the docker-machine-name that the current ENV exports.

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