Take the 2-minute tour ×

I was wondering if it is possible to modify bash such that when I type

command --arg1

what actually happens is

~/prerun.py command --arg1

(prerun.py would handle starting command --arg1 itself)


share|improve this question

2 Answers 2

up vote 5 down vote accepted
command () {
    prerun.py some_command $@

Then when you run command --arg1 it will pass it all on to the prerun.py script.

share|improve this answer
Thanks! Exactly what I was looking for. –  Jake Burton Oct 7 '12 at 21:10
Note that a function is recommended above an alias for extensibility purposes. Passing it variables and whatnot are far more capable. They can be multiple lines long and allow you to use variables internally. –  UtahJarhead Oct 7 '12 at 21:50
make sure you quote "$@" so any arguments with whitespace are protected –  glenn jackman Oct 8 '12 at 2:00

Define an alias with the alias builtin:

alias command='~/prerun.py command'
share|improve this answer

Your Answer


