You are not logged in.

#1 2010-04-15 15:04:37

vendion
Member
From: Tennessee, USA
Registered: 2010-03-10
Posts: 204
Website

[solved] Possible to create an alias for pacman?

Ok so I'll admit I haven't been using Arch for long, been playing with it in a VM for about a month now and after being forced with having to do a reinstall on my main machine I deiced to see what Arch can do on real hardware.  I have to admit I am very impressed, great job to all the devs and contributers!

Anyways onto my question, I like the colorized output of pacman-color over the vanilla pacman, and I'm to lazy to keep typing '-color', I have tried to setup the alias in both my ~/.bashrc and /etc/bash.bashrc.local but no matter if I just close out of my terminal or logout and back in I don't get pacman-color.  I know someone is going to ask "Did you set the alias up right" (or something along the lines) so here is what I have:

alias pacman='pacman-color'

I know my $PS1 is not messing with it because I can call pacman-color up by hand and it works like it should.

Any ideas?

Last edited by vendion (2010-04-17 13:05:32)

Offline

#2 2010-04-15 15:16:03

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: [solved] Possible to create an alias for pacman?

one: you might not be sourcing bashrc by default because of a lacking bash_profile.

echo '. $HOME/.bashrc' > ~/.bash_profile

two: you need to resource bashrc (or login/out) after making changes

source ~/.bashrc; pacman -Qe

try those, we'll go from there.

*note that my echo > profile line will overwrite any existing bash_profile*

/edit: whoops -Qqe is a bad test case... thanks.

Last edited by brisbin33 (2010-04-15 18:29:41)

Offline

#3 2010-04-15 15:22:21

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [solved] Possible to create an alias for pacman?

You can of course use any alias / abbreviation:

alias p="pacman-color"
alias psyu="pacman -Syu"

etc.

Offline

#4 2010-04-15 15:23:08

JohannesSM64
Member
From: Norway
Registered: 2009-10-11
Posts: 623
Website

Re: [solved] Possible to create an alias for pacman?

pacman -Qqe has no color, even with pacman-color. Try -Qe instead.
@ brisbin

Last edited by JohannesSM64 (2010-04-15 15:23:38)

Offline

#5 2010-04-16 01:13:01

vendion
Member
From: Tennessee, USA
Registered: 2010-03-10
Posts: 204
Website

Re: [solved] Possible to create an alias for pacman?

Ok so it works when I source it like brisbin suggested but if I do it with out sourcing the .bashrc file, even after logging out and back in, it doesn't work again.  I know that the terminal is reading my .bashrc file because I program in Go which requires modifying the .bashrc file.  So my .bashrc looks like this:

 # Check for an interactive session
[ -z "$PS1" ] && return

alias pacman='pacman-color'
alias ls='ls --color=auto'
PS1='\[\e[0;32m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[1;32m\]\$\[\e[m\] \[\e[1;37m\]'

export GOROOT=$HOME/go
export GOARCH=amd64
export GOOS=linux

Now I know it works because when I list my environment I see the three Go entries

vendion ~ $ env | grep '^GO'                                                         
GOARCH=amd64
GOROOT=/home/vendion/go
GOOS=linux

Offline

#6 2010-04-16 02:36:48

tesjo
Member
Registered: 2007-11-30
Posts: 164

Re: [solved] Possible to create an alias for pacman?

Is it possible you are using su and running as root, where it should be aliased in /root/.bashrc, and henced have to be sourced from ~/.bashrc ? Or even sudo ?

Last edited by tesjo (2010-04-16 02:39:38)

Offline

#7 2010-04-16 03:14:36

Bralkein
Member
Registered: 2004-10-26
Posts: 354

Re: [solved] Possible to create an alias for pacman?

You can check which aliases are active by typing the alias command by itself, which might be helpful. Also see what the previous poster said about running as root. As for sudo, if you add alias sudo='sudo ' to your ~/.bashrc then your aliases will be expanded before sudo is invoked.

Offline

#8 2010-04-16 16:59:14

vendion
Member
From: Tennessee, USA
Registered: 2010-03-10
Posts: 204
Website

Re: [solved] Possible to create an alias for pacman?

tesjo wrote:

Is it possible you are using su and running as root, where it should be aliased in /root/.bashrc, and henced have to be sourced from ~/.bashrc ? Or even sudo ?

Well I don't think so...

vendion ~ $ whoami                                                                   
vendion                                                                              
vendion ~ $ su                                                                       
Password:                                                                            
root /home/vendion # whoami                                                          
root                                                                                 
root /home/vendion # exit                                                            
exit                                                                                 
vendion ~ $ whoami                                                                   
vendion

I do prefer using sudo over su so I originally set the alias in /etc/bash.bashrc.local so it would work no matter if I am normal user or su/sudo.  I only set it in ~/.bashrc for troubleshooting reasons.

Offline

#9 2010-04-16 17:05:34

vendion
Member
From: Tennessee, USA
Registered: 2010-03-10
Posts: 204
Website

Re: [solved] Possible to create an alias for pacman?

Bralkein wrote:

You can check which aliases are active by typing the alias command by itself, which might be helpful. Also see what the previous poster said about running as root. As for sudo, if you add alias sudo='sudo ' to your ~/.bashrc then your aliases will be expanded before sudo is invoked.

Well that is why I posted here it is listed under both normal user and root, but doesn't work

vendion ~ $ alias                                                                    
alias df='df -h'                                                                     
alias diff='colordiff'                                                               
alias du='du -c -h'                                                                  
alias grep='grep --color=auto'                                                       
alias ls='ls --color=auto'                                                           
alias mkdir='mkdir -p -v'                                                                                                                                                                                               
alias pacman='pacman-color'                                                          
alias ping='ping -c 5'
vendion ~ $ su                                                                       
Password:                                                                            
root /home/vendion # alias                                                           
alias df='df -h'                                                                     
alias diff='colordiff'                                                               
alias du='du -c -h'                                                                  
alias grep='grep --color=auto'                                                       
alias ls='ls --color=auto'                                                           
alias mkdir='mkdir -p -v'                                                                                                                                                                                                
alias pacman='pacman-color'                                                          
alias ping='ping -c 5'

as for the sudo suggestion I will try that

Offline

#10 2010-04-16 17:17:00

vendion
Member
From: Tennessee, USA
Registered: 2010-03-10
Posts: 204
Website

Re: [solved] Possible to create an alias for pacman?

Ok so correction its just not working in sudo, as it can be seen in the image I did add the alias sudo='sudo' line and it is active.  I choose pacman -Syu because I knew that it had color, but also would generate a short print out to try and avoid flooding the screen.
21plvt.png

Offline

#11 2010-04-16 17:22:50

Bralkein
Member
Registered: 2004-10-26
Posts: 354

Re: [solved] Possible to create an alias for pacman?

Hi, you missed out the space character in the alias. It has to be exactly alias sudo='sudo ' otherwise it doesn't work. Go figure.

Offline

#12 2010-04-17 13:04:52

vendion
Member
From: Tennessee, USA
Registered: 2010-03-10
Posts: 204
Website

Re: [solved] Possible to create an alias for pacman?

Thanks for the help it is working now.

Offline

Board footer

Powered by FluxBB