Made myself a nice new bash prompt using lua. Code can be found in this gist.

I started off trying to set PS1 , but bash will incorrectly calcuate the prompt length. This leaves you with strange line wrapping behaviour. Thanks to Rob Hoelz I found out about PROMPT_COMMAND , which allows you to run a command before PS1 is printed.

I used ljsyscall to avoid as many new processes as possible, they could be replaced by commands if you want.

To get the git and mercurial (hg) status, I had to call out to see if the current directory is inside a repository: this can sometimes be slow, as git and hg have to traverse the whole way up the directory tree stat -ing for .git and .hg folders.