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

Re: If then Prompt



On 5/24/07, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
On 24/05/07, fREW <frioux@xxxxxxxxx> wrote:
> Hey all,
>
> I was thinking that it would be cool to show the number of jobs if
> there were more than 0 jobs.  I know you can do this with things like
> the return value, is there any way to do it with jobs?

Sure,
PS1=$'%(1j.%j jobs .)'

--
Mikael Magnusson


Awesome!  Thanks!  If anyone cares or wants to see it, here is my
current prompt.


host_color=cyan
history_color=yellow
user_color=green
root_color=red
directory_color=magenta
error_color=red
jobs_color=green

host_prompt="%{$fg_bold[$host_color]%}%m%{$reset_color%}"

jobs_prompt1="%{$fg_bold[$jobs_color]%}(%{$reset_color%}"

jobs_prompt2="%{$fg[$jobs_color]%}%j%{$reset_color%}"

jobs_prompt3="%{$fg_bold[$jobs_color]%})%{$reset_color%}"

jobs_total="%(1j.${jobs_prompt1}${jobs_prompt2}${jobs_prompt3} .)"

history_prompt1="%{$fg_bold[$history_color]%}[%{$reset_color%}"

history_prompt2="%{$fg[$history_color]%}%h%{$reset_color%}"

history_prompt3="%{$fg_bold[$history_color]%}]%{$reset_color%}"

history_total="${history_prompt1}${history_prompt2}${history_prompt3}"

error_prompt1="%{$fg_bold[$error_color]%}<%{$reset_color%}"

error_prompt2="%{$fg[$error_color]%}%?%{$reset_color%}"

error_prompt3="%{$fg_bold[$error_color]%}>%{$reset_color%}"

error_total="%(?..${error_prompt1}${error_prompt2}${error_prompt3} )"

if [[ $TERM == xterm ]]; then
   directory_prompt=""
else
   directory_prompt="%{$fg[$directory_color]%}%~%{$reset_color%} "
fi

if [[ $USER == root ]]; then
   post_prompt="%{$fg_bold[$root_color]%}%#%{$reset_color%}"
else
   post_prompt="%{$fg_bold[$user_color]%}%#%{$reset_color%}"
fi

PS1="${host_prompt} ${jobs_total}${history_total}
${directory_prompt}${error_total}${post_prompt} "


if [[ $TERM == linux ]]; then
else
   precmd () { print -Pn "\e]0;%m: %~\a" }
fi


It doesn't show the username, because it usually doesn't matter to me
what user I am logged into (it's just a user or root) so I don't show
that.  Also the last part which will put the current directory in the
title of an xterm doesn't work if you are in a screen session.

-fREW



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