You are not logged in.

#1 2008-06-18 22:12:02

pogeymanz
Member
Registered: 2008-03-11
Posts: 1,020

[SOLVED]Weird alias behavior...

I have an alias in my .bashrc:

alias pacman='pacman-color'

and it's also in root's .bashrc.

But when I do a 'sudo pacman' it doesn't have color. If I do 'sudo pacman-color' it has color, like it should. And if I'm root when I do 'pacman' it has color! I just copy/pasted the line from one bashrc to the other. Why the heck doesn't it work for the normal user?

Last edited by pogeymanz (2008-06-19 13:51:07)

Offline

#2 2008-06-18 23:27:43

FrozenFox
Member
From: College Station, TX
Registered: 2008-03-23
Posts: 422
Website

Re: [SOLVED]Weird alias behavior...

Did you remember to do source ~/.bashrc  from under your user acct?

Offline

#3 2008-06-19 00:10:59

pogeymanz
Member
Registered: 2008-03-11
Posts: 1,020

Re: [SOLVED]Weird alias behavior...

I did. I even logged out and back in! Here is my exact .bashrc file:

alias go='startx'
alias ls='ls --color=auto'
alias pacman='pacman-color'
alias targz='tar zxvf'
alias tarbz2='tar jxvf'

#PS1='[\u@\h \W]\$ '
PS1='\[\e[0;32m[\]\e[0;37m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[0;32m]\]\[\e[0;37m\]\$ \[\e[m\]\[\e[0;32m\] '


complete -cf sudo

Offline

#4 2008-06-19 01:40:07

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,230
Website

Re: [SOLVED]Weird alias behavior...

Login to you shell, and type `alias` (without the quotes). That will show you all the aliases currently setup ni your shell. Does it list in there?

Offline

#5 2008-06-19 02:03:20

pogeymanz
Member
Registered: 2008-03-11
Posts: 1,020

Re: [SOLVED]Weird alias behavior...

It does list it there:

[rob ~ ]$  alias
alias go='startx'
alias ls='ls --color=auto'
alias pacman='pacman-color'
alias tarbz2='tar jxvf'
alias targz='tar zxvf'

And my very next line was "sudo pacman -Syu" and it not colorful!

Offline

#6 2008-06-19 03:25:33

Daenyth
Forum Fellow
From: Boston, MA
Registered: 2008-02-24
Posts: 1,244

Re: [SOLVED]Weird alias behavior...

Add to root's .bash_profile

. ~/.bashrc

Offline

#7 2008-06-19 10:55:26

jspicoli
Member
Registered: 2008-06-19
Posts: 10

Re: [SOLVED]Weird alias behavior...

Offline

#8 2008-06-19 11:11:14

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

Re: [SOLVED]Weird alias behavior...

The problem is that sudo cleans out your environment for security reasons, this includes unaliasing everything. The solution in the link above (alias sudo="sudo ") parses the alias before sudo does this.

Offline

#9 2008-06-19 13:50:47

pogeymanz
Member
Registered: 2008-03-11
Posts: 1,020

Re: [SOLVED]Weird alias behavior...

Very interesting. And it worked as it should! You learn something everyday. cool

Offline

Board footer

Powered by FluxBB