Adding Ctrl-L as "clear" hotkey in OpenBSD's ksh
Solution 1
According to the OpenBSD ksh man page, Ctrl+L is bound to redraw.
redraw: ^L Reprints the prompt string and the current input line.
If that isn't sufficient, I can't see any editing command that will help, so I would suggest learning more about bind -m
.
Perhaps you can do something like bind -m '^L'=clear'^J'
to make it type clear
Enter.
Solution 2
You should be able to add an alias to your .kshrc to do this. Try
alias "^L"=clear
Where ^L
is the single char Ctrl-L. You might not need the quoting, if it still doesn't work the last resort would be to escape it like (what you are typing, not what will be visible in your file) Ctrl-VCtrl-L→clear.
IHTH
Related videos on Youtube
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Admin
Updated on September 18, 2022Comments
-
Admin almost 2 years
I've been looking for a way to use Ctrl-L to clear the monitor instead of typing
clear
in each time. I found nothing except a patch which didn't work for me. How do I add hotkeys/shortcuts to my OpenBSD box (which uses ksh as a shell)?[*] OpenBSD's ksh.kshrc
[*] Ctrl-l in hex = 0xc :
# read key ; echo -n $key > file.txt ; hexdump file.txt ^L 0000000 000c 0000001 #
-
kjo about 13 yearsThank you shellter but this way works for bash not ksh.
-
Mikel about 13 yearsI have tested
bind -m '^L'=clear'^J'
on OpenBSD 4.9 and it works. -
Wiliam about 13 yearsIt's solved, Mikel & shellter thank you for help.
-
XGouchet about 13 years@Barakat : What isn't working? What is the error message? It works in my ksh environment ;-) (and I'm sure it would have worked where I used Solaris and AIX ksh's). Hmm. re-read your posting and see you're refering to OpenBSD ksh. Sorry I don't have experience with that. Is it possible that it is really pdksh? Good Luck.
-
XGouchet about 13 years@Barakat : One other thing, did you restart your shell after adding alias defintion to .kshrc. Or you could add it to ~/.profile and then start a new shell.