From a3cd5664f1d4e205f22d2ab54c58a68476867a58 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 6 Jan 2017 17:25:57 +1300 Subject: 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. --- ksh/kshrc.d/bind.ksh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 ksh/kshrc.d/bind.ksh (limited to 'ksh') 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 -- cgit v1.2.3 From de6ec20aec4af67f8de5ab94b76f43722c8e655f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 6 Jan 2017 19:35:18 +1300 Subject: Clean binding of ^L in ksh93 to clear screen --- ksh/kshrc.d/bind.ksh | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) (limited to 'ksh') diff --git a/ksh/kshrc.d/bind.ksh b/ksh/kshrc.d/bind.ksh index 22fb53a8..e32b9565 100644 --- a/ksh/kshrc.d/bind.ksh +++ b/ksh/kshrc.d/bind.ksh @@ -6,29 +6,18 @@ case $KSH_VERSION in 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)? + # Works great *'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' - ;; + $'\f') .sh.edchar=$'\e\f' ;; esac } trap bind KEYBD ;; + + # Works pretty well, but only on an empty line + *'PD KSH'*) + bind -m '^L'=clear'^J' + ;; esac -- cgit v1.2.3 From 3ee57042e41a290edaf171cfe53332a0b2034f01 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 6 Jan 2017 19:42:09 +1300 Subject: Found workable ^L bindings in all three kshes --- ksh/kshrc.d/bind.ksh | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'ksh') diff --git a/ksh/kshrc.d/bind.ksh b/ksh/kshrc.d/bind.ksh index e32b9565..af024fb9 100644 --- a/ksh/kshrc.d/bind.ksh +++ b/ksh/kshrc.d/bind.ksh @@ -1,12 +1,6 @@ # Try to bind ^L to clear the screen case $KSH_VERSION in - # Works great - *'MIRBSD KSH'*) - bind ^L=clear-screen - ;; - - # Works great *'93'*) bind() { case ${.sh.edchar} in @@ -16,8 +10,12 @@ case $KSH_VERSION in trap bind KEYBD ;; - # Works pretty well, but only on an empty line + *'MIRBSD KSH'*) + bind ^L=clear-screen + ;; + *'PD KSH'*) - bind -m '^L'=clear'^J' + bind -m '^L'='^U'clear'^J^Y' ;; + esac -- cgit v1.2.3