zsh-users
 help / color / mirror / code / Atom feed
* Can't use bindkey -c
@ 1997-03-22 19:40 Steve Talley
  1997-03-24  8:19 ` Peter Stephenson
  1997-03-24 18:42 ` Zefram
  0 siblings, 2 replies; 3+ messages in thread
From: Steve Talley @ 1997-03-22 19:40 UTC (permalink / raw)
  To: zsh-users

I'm converting from tcsh to zsh, and have question:

Does zsh's "bindkey" allow the same functionality as tcsh's "bindkey
-c"?  This allows a keystroke to be bound to a builtin or external
command instead of an editor command.  This is useful when I'd like to
run a command and see it's output without having to destroy the
contents of the command-line buffer.

Example:

bindkey -c "^P" pwd

% vi /tmp/blah         <-- Type "^P" here
/usr/bin               <-- shell prints wd
% vi /tmp/blah         <-- I can continue typing here

If there's any way to do this in zsh, please let me know.

Thanks,

Steve

~~
stephen.talley@Central.Sun.COM


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

* Re: Can't use bindkey -c
  1997-03-22 19:40 Can't use bindkey -c Steve Talley
@ 1997-03-24  8:19 ` Peter Stephenson
  1997-03-24 18:42 ` Zefram
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 1997-03-24  8:19 UTC (permalink / raw)
  To: Steve Talley, Zsh users list

Steve Talley wrote:
> Does zsh's "bindkey" allow the same functionality as tcsh's "bindkey
> -c"?  This allows a keystroke to be bound to a builtin or external
> command instead of an editor command.  This is useful when I'd like to
> run a command and see it's output without having to destroy the
> contents of the command-line buffer.
> 
> Example:
> 
> bindkey -c "^P" pwd

Currently the way to do this is:

bindkey -s "^P" "^qpwd\n"

in which the ^q saves the line on the buffer stack, which is restored
after "pwd\n" is executed as input (this assumes emacs bindings; it's
actually a little better to have push-input bound to something and use
that instead of the ^q).

Maybe other ways will be forthcoming.

-- 
Peter Stephenson <pws@ifh.de>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77413
Deutsches Elektronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.


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

* Re: Can't use bindkey -c
  1997-03-22 19:40 Can't use bindkey -c Steve Talley
  1997-03-24  8:19 ` Peter Stephenson
@ 1997-03-24 18:42 ` Zefram
  1 sibling, 0 replies; 3+ messages in thread
From: Zefram @ 1997-03-24 18:42 UTC (permalink / raw)
  To: Steve Talley; +Cc: zsh-users

Steve Talley wrote:
>Does zsh's "bindkey" allow the same functionality as tcsh's "bindkey
>-c"?  This allows a keystroke to be bound to a builtin or external
>command instead of an editor command.  This is useful when I'd like to
>run a command and see it's output without having to destroy the
>contents of the command-line buffer.

Apart from the method that Peter has posted, if you have version 3.1.1
and have applied the patches that have been posted recently, the following
can be done:

bindkey "^P" run-pwd
zle -N run-pwd
function run-pwd {
  echo
  pwd
  zle redisplay
}

Presumably that patch will be in 3.1.2.  In a later version, there will
be a slightly more general solution, probably looking something like:

zle -N run-command
function run-command {
  zle trash-zle
  eval "$STACK"
  zle -s
}
bindkey -x "^P" run-command pwd

-zefram


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

end of thread, other threads:[~1997-03-25 23:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-03-22 19:40 Can't use bindkey -c Steve Talley
1997-03-24  8:19 ` Peter Stephenson
1997-03-24 18:42 ` Zefram

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