zsh-users
 help / color / mirror / code / Atom feed
* New user questions
@ 2000-03-30  3:14 Andrew Morton
  2000-03-30  5:20 ` Chmouel Boudjnah
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Andrew Morton @ 2000-03-30  3:14 UTC (permalink / raw)
  To: zsh-users

Hi.  I just joined.

For the past 10-15 years I have been using the original AT&T bourne
shell into which I have hacked various interactive editing functions. 
The time has come to dump this thing - the maintenance is too high.

I'd like to use zsh and I must say that I am _very_ impressed by the
quality and professionalism of the website, documentation, mailing list
and software.  Congratulations!

A few little problems I have observed:

1: When I printed zsh_a4.ps on an HP LaserJet 4 the last few columns
were truncated.

2: When I installed zsh-3.1.6dev20-1mdk (Mandrake's RPM) I notice that
'man zshall' produces 11 lines of the form:

<standard input>:291: can't open `man1/zshmisc.1': No such file or
directory
<standard input>:292: can't open `man1/zshexpn.1': No such file or
directory


And a few questions, please.

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.

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


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.

^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).

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?

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

etc

forward-kill-line
-----------------

Is there a widget which deletes from the cursor to the end of line?


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.

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.

Thanks!


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: New user questions
  2000-03-30  3:14 New user questions Andrew Morton
@ 2000-03-30  5:20 ` Chmouel Boudjnah
  2000-03-30  5:27 ` Friedrich Dominicus
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 15+ messages in thread
From: Chmouel Boudjnah @ 2000-03-30  5:20 UTC (permalink / raw)
  To: Andrew Morton; +Cc: zsh-users

"Andrew Morton" <morton@nortelnetworks.com> writes:

> 2: When I installed zsh-3.1.6dev20-1mdk (Mandrake's RPM) I notice that
> 'man zshall' produces 11 lines of the form:
> <standard input>:291: can't open `man1/zshmisc.1': No such file or
> directory
> <standard input>:292: can't open `man1/zshexpn.1': No such file or
> directory

it's a mandrake bug not a zsh bug, i'll fix this the soon as possible.

-- 
MandrakeSoft Inc                http://www.mandrakesoft.com
Pasadena, CA USA                                  --Chmouel


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: New user questions
  2000-03-30  3:14 New user questions Andrew Morton
  2000-03-30  5:20 ` Chmouel Boudjnah
@ 2000-03-30  5:27 ` Friedrich Dominicus
  2000-03-30 11:12   ` Oliver Kiddle
  2000-03-30  6:50 ` Andrej Borsenkow
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 15+ messages in thread
From: Friedrich Dominicus @ 2000-03-30  5:27 UTC (permalink / raw)
  To: zsh-users

Andrew Morton wrote:
> 

many questions. Let's see.
> Hi.  I just joined.
> 
> For the past 10-15 years I have been using the original AT&T bourne
> shell into which I have hacked various interactive editing functions.
> The time has come to dump this thing - the maintenance is too high.

Now you know Shells, so you should first spend some time reading zsh
docs

> 
> Impromptu directory listing
> ---------------------------
> 
> prompt> cd /usr/src/li^R
> linux/                  linux-2.2.9/            linux-2.3.99-pre3/
> linux-akpm/

TAB and following options should do the job
setopt automenu autolist should help too

It's even better than just seeing what is there just type TAB again and
one after the other possible extension is used.

man zshopt

and you should check the compctl or the like for cd it might look like:
compctl -g '*(-/)' cd rmdir

which means that you want after a cd just directories as expansion.
> 
> So typing ^R in a command line produces a diectory listing of matching
> files and allows you to continue typing.
> 
> insert-previous-line
> --------------------
> 
> pwold011:~> /sbin/shutdown
> shutdown: must be root.
> pwold011:~> sudo ^W

sudo !!$

> 
> 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...)
> 
> backward-search-word
> --------------------
> 
> prompt> cp /foo/bar /zot/bop
> prompt> ls /fo^C

CTRL+R  (if you use emacs-bindings)




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

sure use s.th like
setopt pushdtohome pushdminus pushdsilent autopushd


check zshoptions
> 
> 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
> 
> etc

echo !!(number)

in you example
echo !!1 TAB expands to echo echo aaa
> 
> forward-kill-line
> -----------------
> 
> Is there a widget which deletes from the cursor to the end of line?

CTRL+k
or kill-line

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

guess zsh makes this automatically. But don't know
> 
> 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.

ctrl+l


Regards
Friedrich


^ permalink raw reply	[flat|nested] 15+ messages in thread

* RE: New user questions
  2000-03-30  3:14 New user questions Andrew Morton
  2000-03-30  5:20 ` Chmouel Boudjnah
  2000-03-30  5:27 ` Friedrich Dominicus
@ 2000-03-30  6:50 ` Andrej Borsenkow
  2000-03-30 18:22   ` Chmouel Boudjnah
  2000-03-30  6:57 ` Andrej Borsenkow
  2000-03-30 13:27 ` Zefram
  4 siblings, 1 reply; 15+ messages in thread
From: Andrej Borsenkow @ 2000-03-30  6:50 UTC (permalink / raw)
  To: Andrew Morton, zsh-users

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

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

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

-andrej


^ permalink raw reply	[flat|nested] 15+ messages in thread

* RE: New user questions
  2000-03-30  3:14 New user questions Andrew Morton
                   ` (2 preceding siblings ...)
  2000-03-30  6:50 ` Andrej Borsenkow
@ 2000-03-30  6:57 ` Andrej Borsenkow
  2000-03-30 13:27 ` Zefram
  4 siblings, 0 replies; 15+ messages in thread
From: Andrej Borsenkow @ 2000-03-30  6:57 UTC (permalink / raw)
  To: Andrew Morton, zsh-users

And, of course, get a look at

http://www.pwstephenson.fsnet.co.uk/computing/

excellent work - much thanks to Peter.

-andrej


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: New user questions
  2000-03-30  5:27 ` Friedrich Dominicus
@ 2000-03-30 11:12   ` Oliver Kiddle
  0 siblings, 0 replies; 15+ messages in thread
From: Oliver Kiddle @ 2000-03-30 11:12 UTC (permalink / raw)
  To: zsh-users

Friedrich Dominicus wrote:

> > 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.
> 
> guess zsh makes this automatically. But don't know

Zsh's idea of word separators is defined by the WORDCHARS parameter. It
actually defines characters to be considered part of a word as opposed
to separators. You can remove slash from it:

WORDCHARS="${WORDCHARS:s@/@}"

Personally, I only want slash to be considered a word separator for
moving and deleting words backward and forward - not for other things
like copying the last word so I define my own functions for these which
all look something like this:

tcsh-backward-word() {
  local WORDCHARS="${WORDCHARS:s@/@}"
  zle backward-word
}

Then I can do:
zle -N tcsh-backward-word
bindkey "..." tcsh-backword-word

Oliver Kiddle


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: New user questions
  2000-03-30  3:14 New user questions Andrew Morton
                   ` (3 preceding siblings ...)
  2000-03-30  6:57 ` Andrej Borsenkow
@ 2000-03-30 13:27 ` Zefram
  2000-03-31 16:18   ` Bart Schaefer
  4 siblings, 1 reply; 15+ messages in thread
From: Zefram @ 2000-03-30 13:27 UTC (permalink / raw)
  To: Andrew Morton; +Cc: zsh-users

Andrew Morton wrote:
>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.

The widget list-choices does this.  Well, actually it produces a list
of possible completions, which are often context dependent (e.g., with
the new completion mechanism enabled, after "kill -" it'll give a list
of signal names).  If you actually want strictly a file listing, you'll
have to write your own widget.

list-choices is by default bound to ^D in the vi insert mode keymap, ^D
and = in vi command mode, and ESC ^D in Emacs mode.  delete-char-or-list
(^D in Emacs mode) behaves like list-choices when at the end of the 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...)

You'll have to write your own widget if you want to do it that way.
Personally I use history expansion to do this.  "sudo !!" would
interpolate the previous command.  "sudo !!<TAB>" will expand it in
place, while the command is being edited.  With magic-space, "sudo !! "
will implicitly expand it when the trailing space is inserted.

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

_history_complete_word is supposed to do something like this, but I
don't know enough about it.

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

No.  You could temporarily stty it in precmd/preexec, but that has all
sorts of drawbacks.

>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

Again, this is most easily done with history expansion.  In the above,
"!:1" will expand to "aaa", "!:2" to "bbb", and so on; "!$" expands to
the last word on the previous line.

>Is there a widget which deletes from the cursor to the end of line?

kill-line does the Emacs thing (delete up to, but not including, NL,
unless that's nothing, in which case it deletes the NL).  vi-kill-eol
deletes up to, but not including, NL.  Both are bound by default in the
appropriate editing modes.

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

Look at the parameter WORDCHARS.

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

redisplay.

-zefram


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: New user questions
  2000-03-30  6:50 ` Andrej Borsenkow
@ 2000-03-30 18:22   ` Chmouel Boudjnah
  2000-03-31  6:40     ` Andrew Morton
  0 siblings, 1 reply; 15+ messages in thread
From: Chmouel Boudjnah @ 2000-03-30 18:22 UTC (permalink / raw)
  To: Andrej Borsenkow; +Cc: Andrew Morton, zsh-users

"Andrej Borsenkow" <Andrej.Borsenkow@mow.siemens.ru> writes:

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

all documentation is available in the zsh-doc rpm, find it in cooker
distribution :

http://www.linuxmandrake.com/cooker/


-- 
MandrakeSoft Inc                http://www.mandrakesoft.com
Pasadena, CA USA                                  --Chmouel


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: New user questions
  2000-03-30 18:22   ` Chmouel Boudjnah
@ 2000-03-31  6:40     ` Andrew Morton
  2000-03-31  7:45       ` Andrej Borsenkow
  2000-04-01 17:13       ` Zefram
  0 siblings, 2 replies; 15+ messages in thread
From: Andrew Morton @ 2000-03-31  6:40 UTC (permalink / raw)
  To: zsh-users

Well thanks everyone for all the help.  Just about everything is working
sweetly (better than the old shell, actually).

Trolling through the magic commands in
/usr/share/zsh/3.1.6-dev-20/functions/Commands/ helped a lot.

A few more observations:

- The zshbuiltins manpage doesn't cover 'bindkey'

- History-search-backward could be improved.  In this example it is
bound to ESC:

prompt> echo foo
prompt> echo bar
prompt> echo f<ESC>

This will then match 'echo bar'.  Would be more sensible to match 'echo
foo'?

- The _history-complete-older function does exactly what I wanted for
searching back through word history!

- _history-complete-older has a bug.  In this example it is bound to ^R:

prompt> echo aa "bb" cc
prompt> echo ^R			# OK, gives echo cc
prompt> echo ^R^R               # oops.  gives echo aa

It is skipping quoted words in its search.

- delete-char-or-list will list the matching files if at end-of-line. 
Marvellous.


Question: How do I, within .zshrc, simply erase _all_ preexisting
bindings and start afresh?  I've tried everything.

pwold011:/home/morton> bindkey -l
.safe
emacs
main
vicmd
viins
pwold011:/home/morton> bindkey -D emacs vicmd viins
pwold011:/home/morton> bindkey -l
.safe
main
pwold011:/home/morton> bindkey -D main
No such keymap `main'


^ permalink raw reply	[flat|nested] 15+ messages in thread

* RE: New user questions
  2000-03-31  6:40     ` Andrew Morton
@ 2000-03-31  7:45       ` Andrej Borsenkow
  2000-03-31 10:33         ` Andrew Morton
  2000-04-01 17:13       ` Zefram
  1 sibling, 1 reply; 15+ messages in thread
From: Andrej Borsenkow @ 2000-03-31  7:45 UTC (permalink / raw)
  To: Andrew Morton, zsh-users

>
> Well thanks everyone for all the help.  Just about everything
> is working
> sweetly (better than the old shell, actually).
>

Have you had any doubts? :-)

> A few more observations:
>
> - The zshbuiltins manpage doesn't cover 'bindkey'
>

This is in modules section (Zle module). But, yes, I never liked this.
Users are not supposed to know, if command is implemented in core or
module.

man zshmodules

> - History-search-backward could be improved.  In this example it is
> bound to ESC:
>
> prompt> echo foo
> prompt> echo bar
> prompt> echo f<ESC>
>
> This will then match 'echo bar'.  Would be more sensible to
> match 'echo
> foo'?
>

There is history-beginning-search-(backward|forward) that should do that

history-beginning-search-backward
     Search backward in the history for a line beginning with the
     current line up to the cursor.  This leaves the cursor in its
     original position.

>
> Question: How do I, within .zshrc, simply erase _all_ preexisting
> bindings and start afresh?  I've tried everything.
>
> pwold011:/home/morton> bindkey -l
> .safe
> emacs
> main
> vicmd
> viins
> pwold011:/home/morton> bindkey -D emacs vicmd viins
> pwold011:/home/morton> bindkey -l
> .safe
> main
> pwold011:/home/morton> bindkey -D main
> No such keymap `main'
>


bor@itsrm2% bindkey -N foo .safe
bor@itsrm2% bindkey -A foo main
bor@itsrm2% bindkey -L
bindkey -R "^@"-"^I" self-insert
bindkey "^J" accept-line
bindkey -R "^K"-"^L" self-insert
bindkey "^M" accept-line
bindkey -R "^N"-"\M-^?" self-insert

These are the minimum - you want to be able to at least enter
characters. If you simply create an *empty* map and assign it to main -
no input will be possible at all.

-andrej


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: New user questions
  2000-03-31  7:45       ` Andrej Borsenkow
@ 2000-03-31 10:33         ` Andrew Morton
  0 siblings, 0 replies; 15+ messages in thread
From: Andrew Morton @ 2000-03-31 10:33 UTC (permalink / raw)
  To: Andrej Borsenkow; +Cc: zsh-users

Andrej Borsenkow wrote:
> 
> >
> > Well thanks everyone for all the help.  Just about everything
> > is working
> > sweetly (better than the old shell, actually).
> >
> 
> Have you had any doubts? :-)

I'm learning not to!

> ...
> There is history-beginning-search-(backward|forward) that should do that

Perfect.

> ...
> bor@itsrm2% bindkey -N foo .safe
> bor@itsrm2% bindkey -A foo main
> bor@itsrm2% bindkey -L
> bindkey -R "^@"-"^I" self-insert
> bindkey "^J" accept-line
> bindkey -R "^K"-"^L" self-insert
> bindkey "^M" accept-line
> bindkey -R "^N"-"\M-^?" self-insert

<smites forehead>  That simple?

BTW, I was fiddling with 'bindkey -R' but I was using things like

	bindkey -R "^A-^Z"

An example in the manual would be nice.

BTW2: The printed manual does not describe the zsh license.  This is
unusual.

Thanks again for all the help.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: New user questions
  2000-03-30 13:27 ` Zefram
@ 2000-03-31 16:18   ` Bart Schaefer
  0 siblings, 0 replies; 15+ messages in thread
From: Bart Schaefer @ 2000-03-31 16:18 UTC (permalink / raw)
  To: Andrew Morton, zsh-users

On Mar 30,  3:14am, Andrew Morton wrote:
} Subject: New user questions
}
} 1: When I printed zsh_a4.ps on an HP LaserJet 4 the last few columns
} were truncated.

Silly question, but ... were you actually printing on size A4 paper?

I'm jumping into the rest of this a bit late, but ...
 
} 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...)

Assuming that you have:
	bindkey "^N" down-line-or-history
	bindkey "^P" up-line-or-history
	bindkey "^U" kill-whole-line
	bindkey "^Y" yank

Then:
	bindkey -s "^W" "^P^U^Y^N^Y"

No need to write a widget for something as simple as this.  The only
tricky bit is the extra ^Y in the middle, needed to "leave the history
as you found it" for other editing commands later.

It's possible that you meant "insert the previous history line at the
cursor" ... that really does require a widget, because zsh loses the
cursor and mark positions when moving up and down through the history.

} ^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).

Check out the STTY parameter.

	stty intr '^G'		# Change interrupt character for zsh
	ttyctl -f		# Freeze settings, just in case
	export STTY='intr ^C'	# Restore interrupt for external commands
 
} 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?

The pushd/popd commands used to work this way (I still have a local hack
to enable it via setopt).  There's an example in the FAQ document that
shows how to do it with shell functions.

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

In addition to WORDCHARS (which others have pointed out), you might try
using the vi-* word motion widgets instead of the emacs ones.

One additional comment:

On Mar 30,  7:27am, Friedrich Dominicus wrote:
} Subject: Re: New user questions
}
} > insert-previous-line
} > --------------------
} > 
} > pwold011:~> /sbin/shutdown
} > shutdown: must be root.
} > pwold011:~> sudo ^W
} 
} sudo !!$

Get that `$' out of there.  Just `sudo !!' does it.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: New user questions
  2000-03-31  6:40     ` Andrew Morton
  2000-03-31  7:45       ` Andrej Borsenkow
@ 2000-04-01 17:13       ` Zefram
  1 sibling, 0 replies; 15+ messages in thread
From: Zefram @ 2000-04-01 17:13 UTC (permalink / raw)
  To: Andrew Morton; +Cc: zsh-users

Andrew Morton wrote:
>pwold011:/home/morton> bindkey -D main
>No such keymap `main'

"bindkey -D main" *does* succeed.  The error message is from ZLE,
starting up to edit the next command line, noticing that it can't select
the keymap.  Its behaviour is to fall back on the .safe keymap (see the
"KEYMAPS" section of zshzle(1)).

You almost certainly don't want to delete keymap main.  To create a
completely new keymap, create one with "bindkey -N", giving it a new name,
then you can add to it as much as you want while it's not selected.
*Then* use "bindkey -A" to make "main" a link to your new keymap.
(And presuming that you want to save the keymap permanently, use "bindkey
-L" to dump the keymap in the form of the commands needed to poulate it.)

-zefram


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: New user questions
  2000-03-31  7:42 Sven Wischnowsky
@ 2000-03-31 10:42 ` Andrew Morton
  0 siblings, 0 replies; 15+ messages in thread
From: Andrew Morton @ 2000-03-31 10:42 UTC (permalink / raw)
  To: Sven Wischnowsky; +Cc: zsh-users

Hi, Sven.

Sven Wischnowsky wrote:
> 
> ...
>
> Besides... do you *really* want to remove all keymaps and begin from
> scratch? Why? You would have to add all those self-insert bindings,
> the cursor movement, etc etc etc. Rather tedious.

Well, my bindings are different from anyone else's!  (Back in '86 I
wrote a text editor which mimiced MicroPro WordStar.  I still use it,
evolve it.  To keep myself sane I like the shell's commands to be the
same as the editor's).

I wanted to clean all the emacs bindings out because I have a single-key
^X command.  The presence of the double-key emacs ^X commands is causing
the single-key ^X to delay 400 mSecs.

Andrei's suggestion worked well.  But I had to put half the emacs
bindings back in to get the arrow keys and things back.  Oh well.

Sorry to hassle you guys so much, but it's good to get it set up just
right.  I expect I'll spend the next 12 years using this shell :-)


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: New user questions
@ 2000-03-31  7:42 Sven Wischnowsky
  2000-03-31 10:42 ` Andrew Morton
  0 siblings, 1 reply; 15+ messages in thread
From: Sven Wischnowsky @ 2000-03-31  7:42 UTC (permalink / raw)
  To: zsh-users


Andrew Morton wrote:

> Well thanks everyone for all the help.  Just about everything is working
> sweetly (better than the old shell, actually).
> 
> Trolling through the magic commands in
> /usr/share/zsh/3.1.6-dev-20/functions/Commands/ helped a lot.
> 
> A few more observations:
> 
> - The zshbuiltins manpage doesn't cover 'bindkey'

Because it's not defined by the shell core, but by the zle module. See 
zshzle(1).

> ...
> 
> - The _history-complete-older function does exactly what I wanted for
> searching back through word history!
> 
> - _history-complete-older has a bug.  In this example it is bound to ^R:
> 
> prompt> echo aa "bb" cc
> prompt> echo ^R			# OK, gives echo cc
> prompt> echo ^R^R               # oops.  gives echo aa
> 
> It is skipping quoted words in its search.

It's not a bug, it's intentional: it explicitly excludes words
starting with any of [$'"]. That was the behaviour shown by the
compctl option for history completion, but now that we have
ignored-patterns it indeed doesn't seem to make sense any more.

> ...
> 
> Question: How do I, within .zshrc, simply erase _all_ preexisting
> bindings and start afresh?  I've tried everything.
> 
> pwold011:/home/morton> bindkey -l
> .safe
> emacs
> main
> vicmd
> viins
> pwold011:/home/morton> bindkey -D emacs vicmd viins
> pwold011:/home/morton> bindkey -l
> .safe
> main
> pwold011:/home/morton> bindkey -D main
> No such keymap `main'

`main' is (internally) really only an alias or some kind of pointer to 
the keymap currently used. Keymap handling (or zle/widget stuff in
general) is one of the things we might have a look at after 3.2/4.0 is 
out. I think.

Besides... do you *really* want to remove all keymaps and begin from
scratch? Why? You would have to add all those self-insert bindings,
the cursor movement, etc etc etc. Rather tedious.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2000-04-01 17:13 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-03-30  3:14 New user questions Andrew Morton
2000-03-30  5:20 ` Chmouel Boudjnah
2000-03-30  5:27 ` Friedrich Dominicus
2000-03-30 11:12   ` Oliver Kiddle
2000-03-30  6:50 ` Andrej Borsenkow
2000-03-30 18:22   ` Chmouel Boudjnah
2000-03-31  6:40     ` Andrew Morton
2000-03-31  7:45       ` Andrej Borsenkow
2000-03-31 10:33         ` Andrew Morton
2000-04-01 17:13       ` Zefram
2000-03-30  6:57 ` Andrej Borsenkow
2000-03-30 13:27 ` Zefram
2000-03-31 16:18   ` Bart Schaefer
2000-03-31  7:42 Sven Wischnowsky
2000-03-31 10:42 ` Andrew Morton

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