Aliases not working

Joined
Nov 22, 2009
Messages
16
Reaction score
0
Points
1
Greetings,
I'd like to set up some aliases for use on my macbook. I'm using the bash shell and have read different posts on how to create a file for storing aliases. One tells me to create a .tcshrc file and another says to create a .bashrc file - each in the home directory. I've created both, but neither one seems to work when I try to test one of my aliases in a Terminal window.

Should I use a .bashrc file with the bash shell or .tschrc? Just saving the files doesn't seem to work. I exit and re-enter a Terminal, but as said, the aliases do not work. Am I missing a step?

Example of .bashrc
alias lsla 'ls -la'
... some other simple aliases...

Any help would be greatly appreciated.
 
Joined
May 22, 2005
Messages
2,159
Reaction score
67
Points
48
Location
Closer than you think.
Your Mac's Specs
Performa 6116 2GBSCSI 8MB OS 7.5.3
Do you mean "aliases", "hard links" or "symbolic links"?

They are all different animals that do similar jobs. Aliases are created in the Finder, whereas hard and symbolic links are created in the CLI. Although an alias can be created through the CLI, unless you needed to script it, why would you do it?

Some good info,..

Hard link vs Symbolic link - MacNN Forums

An alias works differently than a sym-link because you can move the original around the same volume and it will still work. A hard link references the same inode number which is like an alias but the alias does not have the same file size associated with the original file.
 
Joined
Mar 30, 2004
Messages
4,744
Reaction score
381
Points
83
Location
USA
Your Mac's Specs
12" Apple PowerBook G4 (1.5GHz)
I think he means Unix command aliases, not Mac filesystem aliases.

Whether you use a .bashrc or .tcshrc depends on whether you're using BASH (which is the default) or tcsh.
 
Joined
Feb 14, 2004
Messages
4,781
Reaction score
166
Points
63
Location
Groves, Texas
You are probably using bash and if so, the format of your aliases are incorrect.
They should look like this:

alias ll='ls -laghF'
alias l='ls -laghF'
alias grep='grep -n'

Notice the = after the alias.
Save your .bashrc file and restart Terminal.
 
OP
Y
Joined
Nov 22, 2009
Messages
16
Reaction score
0
Points
1
Thanks for the replies all.
I do mean the unix style aliases used to let me use shortcuts in my terminal window.

echo $SHELL nets me:
/bin/bash

So, I'm using the bash shell and .bashrc to store my aliases. I added the '=' (equals) to my lines and restarted a Terminal window. Still does not work. I've done this many times in my Ubuntu desktop without problems. Makes me say, Grrrrr!

My aliases reduced to simple ones to test the file:
>> cat .bashrc

alias webdev 'ssh [email protected]'
alias cdrails 'cd depot/mainline/websw/intraroot/rails/'

alias rm='rm -i'
alias mv='mv -i'
alias cp='cp -i'
alias lsla='ls -la'

Thanks for the tips.
YankeeFan
 
Joined
Feb 14, 2004
Messages
4,781
Reaction score
166
Points
63
Location
Groves, Texas
Which ones don't work? These should:

alias rm='rm -i'
alias mv='mv -i'
alias cp='cp -i'
alias lsla='ls -la'

These won't without the =:

alias webdev 'ssh [email protected]'
alias cdrails 'cd depot/mainline/websw/intraroot/rails/'

and may not anyway, I'm not familiar with using ssh in an alias.
 
OP
Y
Joined
Nov 22, 2009
Messages
16
Reaction score
0
Points
1
None of these work in my terminal. Thanks for spotting the missing '=' is the last two. I specifically tried the lsla alias and the alias cp. Neither worked.

I'll have to try again at home later. I do not have my laptop with me today.

Thanks for the tips.

YankeeFan
 
Joined
Feb 14, 2004
Messages
4,781
Reaction score
166
Points
63
Location
Groves, Texas
Just for giggles open a Terminal and type:

alias

What comes up? It's possible your .bashrc isn't being sourced, therefore the aliases don't work.
 
OP
Y
Joined
Nov 22, 2009
Messages
16
Reaction score
0
Points
1
>> aslias gets me:
alias rvm-restart='source '\''/Users/johncowan/.rvm/scripts/rvm'\'''

I agree with you cradom. I started thinking that maybe my mac is not seeing the .bashrc file. How do I get it to be sourced, as you put it.

Thanks,
 
OP
Y
Joined
Nov 22, 2009
Messages
16
Reaction score
0
Points
1
I got it!
In ~/.bash_profile I added my .bashrc file.

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

That does the trick. I'm good.
 
OP
Y
Joined
Nov 22, 2009
Messages
16
Reaction score
0
Points
1
Failed to thank everyone for helping me with this. It is much appreciated.

YankeeFan
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top