views:

21

answers:

1

Hi. I want to know how to configure your environment to execute some command with specific params everytime you use it. So, if I have a command named:

spec

I want to know where I configure my bash to always use:

spec -c --format nested

instead of just 'spec'

I tried to put this like an alias on my .bashrc file, like:

alias spec='spec -c --format pretty'

but didn't work. Any tip?

+1  A: 

Did you remember to execute your .bashrc after editing it?

. ~/.bashrc will do it.

Also, your two commands don't match. You have "nested" in one and "pretty" in the other.

danben
@danben: Thanks man, you're the guy! It worked. But tellme something: why '~/.bashrc' doesn't work, but '. ~/.bashrc' works? What's the meaning of the '.' before the expression? Thank you again.
Gabriel L. Oliveira
@Gabriel: The dot means to source the file which runs the commands in the file in the current environment and allows variables, aliases and `cd` to remain in affect after the file exits. If you *run* it instead, changes to the environment only affect its environment rather than the parent's.
Dennis Williamson
@Gabriel: If this was helpful, I would appreciate if you would upvote / accept the answer. Thanks!
danben
Note that the `.` command is equivalent to the `source` command. In scripts and examples, I always use `source` since its not as confusing as seeing a lone period and wondering what the heck it means. But both do the same thing, tell the shell to execute commands stored in a shell script file in the running shell.
Peter Lyons
@Peter thank you
Gabriel L. Oliveira