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
0000000 000c                                   

2 Answers 2


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.

  • I have tested bind -m '^L'=clear'^J' on OpenBSD 4.9 and it works.
    – Mikel
    Apr 5, 2011 at 7:50
  • It's solved, Mikel & shellter thank you for help.
    – user6291
    Apr 5, 2011 at 8:05

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.


  • 1
    Thank you shellter but this way works for bash not ksh.
    – user6291
    Apr 5, 2011 at 4:43
  • @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.
    – shellter
    Apr 6, 2011 at 13:35
  • @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.
    – shellter
    Apr 6, 2011 at 21:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy