6

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)

Thanks!

5
command () {
    prerun.py some_command $@
}

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

2
  • 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
  • 2
    make sure you quote "$@" so any arguments with whitespace are protected – glenn jackman Oct 8 '12 at 2:00
6

Define an alias with the alias builtin:

alias command='~/prerun.py command'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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