Skip to content

Instantly share code, notes, and snippets.

@maewolfsky
Created February 14, 2014 15:16
Show Gist options
  • Save maewolfsky/9002802 to your computer and use it in GitHub Desktop.
Save maewolfsky/9002802 to your computer and use it in GitHub Desktop.
Really basic way to display the currently "active" chef-server in your bash prompt
function parse_chef_server
{
if [ -r .chef/knife.rb ]; then
knife_config='.chef/knife.rb'
elif [ -r ../.chef/knife.rb ]; then
knife_config='../.chef/knife.rb'
fi
## Make sure that the knife_config was actually set before running the grep
[[ $knife_config ]] && grep chef_server_url $knife_config | awk -F/ '{print "[chef:" $3 "]"}'
}
PS1="\[\033[01;32m\]\u@\h \[\033[01;34m\]\W \[\033[00m\] \n\$(parse_git_branch)\$(parse_chef_server)$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment