* previous cmd in RPS1
@ 2005-08-26 9:36 Miek Gieben
2005-08-26 16:18 ` Bart Schaefer
0 siblings, 1 reply; 3+ messages in thread
From: Miek Gieben @ 2005-08-26 9:36 UTC (permalink / raw)
To: zsh users
[-- Attachment #1: Type: text/plain, Size: 1044 bytes --]
hello all,
I have my prompt setup in such a way that it will print my previous
cmd in green (when the exitcode was 0) or red (exitcode != 0) on the
right side of my screen. This works really well, expect in some cases.
It seems that sometimes this setup fails, for instance when my
previous cmd had a % in it, this gets re-evaluated and results in
a weird looking prompt. Also when I try to type in a for-loop and I
make a typo which causes the loop to hang, my prompt also hangs.
It there any way to make zsh /not/ to parse my previous cmd but
just show it as is?
Below are the relevant piecies of my prompt setup:
RPSL=$'%{\e[0m%}%{\e[$C;31m%}%(0?.%{\e[$C;32m%}.(%?%)) '
RPSR=$'%{\e[0m%}'
((MAXMID=$COLUMNS / 2)) # truncate to this value
RPSMID=$history[$[${(%):-%h}-1]]
RPS1="$RPSL%$MAXMID<... <$RPSMID$RPSR"
Thanks for any help,
--
grtz,
- Miek
http://www.miek.nl http://www.nlnetlabs.nl
PGP Key ID: 0xB18453A1
fingerprint: 002B B079 0DDA 7D44 2B5C CAB0 C3B7 F943 B184 53A1
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: previous cmd in RPS1
2005-08-26 9:36 previous cmd in RPS1 Miek Gieben
@ 2005-08-26 16:18 ` Bart Schaefer
2005-08-26 16:30 ` Miek Gieben
0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2005-08-26 16:18 UTC (permalink / raw)
To: zsh users
On Aug 26, 11:36am, Miek Gieben wrote:
}
} It there any way to make zsh /not/ to parse my previous cmd but
} just show it as is?
Use the psvar array and the %v prompt replacement.
psvar=( $history[$[${(%):-%h}-1]] )
RPS1="$RPSL%$MAXMID<... <%v$RPSR"
Or -- less good in my opinion -- use promptsubst:
setopt promptsubst
RPSMID=$history[$[${(%):-%h}-1]]
RPS1="$RPSL%$MAXMID<... <"\$RPSMID"$RPSR"
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: previous cmd in RPS1
2005-08-26 16:18 ` Bart Schaefer
@ 2005-08-26 16:30 ` Miek Gieben
0 siblings, 0 replies; 3+ messages in thread
From: Miek Gieben @ 2005-08-26 16:30 UTC (permalink / raw)
To: zsh users
[-- Attachment #1: Type: text/plain, Size: 579 bytes --]
[On 26 Aug, @18:18, Bart Schaefer wrote in "Re: previous cmd in RPS1 ..."]
> On Aug 26, 11:36am, Miek Gieben wrote:
> }
> } It there any way to make zsh /not/ to parse my previous cmd but
> } just show it as is?
>
> Use the psvar array and the %v prompt replacement.
>
> psvar=( $history[$[${(%):-%h}-1]] )
> RPS1="$RPSL%$MAXMID<... <%v$RPSR"
nice! This works. Never heard of psvar, but it seems to do the trick.
(now that I now about psvar, this msg also explains it:
http://www.zsh.org/mla/users/2005/msg00860.html) (also from you :) )
Thanks,
grtz Miek
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-08-26 16:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-26 9:36 previous cmd in RPS1 Miek Gieben
2005-08-26 16:18 ` Bart Schaefer
2005-08-26 16:30 ` Miek Gieben
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).