Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: "converting"

Joakim Ryden wrote:
> i found a neat looking prompt written for bash that i'd like to use with
> zsh. the whole thing looks like:
> TOPBAR="$SP$MT$CL$CR User: $CB\u$NC$CR  Host: $CB\h$NC$CR Time:
> $CB\t$NC$RP"
> PS1="\n$CW[$CB\w$CW]$NC$TOPBAR"
> i'm not really sure at all where to start with this, the only thing i
> would really know how to do is "translate" the "\u,\h,\w" to something
> zsh understands. can someone point me to a good place for starting to
> "convert" this?

hrmm perhaps TFM?  search for 'PROMPT EXPANSION' in the zshall man page.

       %n     $USERNAME.
       %M     The full machine hostname.
       %m     The  hostname  up to the first `.'.  An integer may
              follow the `%' to specify how  many  components  of
              the hostname are desired.  With a negative integer,
              trailing components of the hostname are shown.

as far as \w, zsh gives a lot of options for how to display the working
directory. i suggest reading the man page.

looking at other peoples' zshrc files can be very helpful as well.
check dotfiles.net, and do searches on google.

zsh is (IMHO) more flexible than bash as far as doing prompts.

also, you don't need to do as much fancy stuff to put stuff in the xterm

i have:

PS1="%B%m%b%# "

(hostname in bold, percent as a regular user, pound sign (#) as root) as
my prompt, and then:

case $TERM in
                precmd () {print -Pn "\e]2;%n@%m%#  %~ %l  %w :: %T\a"}
                preexec () {print -Pn "\e]2;%n@%m%#  <$1>  %~ %l  %w :: %T\a"}

(if i'm in rxvt or xterm put fancy crap in the titlebar).


Messages sorted by: Reverse Date, Date, Thread, Author