Reputation: 386
How can i replicate the following bash functionality in KornShell:
bind "\C-l":"clear-screen"
I needed that bind
because i'm using set -o vi
in bash, and
plan on using it in ksh too.
Trying to use it in ksh prints out an error:
ksh: bind: not found
Upvotes: 1
Views: 754
Reputation: 7098
Sorry to break the news, but as you've noticed this a different between ksh and bash: bind or the ability to define key mappings is not there. Nor is programmable command completion. Historically the Korn shell focused on language design and features and not on interactive terminal capabilities.
GNU bash provides key bindings via the GNU Readline library which was developed and maintained by the same person, Chet Ramey. ksh
even in its most recent versions doesn't use this library nor does it provide an equivalant library, as far as I know.
A workaround is to see if you can program the terminal to provide such capabilities. In tmux if you put this in your .tmux.conf
configuration file:
bind-key C-l send-keys clear
Then tmux will interpret the Control-l before ksh
has a chance to see it and will expand with the string "clear". (Underneath I bet tmux is using the GNU Readline library)
The POSIX standard (which ksh and bash both follow) defines an "alias" command. However an alias name isn't defined to allow control characters. A particular implemenation may do that, but ksh doesn't.
Upvotes: 1