Image of the glider from the Game of Life by John Conway
Skip to content

More ZSH Prompt Love

Ever since discovering ZSH 3 years ago, I've been addicted, but it wasn't until a good 2 years into using the prompt on a daily basis that I decided to do some radical work with my prompt. I've blogged about this before a couple times, making improvements along the way: post 0, post 1, post 2, post 3. Check out those posts if you're interested in what I've done to the prompt, and extra screenshots.

At the Utah Open Source Conference, I gave a BOF on Unix shells. The turnout was good, and we had a great discussion. I presented on my default prompt for ZSH, showing all the hidden features of the prompt. However, I had forgotten that I had removed battery status from my prompt, because I was depending on APM, which is no longer compiled in the kernel. A couple people have asked me since then why I'm depending on APM and not ACPI. I don't have an answer, other than that was just what I coded. So, last night, I put up an ACPI implementation, and it works great. As with the APM implementation, if the battery percentage is less than 15%, the percentage display is red. If it's less than 50% but greater than 14%, it's yellow, and if it's less than 100% but greater than 49%, it's blue. If it's 100%, or the tool "acpi" is not installed, then it doesn't show up. Here's a screenshot below:

Battery Percentage in ZSH prompt

While hanging out in our local LUG channel for the Ogden Area Linux Users Group, I got talking with Seth about prompts. He decided to change his, including adding the dog from Nethack randomly "moving" in the prompt. He also mentioned changing the color of the path if the present working directory was not writable. I really liked this idea, and decided to implement it in my prompt. Here's a screenshot of that in action:

Path color change in ZSH prompt

I change the path color to yellow if the present working directory is not writable, as it's noticeable enough to catch your attention, but subtle enough to not get in the way, and be distracting.

As usual, if you want the source, here it is. Yes, it's public domain, as mentioned in the code, so have at it.

{ 7 } Comments

  1. nixternal | October 14, 2009 at 10:54 am | Permalink

    Groovy idea with the r/w ability of the directory, added that one to my config. On a related note, for your Git stuff, you can make it even easier using zsh-lovers and then adding:


    Into your precmd function. And then you just use ${vcs_info_msg_0_} in your prompt. This will give you git, bzr, svn, cvs, hg, and others for vcs support.

    Here is a screeny of what mine currently looks like:

  2. Adam Petaccia | October 14, 2009 at 12:24 pm | Permalink

    A nifty script, but do you have any idea why I don't have any colors (ls --color gives me colors, btw). I'm using Gnome-terminal, what are you using?

  3. Adam | October 14, 2009 at 12:44 pm | Permalink

    I like the prompt. Currently I'm using the totally over the top prompt found here: . Maybe I'll take a whack at porting your ACPI work to work with what I'm using.

  4. Daniel | October 15, 2009 at 2:25 pm | Permalink

    I prefer red when a path is not writable..
    also, I find 3 lines for each prompt quite too much.
    also^2, what do all the exclamation marks are for? quite distracting.. my first thought had been "!" => "not writable" in this context.

  5. Aaron | October 15, 2009 at 2:41 pm | Permalink

    @Daniel If you prefer red to paths that aren't writable, then go ahead and take the source, and change it. Same could be said if you don't like the three lines, but prefer two, or one. Also, there are only 2 explanation marks, and they're for style. They're just red as opposed to bright red, so as to not be distracting, but provide style. Now that I think about it, I might change it to the vertical bar. I guess you don't like the wakas on the left either? Again, the source is right there in the post, so feel free to change it to your hearts content.

  6. Daniel Correia | February 7, 2010 at 12:07 am | Permalink

    @Adam Change

    if [[ "$terminfo[colors]" -gt 8 ]]; then


    if [[ "$terminfo[colors]" -ge 8 ]]; then

    And that should make colours work for you.

  7. Shellcat-Zero | September 24, 2017 at 12:23 am | Permalink

    The VCS feature appears to be broken, I never get any version control information in the prompt when navigating through repositories.

{ 3 } Trackbacks

  1. [...] my !zsh prompt, for those who are interested: [...]

  2. [...] it was just distracting. But I live having both a right and left font so I stole a large portion of Aaron Toponce’s zshrc and have made my new prompt that I am rather happy with. Check it out and share what you [...]

  3. Aaron Toponce : My Tmux Hardstatus Theme | March 28, 2012 at 10:09 pm | Permalink

    [...] possible. Well, I got it to that point, then took it even further to work with my custom Irssi and ZSH themes (I want everything to tie in nicely). The only thing left is getting Mutt in order, but [...]

Post a Comment

Your email is never published nor shared.