Browse Source

fix(colemak): remove `lesskey` usage in less v582 and newer (#10102)

Marc Cornellà 2 years ago
parent
commit
33847956d9
2 changed files with 13 additions and 1 deletions
  1. 1 0
      plugins/colemak/.gitignore
  2. 12 1
      plugins/colemak/colemak.plugin.zsh

+ 1 - 0
plugins/colemak/.gitignore

@@ -0,0 +1 @@
+.less

+ 12 - 1
plugins/colemak/colemak.plugin.zsh

@@ -19,4 +19,15 @@ bindkey -a 'N' vi-join
 bindkey -a 'j' vi-forward-word-end
 bindkey -a 'J' vi-forward-blank-word-end
 
-lesskey $ZSH/plugins/colemak/colemak-less
+# New less versions will read this file directly
+export LESSKEYIN="${0:h:A}/colemak-less"
+
+# Only run lesskey if less version is older than v582
+less_ver=$(less --version | awk '{print $2;exit}')
+autoload -Uz is-at-least
+if ! is-at-least 582 $less_ver; then
+  # Old less versions will read this transformed file
+  export LESSKEY="${0:h:A}/.less"
+  lesskey -o "$LESSKEY" "$LESSKEYIN" 2>/dev/null
+fi
+unset less_ver