My /home/myusername/ directory is provided through a network, and looks exactly the same on my Linux machine and my Mac Mini. I'd like to add to PATH a directory of Mac-specific software in my home, e.g. /home/myusername/SW/bin_mac/ and have this happen only when I'm doing command line stuff on the Mac, and not have PATH contain this when on Linux. If I edit .bashrc (or tcsh's equivalent) it'll affect PATH in both cases. What are some tricks to do this?
Adding Mac-specific directory to PATH when home is shared
command linepath
Related Question
- Removing Built-in Command-Line Utilities from PATH in zsh – macOS Guide
- MacOS – Help on setting path right
- MacOS – How -exactly- do I remove a specific directory, from the PATH, in OSX, Mavericks
- How to Export to $PATH Permanently Without .bashrc File
- How to Connect a router to console, using a mac
- PATH – Adding a New Directory to PATH Variable
- macOS – Fix Bash Commands Not Working in Terminal
- Fix Terminal PATH Issue – How to Fix Terminal Hang After Editing PATH in .bash_profile
Best Answer
Test the output of
uname
; it will beDarwin
on OS X andLinux
on Linux.Alternately, you could just add an appropriate directory on each machine, which will be useful if you find yourself needing a separate Linux
bin
directory as well in the future.and either
mv
orln -s
yourbin_mac
tobin_Darwin
; then you can create abin_Linux
directory in the future if you need it, and it'll just work.(You could also test
$HOSTTYPE
, which is set bybash
, but it contains more information than you're likely to need.)