I am trying to echo to the console in the event that a successful git checkout happened, but cannot get it to work.
function prompt_command {
prev=`fc -ln -1`
ecode=$?
if [ ecode = 0 ]
then
if [ `echo $prev | grep -c "^git co -b"` -ge 0 ] || [ echo $prev | `grep -c "^git checkout -b"` -ge 0 ]
then
echo "SUCCESSFULLY CHECKED OUT!"
fi
fi
}
export PROMPT_COMMAND=prompt_command
Context:
The eventual aim is to update the new git branch's description to indicate which branch it was checked out from. E.g. If I checkout "my_new_feature" from "dev", I want to automatically run:
git config branch.my_new_feature.description "[FROM:dev]"
Then modify the prompt to include the parent branch.
[ ecode = 0 ]
should be[[ $ecode -eq 0 ]]
[ "$ecode" = 0 ]
.