« enough is enough | Main | pubwalk.com »
August 12, 2005
s/bash/zsh/
for months i've envied my coworker Morgen's shell prompt. each command is separated from the previous one with an underline, and the system time is displayed flush with the right side of the window on the line where you enter your command. the whole thing is bolded. it's hot stuff, and yesterday i decided i wanted it for myself.
unfortunately, Morgen uses zsh and i use bash. so i asked some friends how to translate his prompt definition into bash. then i upped the ante and offered a beer to anybody who'd do it for me. one guy tried halfheartedly, but like half a dozen people just said "switch to zsh". i REALLY wanted the prompt, so i figured i'd give it a try.
so far it's exactly the same. all my aliases and exports worked with no changes. and the prompt is so hot. here, check it out:

here's the .zshrc snippet that sets the prompt:
PROMPT='%B% %U %u%b
%B%n@%m:%b%B%~%b
%(?..RET: %? )%B%#%b ' # default prompt
RPROMPT=" %B%D{%l:%M:%S}%b" # prompt for right side of screen
update: i didn't realize at first, but this prompt also prints the return code of the previous command if it's non-zero. that's what the (?..RET: %? ) business is. awesome! Morgen is my hero.
update: anybody know how to enable emacs keybindings? i need my ctl-A!
Posted by bcm at August 12, 2005 12:02 PM
Comments
Now I'm rocking the zsh too!
Posted by: Smartacus
at August 12, 2005 04:23 PM
that is hot shit. let me know when you figure out emacs key bindings. i might follow you over to zsh world.
Posted by: le
at August 13, 2005 12:16 AM
You could start with the "Bash Prompts HOWTO," which has a method for setting term-width lines. I think with a tiny bit of hackery you could have exactly what you want, even in Bash.
http://www.linuxselfhelp.com/howtos/Bash-Prompt/Bash-Prompt-HOWTO-12.html#ss12.6
Posted by: chemicalpilate
at August 13, 2005 10:15 PM
Holy shit, that is sexy.
Posted by: olivia
at August 14, 2005 12:27 AM
PS: Moo.
Posted by: olivia
at August 14, 2005 12:28 AM
Post a comment
Thanks for signing in, . Now you can comment. (sign out)
(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)