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 want to create a bind that executes g++ !$ in the same way that the shell would interpret it if I just typed it.

I tried:

  • bind '"\ee": "g++ !$"', but it doesn't execute command (just "pastes" it)
  • bind -x '"\ee": "g++ !$"', but it doesn't interpret the !$ part correctly

Any way to overcome it without using some custom shell scripts?

share|improve this question
I am not sure, but you can try escaping the bang and/or the dollar like bind -x '"\ee": "g++ \!\$"' . Does it work? – Sudhi Mar 10 '13 at 12:08
No, it doesn't. – ΔλЛ Mar 10 '13 at 12:15
up vote 0 down vote accepted

bind '"\ee": "g++ !$"' does exactly what you wrote, which is to insert g++ !$ on the command line. If you want the command to be executed, you need to press Enter.

bind '"\ee": "g++ !$\r"'
share|improve this answer

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.