zsh-workers
 help / color / mirror / code / Atom feed
* Strange behaviour of setopt and binkey in a widget
@ 2010-04-19  7:29 Mike Perdide
  0 siblings, 0 replies; only message in thread
From: Mike Perdide @ 2010-04-19  7:29 UTC (permalink / raw)
  To: zsh-workers

Hello,

I'm trying to customize the behaviour of CTRL-D in certain conditions
and I 'm observing strange behaviours from zsh.
Here is what I do :

-------------- From my .zshrc
--------------------------------------------------------------
widg0() { echo "not really exiting"; }
zle -N widg0
widg1() { setopt ignoreeof; bindkey "^D" widg0; }
widg2() { unsetopt ignoreeof; bindkey -r "^D"; }
zle -N widg1
zle -N widg2
bindkey "^O" widg1
bindkey "^P" widg2

-------------- Starting from a bash shell :
--------------------------------------------
[22:49] :~$ zsh
north.~% <CTRL-O> <CTRL-D>
zsh: use 'exit' to exit.
north.~% <CTRL-D>not really exiting
          !!! First strange behaviour : the prompt is not redrawn. At
this point I press <ENTER> to get my prompt back :
north.~% <CTRL-P> <CTRL-D>
!!! The previous ligne is rewritten with these two :
[22:53] :~$
zsh: use 'exit' to exit

-----------------------------------------------------------------------------------------------

The long story behind the ^D rebinding is that I'm using
virtualenvwrapper, that is a wrapper
around virtualenv, a tool designed to build virtual environments using
python. This wrapper
activates virtual environments by making directories and setting env
variables to these
directories (such as PATH). When a environment is activated, the only
way to deactivate it is
 to enter "deactivate". Typing ctrl-d will exit the shell you're in,
and I think that's not a nice
behaviour. What I'm trying to do is to rebind ctrl-d so when it is
used in a virtual environment,
 this environment would be deactivated but the shell wouldn't exit.

Am I doing something wrong ? Is the "strange" behaviour I'm observing
a feature I'm not using correctly ?
Thanks in advance.

Regards,

Mike Perdide.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-04-19  7:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-19  7:29 Strange behaviour of setopt and binkey in a widget Mike Perdide

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