1. Panagiotis Mavrogiorgos
  2. dotfiles

Commits

Panagiotis Mavrogiorgos  committed acd865d

fix bug in zsh when using tty.

  • Participants
  • Parent commits 082303f
  • Branches default

Comments (0)

Files changed (1)

File zsh/key-bindings.zsh

View file
+#!/usr/bin/zsh
 #
 # Key bindings
 #
 typeset -A key
 
 key[Home]=${terminfo[khome]}
-
 key[End]=${terminfo[kend]}
 key[Insert]=${terminfo[kich1]}
 key[Delete]=${terminfo[kdch1]}
 [[ -n "${key[Left]}"    ]]  && bindkey  "${key[Left]}"    backward-char
 [[ -n "${key[Right]}"   ]]  && bindkey  "${key[Right]}"   forward-char
 
-# Finally, make sure the terminal is in application mode, when zle is
+# Make sure the terminal is in application mode, when zle is
 # active. Only then are the values from $terminfo valid.
-
-function zle-line-init () {
-    echoti smkx
-}
-function zle-line-finish () {
-    echoti rmkx
-}
-
-zle -N zle-line-init
-zle -N zle-line-finish
-
+if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
+    function zle-line-init () {
+        printf '%s' ${terminfo[smkx]}
+    }
+    function zle-line-finish () {
+        printf '%s' ${terminfo[rmkx]}
+    }
+    zle -N zle-line-init
+    zle -N zle-line-finish
+else
+    for i in {s,r}mkx; do
+        (( ${+terminfo[$i]} )) || debian_missing_features+=($i)
+    done
+    unset i
+fi
 
 # Search History
 bindkey "^[[A" history-beginning-search-backward