You are not logged in.

#1 2008-10-18 16:42:57

Ranguvar
Member
Registered: 2008-08-12
Posts: 2,549

Multi-word aliases?

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 tongue 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

#2 2008-10-18 17:09:39

finferflu
Forum Fellow
From: Manchester, UK
Registered: 2007-06-21
Posts: 1,899
Website

Re: Multi-word aliases?

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

#3 2008-10-18 17:22:49

Radek
Member
From: Warsaw in Poland
Registered: 2006-08-20
Posts: 23
Website

Re: Multi-word aliases?

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

#4 2008-10-18 17:30:40

finferflu
Forum Fellow
From: Manchester, UK
Registered: 2007-06-21
Posts: 1,899
Website

Re: Multi-word aliases?

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

#5 2008-10-18 17:56:11

Ramses de Norre
Member
From: Leuven - Belgium
Registered: 2007-03-27
Posts: 1,289

Re: Multi-word aliases?

Add

alias sudo="sudo "

to make sudo work with aliases.

Offline

#6 2008-10-19 00:12:50

Ranguvar
Member
Registered: 2008-08-12
Posts: 2,549

Re: Multi-word aliases?

Thanks, finferflu! That works great.

Could you please explain why it works, though? I like learning big_smile

Offline

#7 2008-10-21 20:51:33

Ranguvar
Member
Registered: 2008-08-12
Posts: 2,549

Re: Multi-word aliases?

Anyone?

Offline

#8 2008-10-21 21:45:19

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: Multi-word aliases?

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

#9 2008-10-23 03:45:23

Ranguvar
Member
Registered: 2008-08-12
Posts: 2,549

Re: Multi-word aliases?

Thanks big_smile Forgot to look in man bash.

Offline

Board footer

Powered by FluxBB