Simple script to give me the name of my current knife block target.
Used to provide that hint in my bash_it custom prompt kind of like so:
chef_knife_block() {
if [ -f $HOME/.chef/knife.rb ]; then
knife_target=$(readlink $HOME/.chef/knife.rb)
echo "[$(basename -s .rb ${knife_target/knife-/})]"
else
echo ""
fi
}
# fancy stuff for bashit
PS1="${TITLEBAR}${bold_red}┌─${reset_color}$(chef_knife_block)$(modern_scm_prompt)[${cyan}\W${normal}][$(battery_charge)]$(is_vim_shell)
${bold_red}└─▪${normal} ${HOSTNAME%%.*} $ "
Results in giving me a bash propt with the following hint on my terminal prompt which knife block I'm pointing at:
┌─[home][~][]
└─▪ gibson > knife block n1nj4
The knife configuration has been updated to use n1nj4
┌─[n1nj4][~][]
└─▪ gibson >