I would like to add:
function ps_mem {
python /home/vagrant/ps_mem/ps_mem.py -p $@
}
To the end of ~/.bashrc from the command-line. I have tried using:
printf "function ps_mem {\n python /home/vagrant/ps_mem/ps_mem.py -p $@ \n}" >> ~/.bashrc
And while it almost worked, the input field $@ was ignored, making this:
function ps_mem {
python /home/vagrant/ps_mem/ps_mem.py -p
}
Instead, be added to the end of ~/.bashrc.
"'$@'"would do it... But you want"'"$@"'"so that you have quotes in the function. – jasonwryan Oct 27 '15 at 07:11function foo {syntax) andzshscript ($@unquoted which only makes sense in zsh and is for the list of non-empty arguments) than a bash script. Inbash, that would beps_mem() { python /home/vagrant/ps_mem/ps_mem.py "$@"; }or if you do really want to remove empty arguments:ps_mem() (IFS=; set -f; python /home/vagrant/ps_mem/ps_mem.py $@;}– Stéphane Chazelas Oct 27 '15 at 08:55