From: Vincent Lefevre <vincent@vinc17.org>
To: ZSH-users <zsh-users@sunsite.dk>
Subject: Re: Coolest prompt?
Date: Thu, 17 Jun 2004 14:25:27 +0200 [thread overview]
Message-ID: <20040617122527.GF12350@ay.vinc17.org> (raw)
In-Reply-To: <20040615151840.GC7673@cvmx.de>
On 2004-06-15 17:18:40 +0200, Julius Plenz wrote:
> To see this Prompt in action, look at this example:
>
> e/www/plenz,0% cd www/
> w/plenz/www,0% cd plenz.com/
> w/plenz.com,0% cd /tmp
> /tmp,0% sleep 10&
> [1] 16056
> /tmp,1% cd
> [1] + 16056 done sleep 10
> e/www/plenz,0%
>
> So, you see, there is a fixed path-length and the number of
> background jobs. I really like this prompt, its simple but gives
> enough information.
You could avoid to write ",0" when there are no background jobs.
Here's my prompt code:
setopt PROMPT_SUBST
setopt PROMPT_PERCENT
zmodload -i zsh/parameter
precmd()
{
local njobs
if [[ $domain == local.ay && "$(pmu_battery)" == "Battery" ]] then
psvar[1]="[$(pmu_percent)%]"
else
psvar[1]=""
fi
njobs=$#jobstates;
case $njobs in
0) psvar[2]=();;
1) psvar[2]="1 job";;
*) psvar[2]="$njobs jobs";;
esac
[[ -n $TTY && $TERM == (xterm*|dtterm|rxvt|screen*) ]] &&
{
print -nP "\e]1;%m:%.\x07"
print -nP "\e]2;%(2v. %2v |.)${WINTITLE:+ $WINTITLE |} %n@%m - %~ | %y"
[[ $TERM == screen* ]] && print -n .
print -n "\x07"
} > $TTY
}
TRAPCLD() { [[ -o interactive && -n $TTY ]] && precmd }
putprompt()
{
local preprompt postprompt prefail postfail
if [[ -n $COLORTERM ]] then
local bgcol=`tput setab 0`
preprompt="%{`tput bold`$bgcol%(2v.`tput setaf 2`.`tput setaf 3`)%}"
postprompt="%{`tput sgr0`%}"
prefail="%{`tput setab 1`%}"
postfail="%{$bgcol%}"
fi
PS1="%m:%20<...<%~%<<%(?..${prefail}[%?]${postfail})%1v%(#.#.>) "
RPS1="<%*"
PS1="$preprompt$PS1$postprompt"
RPS1="$preprompt$RPS1$postprompt"
PS2="$preprompt$PS2$postprompt"
PS3="$preprompt$PS3$postprompt"
PS4="$preprompt$PS4$postprompt"
}
putprompt
--
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/>
100% validated (X)HTML - Acorn / RISC OS / ARM, free software, YP17,
Championnat International des Jeux Mathématiques et Logiques, etc.
Work: CR INRIA - computer arithmetic / SPACES project at LORIA
next prev parent reply other threads:[~2004-06-17 12:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-11 10:29 Ziggy
2004-06-11 12:07 ` Thomas Köhler
2004-06-11 21:20 ` Aaron Davies
2004-06-11 22:34 ` William Scott
2004-06-15 15:18 ` Julius Plenz
2004-06-17 12:25 ` Vincent Lefevre [this message]
2004-06-17 17:50 ` Sami Samhuri
2004-06-18 16:08 ` Sartoo
2004-07-08 1:15 ` Geoff Wing
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040617122527.GF12350@ay.vinc17.org \
--to=vincent@vinc17.org \
--cc=zsh-users@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).