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

Re: Key bindings not working under screen



* Bart Schaefer (Tue, 15 Feb 2011 07:44:53 -0800)
> On Feb 15, 11:55am, Thorsten Kampe wrote:
> } On systems where JED is not installed (-> DEFAULT_EDITOR=vim) I can 
> } observe this:
> } 
> } % bindkey | wc -l
> } 147
> } % bindkey | grep copy-prev-shell-word
> } "^[-" copy-prev-shell-word
> } % screen
> } % bindkey | wc -l
> } 131
> } % bindkey | grep copy-prev-shell-word
> } %
> } 
> } I've renamed my .screenrc but the issue remains. Interestingly it only 
> } happens when I set $EDITOR *and* $VISUAL in .zshrc, only under screen 
> } and only with zsh (not bash).
> } 
> } Can someone shed some light about the connection between $EDITOR, 
> } $VISUAL, zsh and screen?
> 
> Zsh attempts to initialize the ZLE mode based on VISUAL if it is set
> and EDITOR if it VISUAL is not.  If whichever of those is chosen looks
> like a variant of "vi" then ZLE initializes with vi-style key bindings,
> otherwise it initializes with emacs-style key bindings.
> 
> Probably what's happening is that when you log in, VISUAL and EDITOR
> are not set, and ZLE initializes in emacs mode.

I actually setopt emacs and no_vi in my .zshrc (but before setting 
VISUAL and EDITOR).

> When you then start screen, those variables are in the environment and
> ZLE initializes in vi mode.
> 
> I further suspect that some of your bindkey settings are always ending
> up in the emacs keymap, even when ZLE is in vi mode.  Have you tried
> capturing the bindkey output in a file in each case and diffing them?

"^I" complete-word -> expand-or-complete
"^[-" copy-prev-shell-word -> neg-argument

"^[O5C" forward-word [deleted]
"^[O5D" backward-word [deleted]

"^[Oc" forward-word [deleted]
"^[Od" backward-word [deleted]

"^[[1;5C" forward-word [deleted]
"^[[1;5D" backward-word [deleted]
"^[[1~" beginning-of-line [deleted]
"^[[3~" delete-char [deleted]
"^[[4~" end-of-line [deleted]
"^[[7~" beginning-of-line [deleted]
"^[[8~" end-of-line [deleted]

"^[[A" history-beginning-search-backward -> up-line-or-history
"^[[B" history-beginning-search-forward -> down-line-or-history

"^[[F" end-of-line [deleted]
"^[[H" beginning-of-line [deleted]
"^[[a" up-line-or-beginning-search [deleted]
"^[[b" down-line-or-beginning-search [deleted]

"^[q" push-line-or-edit -> push-line

" " global-alias-space [deleted]
"!"-"~" self-insert -> " "-"~" self-insert

As far as I can see, these are all from my .zshrc (the deleted ones and 
the ones before the "->"):

##
bindkey '^i'      complete-word
bindkey '^[q'     push-line-or-edit
bindkey '^[-'     copy-prev-shell-word
bindkey '\e[3~'   delete-char
bindkey '\e[A'    history-beginning-search-backward
bindkey '\e[B'    history-beginning-search-forward

# xterm/rxvt ("od -c")               # [Ctrl][V]
bindkey '\eOd'    backward-word      # '^[Od'
bindkey '\eOc'    forward-word       # '^[Oc'
bindkey '\e[7~'   beginning-of-line  # '^[[7~'
bindkey '\e[8~'   end-of-line        # '^[[8~'

# Konsole
bindkey '\e[1;5D' backward-word
bindkey '\e[1;5C' forward-word
bindkey '\e[H'    beginning-of-line
bindkey '\e[F'    end-of-line

# GNOME Terminal
bindkey '\eO5D'   backward-word
bindkey '\eO5C'   forward-word

autoload up-line-or-beginning-search \
         down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
bindkey '\e[a'  up-line-or-beginning-search
bindkey '\e[b'  down-line-or-beginning-search

# Cygwin and Linux Console return the same keycode for [Ctrl][Key],
# shifted and unshifted
bindkey '\e[1~' beginning-of-line
bindkey '\e[4~' end-of-line

# Bart Schaefer
autoload -Uz match-words-by-style
global-alias-space()
    { emulate -LR zsh
      match-words-by-style -w shell
      local ga=$matched_words[2]
      if [[ -n $ga ]]; then
          matched_words[2]="${${galiases[$ga]}:-$ga}"
          LBUFFER="${(j::)matched_words[1,3]}"
      fi
      zle .self-insert;}

zle -N global-alias-space
bindkey ' ' global-alias-space

accept-line()
    { emulate -LR zsh
      match-words-by-style -w shell
      local ga=$matched_words[2]
      if [[ -n $ga && ( -n $matched_words[4] || -z $matched_words[5] ) 
]]; then
          matched_words[2]="${${galiases[$ga]}:-$ga}"
          LBUFFER="${(j::)matched_words[1,3]}"
      fi
      zle .accept-line;}

zle -N accept-line
##


Thorsten



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