Computer :(

/home/rrix:blog:tags:cgit:rss

$PS1 tricks

Back when I switched from Debian to Fedora, the biggest, and hardest to get used to, change was the fact that the bash prompt looked like this:

![](/images/PS1unhacked.png)

Not having the full directory in the pathname had always been hard to get used to, but as I learned to delve deeper and deeper into source trees, that became really nice. And then (I think, feel free to correct me) Pinochio at Akademy reminded that that setup has its own set of limitations, and it was more and more clear that having only part of the PWD in the prompt could be an annoyance, particularly as I used pwd to constantly check whether I was in a CMake build dir, or the source dir. Well, not any more.

![](/images/PS2hacks.png)

bash's ability to colorize things suddenly rocks hard. :)

I found it useful, feel free to hack on it, make it less craptastic… I picked the worst possible I-hate-Bash-Scripting way of doing this, perhaps some gurus can improve on it:

function startbd()
{
  if [ "$(pwd|grep build)" = "" ];
   then echo ;
   else echo -ne '33[1;31m';
  fi
}

function endbd()
{
  if [ "$(pwd|grep build)" = "" ];
   then echo ;
   else echo -ne '33[0;34m';
  fi
}

PS1="e[0;34m[$(date +%k:%M:%S)] [u@h $(startbd)W$(endbd)]\$ e[m"