Using "nice" command with an alias
bash
Solution
Alias is a shell feature, and `nice` is an external program:
$ type nice
nice is hashed (/usr/bin/nice)
It's the program `nice` that runs the command passed as an argument, calling the C function `execve`, so all the arguments for it need to be evaluated BEFORE the call.
So, it would probably better not to use an alias and simply put the whole command needed there, but if you really want to, you could try something like this:
$ nice -10 `alias list | sed "s/^\(alias \)\?[^=]\+='//; s/'$//;"`
`alias list` prints the alias definition in the format `alias list='ls'` (or `list='ls'`, if it's `/bin/sh`), so I did some sed substitutions there to get only the command it expands to.
If you're sure to use only `bash` you can use `${BASH_ALIASES[list]}` instead, as pointed out in the comments:
$ nice -10 ${BASH_ALIASES[list]}
Problem
How can I use the "nice" command with an alias? As an example: ``` alias list=ls list # works nice -10 list # doesn't work ``` How could I make that last line work?