Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Jumping to the line above
- X-seq: zsh-users 7650
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-users@xxxxxxxxxx (Zsh users list)
- Subject: Re: Jumping to the line above
- Date: Thu, 01 Jul 2004 13:14:42 +0100
- In-reply-to: "Peter Stephenson"'s message of "Thu, 01 Jul 2004 12:32:08 BST." <200407011132.i61BW9Ss012116@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
Peter Stephenson wrote:
> > [Some previous output]
> > ~/bin/foo/bar $
> >
> > After typing (for example) ^U twice:
> >
> > [Some previous output]
> > ~/bin $
>
> I think what you *really* want is a way of re-expanding the current
> prompt.
This may be oversimple (in particular, I have no idea what to do about
pmpt_attr and rpmpt_attr) ... Further followups on that should go
to zsh-workers.
After the patch, you can do stuff like
PS1="%~%# "
zle-pushd() {
emulate -L zsh
setopt pushdsilent
# Use the numeric argument to get a new directory.
# Make sure we get an argument in the +/- from expected by pushd.
local numeric=${NUMERIC:-+1}
[[ $numeric = [-+]* ]] || numeric="+$numeric"
pushd $numeric
zle reset-prompt
}
zle -N zle-pushd
bindkey '^x^p' zle-pushd
Index: Doc/Zsh/zle.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/zle.yo,v
retrieving revision 1.35
diff -u -r1.35 zle.yo
--- Doc/Zsh/zle.yo 22 Jun 2004 07:02:50 -0000 1.35
+++ Doc/Zsh/zle.yo 1 Jul 2004 12:03:19 -0000
@@ -1737,6 +1737,15 @@
item(tt(redisplay) (unbound) (^R) (^R))(
Redisplays the edit buffer.
)
+tindex(reset-prompt)
+item(tt(reset-prompt) (unbound) (unbound) (unbound))(
+Force the prompts on both the left and right of the screen to be
+re-expanded, then redisplay the edit buffer. Note that this
+does not reflect changes to the prompt variables themselves, only changes
+in the expansion of the values (for example, changes in time or
+directory, or changes to the value of variables referred to by the
+prompt).
+)
tindex(send-break)
item(tt(send-break) (^G ESC-^G) (unbound) (unbound))(
Abort the current editor function, e.g. tt(execute-named-command), or the
Index: Src/Zle/iwidgets.list
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/iwidgets.list,v
retrieving revision 1.5
diff -u -r1.5 iwidgets.list
--- Src/Zle/iwidgets.list 20 Feb 2004 15:27:53 -0000 1.5
+++ Src/Zle/iwidgets.list 1 Jul 2004 12:03:19 -0000
@@ -88,6 +88,7 @@
"recursive-edit", recursiveedit, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL
"redisplay", redisplay, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL
"redo", redo, ZLE_KEEPSUFFIX
+"reset-prompt", resetprompt, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL
"reverse-menu-complete", reversemenucomplete, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_ISCOMP
"run-help", processcmd, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL
"self-insert", selfinsert, ZLE_MENUCMP | ZLE_KEEPSUFFIX
Index: Src/Zle/zle_main.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v
retrieving revision 1.45
diff -u -r1.45 zle_main.c
--- Src/Zle/zle_main.c 2 Jun 2004 22:15:01 -0000 1.45
+++ Src/Zle/zle_main.c 1 Jul 2004 12:03:20 -0000
@@ -150,6 +150,8 @@
/**/
mod_export char *zlenoargs[1] = { NULL };
+static char *raw_lp, *raw_rp;
+
#ifdef FIONREAD
static int delayzsetterm;
#endif
@@ -785,8 +787,10 @@
insmode = unset(OVERSTRIKE);
eofsent = 0;
resetneeded = 0;
+ raw_lp = lp;
lpromptbuf = promptexpand(lp, 1, NULL, NULL);
pmpt_attr = txtchange;
+ raw_rp = rp;
rpromptbuf = promptexpand(rp, 1, NULL, NULL);
rpmpt_attr = txtchange;
free_prepostdisplay();
@@ -1307,6 +1311,18 @@
}
/**/
+int
+resetprompt(UNUSED(char **args))
+{
+ free(lpromptbuf);
+ lpromptbuf = promptexpand(raw_lp, 1, NULL, NULL);
+ free(rpromptbuf);
+ rpromptbuf = promptexpand(raw_rp, 1, NULL, NULL);
+
+ return redisplay(NULL);
+}
+
+/**/
mod_export void
trashzle(void)
{
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.
www.mimesweeper.com
**********************************************************************
Messages sorted by:
Reverse Date,
Date,
Thread,
Author