Tag Archives: prompt

A zsh adventure

Oh yeah, zsh guys.  It’s awesome, and you should know that, but what makes one switch from good ol’ bash?  Generally, it’s prompt magic, but really there’s some other nice features that make it worth considering.  But first, prompt magic.  I had some trouble getting the prompt to respect the width of my terminal, but it was resolved by escaping some things I had in there.  I ended up with this:

To do that, you just need the following in your .zshrc in your home directory:

autoload -U colors && colors

# Prompt Customization
PS1="%{$fg[blue]%}%n%{$fg_bold[yellow]%}✯%{$fg[blue]%}%m%{$fg_bold[black]%}:%{$fg_no_bold[green]%}%~ %{$fg_bold[black]%}%#%{$reset_color%} "
RPS1="%{$fg_bold[black]%}%D{%Y%m%d %H:%M}%{$reset_color%}"

Yes, that’s a unicode character.  That’s perfectly legal, which is awesome.  Next, we have to get bash reverse history search functionality working in zsh, which is really easy with a simple keybinding for control-r:

## History search like bash
bindkey '\e[3~' delete-char
bindkey '^R' history-incremental-search-backward

And we’re off to the races.  So far, I really like it.  I recommend that you *nix nerds try it.