aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-01-06 17:25:57 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-01-06 17:25:57 +1300
commita3cd5664f1d4e205f22d2ab54c58a68476867a58 (patch)
treea72be168b0383be45acdc6e3ffec9124c18fcf87
parentAdd "trackall" option to ksh (diff)
downloaddotfiles-a3cd5664f1d4e205f22d2ab54c58a68476867a58.tar.gz
dotfiles-a3cd5664f1d4e205f22d2ab54c58a68476867a58.zip
Experimental/not-very-good-yet ksh bindings
Just starting with what I know and seeing if I can make ^L work the same way it does in Bash. Once I understand this a bit better I intend to have a crack at writing some dynamic completion for ksh93.
-rw-r--r--ksh/kshrc.d/bind.ksh34
1 files changed, 34 insertions, 0 deletions
diff --git a/ksh/kshrc.d/bind.ksh b/ksh/kshrc.d/bind.ksh
new file mode 100644
index 00000000..22fb53a8
--- /dev/null
+++ b/ksh/kshrc.d/bind.ksh
@@ -0,0 +1,34 @@
+# Try to bind ^L to clear the screen
+case $KSH_VERSION in
+
+ # Works great
+ *'MIRBSD KSH'*)
+ bind ^L=clear-screen
+ ;;
+
+ # Works pretty well, but only on an empty line
+ *'PD KSH'*)
+ bind -m '^L'=clear'^J'
+ ;;
+
+ # Not great; only works on an empty line, and skips a line after clearing;
+ # need a better way to redraw the prompt after clearing, or some suitable
+ # way to fake it with tput (can I clear-but-one)?
+ *'93'*)
+
+ # Bind function to run on each KEYBD trap
+ bind() {
+ case ${.sh.edchar} in
+ $'\x0c') # ^L
+
+ # Write a sequence to clear the screen
+ tput clear
+
+ # Change key to Enter to redraw the prompt
+ .sh.edchar=$'\x0d'
+ ;;
+ esac
+ }
+ trap bind KEYBD
+ ;;
+esac