Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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                                   
share|improve this question
up vote 5 down vote accepted

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.

share|improve this answer
I have tested bind -m '^L'=clear'^J' on OpenBSD 4.9 and it works. – Mikel Apr 5 '11 at 7:50
It's solved, Mikel & shellter thank you for help. – user6291 Apr 5 '11 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.

I hope this helps.

P.S. as you appear to be a new user, if you get an answer that helps you please remember to mark it as accepted, and/or give it a + (or -) as a useful answer.

share|improve this answer
Thank you shellter but this way works for bash not ksh. – user6291 Apr 5 '11 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 '11 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 '11 at 21:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.