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

Can one remap Ctrl-l in bash to execute more than just clear?

I know normally it just clears the screen. I'm looking to change that to clear the screen and list my pwd like so:


share|improve this question
up vote 10 down vote accepted

The bind command defines new key bindings. With the -x parameter, you can assign a shell snippet to a key. The quoting is a bit strange: the key must be quoted for the readline key parser, and the binding description must be quoted because it contains several shell special characters.

bind -x '"\C-l": clear; ls'
share|improve this answer
Thank you. Is this command available in osx? Would you know by some chance? – chrisjlee Jan 16 '12 at 21:28
@ChrisJ.Lee Yes, it's a bash built-in, it's available anywhere you're running bash. – Gilles Jan 16 '12 at 21:29
Ah thanks. I thought the mac port may have some differences in commands. I guess that's just a misunderstanding on my part. – chrisjlee Jan 16 '12 at 21:30

Your Answer


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.