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

RE: New user questions

> I am trying to emulate some functions of which I have become very fond
> and there are just a few which for I have not been able to
> find the zsh
> equivalents:
> Impromptu directory listing
> ---------------------------
> prompt> cd /usr/src/li^R
> linux/                  linux-2.2.9/            linux-2.3.99-pre3/
> linux-akpm/
> So typing ^R in a command line produces a diectory listing of matching
> files and allows you to continue typing.

By default, ^D _at_the_end_of_line_ does the same. Beware about

- this is true for emacs style editing (that is default unless you
happen to have EDITOR=vi or like). You can explicitly set emacs style
with `bindkey -e'. Dunno what is in vi style - did not use for a long

- with emacs editing, ^D in the middle of line deletes current

Actually, ^D does much more. It tries to complete current word - and
completion in Zsh does much more than simply listing directories and/or
files. Two examples:

bor@itsrm2% cd z^D
Completing directories in cdpath
zsh-3.1.6-dev-19/  zsh-3.1.6-dev-20/

bor@itsrm2% l /u/i/s^D
Completing file
sac.h          scnhdr.h       search.h       setjmp.h       sgtty.h
shadow.h       siginfo.h      signal.h       stand.h        std.h
stdarg.h       stddef.h       stdio.h        stdlib.h       stdvar_dcl.h
storclass.h    string.h       strings.h      stropts.h      sum.h
sym.h          symconst.h     syms.h         sys/           syslog.h

that lists contents of /usr/include/ ...

and, of course, Zsh can complete command options, parameters, Zsh
options etc etc etc

> insert-previous-line
> --------------------
> pwold011:~> /sbin/shutdown
> shutdown: must be root.
> pwold011:~> sudo ^W
> Here, typing ^W will insert _all_ of the previous line at the prompt.
> (I'd expected get-line to do this, but it just beeps...)

No, get-line actually gets line you pushed previously. You can use
csh-style history substitution (intriduced with !); in current Zsh it
should be fairly easy to write custom widget to do the above and bind it
to any keystroke. I actually simply do ^P^Asudo :-)

> backward-search-word
> --------------------
> prompt> cp /foo/bar /zot/bop
> prompt> ls /fo^C
> Here, ^C will search back through the word history and insert
> '/foo/bar'.  If I immediately hit ^C again, it will rub out
> the 'o/bar'
> and search further back in history, so one can just keep hitting ^C.

I believe, _history_complete_word does something similar .. but I do not
use it, and you may need to tweak styles to get exactly the above
effect. I could not get it to insert next match. Peter?

> ^C
> --
> This normally generates interrupt.  Is there a way of making it
> available to the interactive editor without globally sttying it? (The
> shell would need to restore the intr char when it leaves
> editing mode).

there are precmd and preexec functions. precmd is executed before prompt
is output (BTW I'd like to know, if it applies only to PS1?)  and
preexec before command gets executed. So, you may try to disable and
rebind ^C in precmd and restore in preexec ... never tried it ... why
would you need it at all? I bet, you will get zsh hung in line editor
every now and then :-)

> Bidirectional directory history
> -------------------------------
> I'd like to be able to 'cd' back to somewhere where I used to be.  I
> have this set up nicely using popd.  But once I've gone back a few
> levels with multiple popd's I would like to go forward again.  A ring,
> rather than a stack.
> Possible?

cd +|-N

bor@itsrm2% setopt autopushd
bor@itsrm2% cd
bor@itsrm2% cd tmp
bor@itsrm2% cd test
bor@itsrm2% cd ./embperl
bor@itsrm2% dirs
~/test/embperl ~/test ~/tmp ~ ~/test/embperl
bor@itsrm2% cd -3
bor@itsrm2% dirs
~/test ~/test/embperl ~/tmp ~ ~/test/embperl
bor@itsrm2% cd +2
bor@itsrm2% dirs
~/tmp ~/test ~/test/embperl ~ ~/test/embperl

and Zsh comes with completion for cd so you do not need to remember
stack every time. But I agree, this changes position of stack entries

> insert-previous-word
> --------------------
> The insert-last-word widget will insert the last word of the previous
> line.  Hitting it again inserts the last word of the line before that.
> I would like to do something similar, but have it walk back
> through all
> the previous words, not just the final ones on each line:
> prompt> echo aaa bbb ccc ddd
> prompt> echo ^O        # Expands to echo ddd
> prompt> echo ^O^O      # Expands to echo ccc

Here again - csh-style history substitution. I do not like it because it
makes ! special.

> etc
> forward-kill-line
> -----------------
> Is there a widget which deletes from the cursor to the end of line?

^K in emacs? ESCd$ in vi?

> Changing separators
> -------------------
> All the editor commands define a word separator as a space.
> Is there a
> way of changing zsh's idea of word separators?  I would prefer that it
> consider '/' to be a separator as well.

I think, it was discussed once but am not sure what the results are.

> redraw
> ------
> If asynchronous output mucks up the editor output, how to redraw it?
> 'clear-screen' will do the job, but I'd prefer it not clear
> the screen.

There is `redisplay' widget; it is unbound by default in emacs and biund
to ^R in vi ... have you tried it?

> Thanks!

I wonder, Mandrake should have info for Zsh? Most you questions are
covered there :-)


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