how to set up aliases in Terminal?

Discussion in 'Mac Apps and Mac App Store' started by beethovengirl, May 20, 2004.

  1. beethovengirl macrumors regular

    Jan 15, 2004
    While I'm waiting for suggestions on user-friendly implementations of ssh and scp for Mac OS X, I was hoping someone could help me set up aliases in Terminal. I'm accustomed to getting UNIX accts from school in which there is a .cshrc, .login, or .aliases file that makes setting up aliases obvious, but I couldn't figure it out in OS X.

    By the way, I'm using tcsh.

    I'm sorry if this question is answered in Pogue's Missing Manual, but I'm waiting for amazon to deliver it. :)

    Thanks for your help! :)
  2. GovornorPhatt macrumors regular

    Dec 19, 2003
    Where do YOU live?
  3. Rower_CPU Moderator emeritus


    Oct 5, 2001
    San Diego, CA
    I use .login - just create the file and place it in your home directory. Close Terminal and then re-open it for the changes to take effect.
  4. beethovengirl thread starter macrumors regular

    Jan 15, 2004
    I looked at the google results, but they were contradictory about which syntax to use [whether or not there is an equal sign, for example]. Plus, a lot of them say to edit the .tcshrc or .cshrc in my home directory, but there is no file like that, as I'm accustomed in my the UNIX accounts I've used in the past.

    Can the .login file contain only the alias commands? I'm scared of creating my own .login or .cshrc file...I don't want to mess up anything. :(

    Thanks for your help! :)
  5. zimv20 macrumors 601


    Jul 18, 2002
    no worries. just make a .tcshrc file in your home directory (either vi it or use touch) and put your aliases in it.

    mine looks like this:

    alias ls ls -F
    alias la ls -a
    alias l ls -ls
    alias ll ls -als

    alias c clear
    alias h history
    alias j 'jobs -l'
    alias m more
    alias v vi

    alias ab cd -
    alias k 'cd ..'

    alias 5 'set prompt="%# "'
    alias 7 'set prompt = "[%m:%c3] `id -nu`%# "'
    alias 8 'set prompt = "[%c3] > "'

    my .login looks like this:

    # F@H commands
    alias fstart 'cd ~/F@H1; ./OSX-3.25 -local -advmethods&; cd ~/F@H2; ./OSX-3.25 -local -advmethods&'
    alias fstop 'killall OSX-3.25'
    alias fwork '~/.work'
    alias fwork2 'date && cat ~/F@H1/unitinfo.txt ~/F@H2/unitinfo.txt'
    alias frid '~/.rid'

    setenv EDITOR /usr/bin/vi

    setenv MYSQL_PATH /usr/local/mysql
    setenv VOSGES_PATH /Users/zim/Documents/vosges/devel

    setenv PATH .:/usr/local/bin:${PATH}:${HOME}/bin:${VOSGES_PATH}/bin:${MYSQL_PATH}/bin

    set filec


    i really do mean to move those folding commands out of .login, one of these days...
  6. 1=1? macrumors regular


    Jun 1, 2010
    This is so annoying. I can not get it to work.

    i put this:

    alias gosnowball 'ssh -l snowball 64.***.***.*** in

    .tcshrc in my home directory and when i go back into terminal it does nothing. I can vi the file and the line is still there in the file but it doesn't work. what the funk
  7. LPZ macrumors 65816

    Jul 11, 2006
    What do you get if you type

    echo $SHELL
    in Terminal?
  8. willieva macrumors 6502

    Mar 12, 2010
    First make sure that there is a final ' at the end of your alias line.

    Then type the following in your terminal:
    source .tcshrc

    Then type:
    to get a list of all of your aliases.

    Get a book on the c shell and read the first couple of chapters. I recommend Anderson and Anderson The Unix C Shell Field Guide.

    I'm not sure what you think * means, but it's a pattern matching metacharacter. The way you use it in this context is highly suspect.
  9. LPZ macrumors 65816

    Jul 11, 2006
    I assumed 1=1? was simply using the *'s in his post to keep from revealing an IP address.

    I'm wondering if he's using tcsh or the default, which has been bash for quite some time.
  10. willieva macrumors 6502

    Mar 12, 2010
    You're probably right on both accounts. I hadn't noticed 1=1? wasn't the OP who stated they were using tcsh.
  11. 1=1? macrumors regular


    Jun 1, 2010
    I got it to work. The problem was I needed to put it in .profile

    nothing i put in any other file worked.

Share This Page