I am defining an alias in a departmental .bashrc file, which is sourced before the individual user .bashrc file. In the individual user .bashrc file I would like to be able to add options to the existing alias. So for example in the first (departmental) .bashrc file I have the following:
alias my_command = '/usr/local/bin/my_command -option1 -option2' In the user .bashrc file I'd like to build on the existing alias, e.g.
alias my_command = 'my_command -option3' As written, the alias instruction in the user .bashrc file would simply replace the alias of the same name defined in the departmental .bashrc file. I tried to get around this with the following approach:
existing_alias_components=($(type my_command)) which returns the words my_command, is, aliased, and to in the first four elements of the array. I want to capture the remaining array elements, join them back into a string -- say $string -- and then issue the command
alias my_command="$string -option 3" I'm running into challenges with the fact that the quote characters that surround the first definition of the alias are getting into the first and last array values after the first four. I can substring them out, but it's getting to be a lot of work for what would be a one-liner in perl. Is there a more expedient way to accomplish this?
Thanks!