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

Re: Return to the prompt



Oliver Kiddle wrote:
> Philippe Troin wrote:
> > listdir() { ls -l; zle redisplay }
> 
> Problem with that is the beginning of the ls listing can get a little
> mixed up with what is currently on the command line.
> 
> I would use:
>   bindkey -s '^V' $'\eqls -l\n'
> 
> Note that that relies on my also having:
>   bindkey '^[q' push-input
> 
> Oliver

The following widget seems to give a reasonable combination of features.
The difference between zle -R and zle redisplay isn't that obvious.  You use
zle -R to make editing changes visible, and zle redisplay when it's
necessary to reshow everything completely.

listdir() {
  zle push-input		# Save the input for later
  zle -R			# Show new line with no input
  print				# Clear the line with the prompt
  ls -l				# Show the listing
  zle redisplay			# Redisplay the entire line
  zle get-line			# Get back the input
}

(It doesn't seem to beep if there's no input to push and get back, but I
have so many guards to stop the damn thing beeping that I can't be
sure.  If it does, extra protection of the form (( ${#BUFFER} )) is
necessary.)

-- 
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