ryuslash/baps1 — pull request #1 by babab (2012-05-27 20:25:11+00:00)
Title: Add install and clean targets to Makefile

Hey ryuslash,

First of all, thanks again so much for taking the time to build this awesome program.
I really would like to extend it a little so it can become a tool to create a custom PS1 prompt with much ease.

I'm thinking about turning something like this:

# file: .bashrc

exitcode_ps1()
{
if [ $1 -gt 0 ]; then
echo " err:$1"
fi
}

sshkey_ps1()
{
ssh-add -l 2>/dev/null >/dev/null
case $? in
0)
echo "+"
;;
1)
echo "-"
;;
2)
echo "n/a"
;;
esac
}

PS1="\[$(tput bold; tput setaf 1)\]\n\u\ # username in red
\[$(tput op)\] at \ # 'at' in default font-color
\[$(tput setaf 3)\]\h\ # hostname in yellow
\[$(tput setaf 1)\]\$(exitcode_ps1 \$?)\ # non-zero exit warning in red
\[$(tput setaf 5)\] \!\ # no of shell cmd in magenta
\[$(tput setaf 6)\] \$(sshkey_ps1)\ # ssh-key status in cyan
\[$(tput setaf 2)\] \$(baps1)\ # baps1(as current) in green
\[$(tput setaf 1)\]\$(__git_ps1 ' %s')\ # git-branch in red
\[$(tput setaf 2)\]\n\w\ # pwd in green
\[$(tput setaf 3)\]\$\[$(tput op)\] " # prompt 'symbol' in yellow

Into something like this:

# file: .bashrc
PS1=$(baps1 --username red --string at --hostname yellow \
--exit-status red --shell-cmd-no magenta \
--ssh-key-status cyan --timediff green \
--git-branch red --pwd green --symbol yellow)

Although it may not be desirable to let baps1 do *all* the prompt stuff, since
some things are better handled by the shell I guess. Like shell-cmd-no,
exit-status and git-branch.

I know too little of C to develop this in a short time, but I think I'll try
to get to a point where baps1 can operate in a way close to my example in
small steps.

These Makefile changes are the least I can do at this moment, but since you
got me excited about this, I think it's safe to expect more from me in the
future :)