Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 would like to be able to define arbitrary modifications to command lines that happen before bash sees them at all, ie, before expansion of any kind. Is this possible?

I'm not trying to solve one particular problem, I'm really just curious if it is possible to obtain exactly this functionality without writing my own shell.

share|improve this question
What kind of modifications? If you just want shortcuts to things, use alias. – jtbandes Jul 24 '10 at 21:13
>"before expansion of any kind." I would like to do complete rewriting of entire command lines. Aliases and shell functions are the limitation I am trying to overcome. – Personman Jul 24 '10 at 21:28
related:… – poindexter Apr 30 '12 at 14:10
up vote 2 down vote accepted

I would suggest that you investigate the possibility of binding the readline function accept-line (Ctrl-m) into the Bash completion facility (readline complete) where you would be able to process the line and should be able to execute it from there.

share|improve this answer
Can you give an example of how one would do this? Are you suggesting using a bind command to change the behavior of C-m? Or are you suggesting that complete offers some way to intercept accept-line? – poindexter Apr 27 '12 at 18:03

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.