A couple of hints to ease working in the Terminal and GUI

Apr 24, '03 09:40:00AM

Contributed by: alant

Here are two hints for making life easier while moving back and forth between the Mac's Aqua GUI and Unix's CLI. These aren't brain surgery caliper hints, but I have found them to be very useful. Hopefully some of your other readers will also. Enjoy.

Finder accessible UNIX folders: This first hint is just another alternative to several other hints (1, 2, 3, 4) that have been posted here before.

As with many OS X users, I switch back and forth between the Mac's Aqua GUI and the Unix CLI many times a day. There are often times when I am in the Finder that I wish I could see certain unix files and folders (but don't what to expose all of them to everyone). Below you will find a simple "stupid pet trick" shell script that creates Finder accessible aliases (symbolic links, actually) to several common unix directories and places them in a folder called "unix:"

 #!/bin/csh

 if !( -d 'unix' ) then
   /bin/mkdir 'unix'
 endif
 /bin/ln -s '/usr' 'unix/usr'
 /bin/ln -s '/sbin' 'unix/sbin'
 /bin/ln -s '/private/tmp' 'unix/tmp'
 /bin/ln -s '/private/var' 'unix/var'
 /bin/ln -s '/private/etc' 'unix/etc'
 /bin/ln -s '/bin' 'unix/bin'
 /bin/ln -s '/opt' 'unix/opt'
 
 # FOR THOSE THAT HAVE FINK INSTALLED
 /bin/ln -s '/sw' 'unix/sw'
[robg adds: Make sure you run this script from your home directory, as the "unix" directory will be created wherever you execute the script...]

Aliasing Mac-specific copy and move commands: I use the Terminal constantly to interact with both Unix and Mac files. As most know, Mac "files" are often made up of several parts (i.e. data and resource forks). Since I don't want to lose any of this information when copying or moving Mac files via the Terminal, I use pcpmac and pmvmac (perl versions of the CpMac and MvMac commands in the Developer Tools, accessible via fink in the Macosx-file-pm package) as replacements to cp and mv, respectively. To make life easier, I added the following lines to my .cshrc file:
 alias cpm "/usr/local/bin/pcpmac"
 alias mvm "/usr/local/bin/pmvmac"
If you have the Developer Tools installed, you could also alternatively alias to "/Developer/Tools/CpMac" and "/Developer/Tools/MvMac," respectively.

Comments (10)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20030422184737624