You are not logged in.
Pages: 1
Hello,
I use bash. I'd like to alias, for example, 'sudo pacman' to be 'sudo pacman-color'. This is turning out to be harder than I thought I can alias 'spacman' to that, but I'd rather learn how to do this. Symlinking pacman to pacman-color also is not preferable.
Can one alias multi-word commands to something else?
Thanks!
Offline
If you are interested in sudo only, you can put this in your .bashrc:
alias sudo='A=`alias` sudo '
In this way your aliases will persist even when you use sudo.
Other than that, I don't know how to create multi-word aliases.
Have you Syued today?
Free music for free people! | Earthlings
"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery
Offline
Why not
alias pacman=pacman-color
? I have this alias and it works fine.
"Physics is like sex: sure, it may give some practical results, but that's not why we do it."
Richard P. Feynman.
Offline
Because it doesn't work with sudo...
Also, I think s/he's asking this just as an example, as far as I understand s/he wants to find a way to use an alias which uses more than one word. Not sure that is possible at all.
Have you Syued today?
Free music for free people! | Earthlings
"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery
Offline
Add
alias sudo="sudo "
to make sudo work with aliases.
Offline
Thanks, finferflu! That works great.
Could you please explain why it works, though? I like learning
Offline
Anyone?
Offline
If the last character of the alias value is a blank, then the next command word following the alias is also checked for alias expansion.
edit: that's in man bash btw, not man alias.
Last edited by Procyon (2008-10-21 21:45:53)
Offline
Thanks Forgot to look in man bash.
Offline
Pages: 1