You can temporarily redefine the value of PATH
by prepending its definition to the command:
PATH=/some/directory/somewhere:/usr/local/bin:/usr/bin:/bin deploy
This can also be packed into an alias:
alias some_prefix='PATH=/some/directory/somewhere:$PATH'
So that you only need to run:
some_prefix deploy
The shell (bash
, zsh
or even dash
), will first expand the alias
PATH=/some/directory/somewhere:$PATH deploy
and then the PATH
parameter
PATH=/some/directory/somewhere:/usr/local/bin:/usr/bin:/bin deploy
before using the redefined PATH
to search for the deploy
command and also passing it onto the environment of the deploy
process.
Note: The definition is scoped only to the following command, not to the whole command line. So, if you run
some_prefix deploy ; deploy
only the first deploy
will be searched in the modified PATH
, while the second uses the original value of PATH
. The same holds true for commands that are chained with |
, &&
or ||
. If that is an issue, you might want to have a look at this question. Of course it is always possible to just use the alias multiple times as needed:
some_prefix deploy; some_prefix deploy