33847956d9969866dd8b502ffc88af58d2b427fe

Author
Marc Cornellà <marc.cornella@live.com>
Committer
GitHub <noreply@github.com>
Date

Message

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

Diff

 1diff --git a/plugins/colemak/.gitignore b/plugins/colemak/.gitignore
 2new file mode 100644
 3index 0000000000000000000000000000000000000000..8241f5ed6e25491c48737de10a2f288bb096cd47
 4--- /dev/null
 5+++ b/plugins/colemak/.gitignore
 6@@ -0,0 +1 @@
 7+.less
 8diff --git a/plugins/colemak/colemak.plugin.zsh b/plugins/colemak/colemak.plugin.zsh
 9index cb7cc5068647da2a35928da119c8efc5658866de..8d3393c44cda40fc5438cdfcbfc6071ab87fbbcc 100644
10--- a/plugins/colemak/colemak.plugin.zsh
11+++ b/plugins/colemak/colemak.plugin.zsh
12@@ -19,4 +19,15 @@ bindkey -a 'N' vi-join
13 bindkey -a 'j' vi-forward-word-end
14 bindkey -a 'J' vi-forward-blank-word-end
15 
16-lesskey $ZSH/plugins/colemak/colemak-less
17+# New less versions will read this file directly
18+export LESSKEYIN="${0:h:A}/colemak-less"
19+
20+# Only run lesskey if less version is older than v582
21+less_ver=$(less --version | awk '{print $2;exit}')
22+autoload -Uz is-at-least
23+if ! is-at-least 582 $less_ver; then
24+  # Old less versions will read this transformed file
25+  export LESSKEY="${0:h:A}/.less"
26+  lesskey -o "$LESSKEY" "$LESSKEYIN" 2>/dev/null
27+fi
28+unset less_ver