Super User is a question and answer site for computer enthusiasts and power users. 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 was wondering if it is possible to modify bash such that when I type

command --arg1

what actually happens is

~/ command --arg1

( would handle starting command --arg1 itself)


share|improve this question
up vote 5 down vote accepted
command () { some_command $@

Then when you run command --arg1 it will pass it all on to the 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='~/ command'
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .