Search code examples
macosunix.profile

Unix: making change to .profile file


I am running MAC OS X.

I added a new alias to my .profile. Now, when I open a terminal window, I get a message saying that the alias cannot be found. Do I have to do some sort of exporting to get the change to my .profile to take affect?

As requested, my .profile.

export PATH=$PATH:/opt/local/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/local/lib

alias sl='ls'
alias pwd='echo -n `pwd` | pbcopy'

Solution

  • Have you checked that you are using bash (or ksh) which reads .profile and not tcsh (the default shell on MacOS X) which does not read .profile?

    Do any other commands in your profile get executed?


    The alias not working is:

    alias pwd='echo -n `pwd` | pbcopy'
    

    The issue there is: what command is executed when the

    `pwd`
    

    is executed -- oops; it's the alias? Try:

    alias pwd='echo -n $(/bin/pwd) | pbcopy'
    

    We could also argue that you can use just:

    alias pwd='/bin/pwd | pbcopy'