Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
# 
share|improve this question
add comment

2 Answers 2

up vote 4 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. –  BSH Apr 5 '11 at 8:05
add comment

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
1  
Thank you shellter but this way works for bash not ksh. –  BSH 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
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.