Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

A couple of hints to ease working in the Terminal and GUI UNIX
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.
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[7,369 views]  

A couple of hints to ease working in the Terminal and GUI | 10 comments | Create New Account
Click here to return to the 'A couple of hints to ease working in the Terminal and GUI' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A couple of hints to ease working in the Terminal and GUI
Authored by: rufo on Apr 24, '03 12:23:26PM

Seems to me a far easier thing to do would be to edit the file ".hidden" at the root level of the hard drive and quit the finder (logout/login, force-quit, whatever). Since it begins with a dot, chances are you'll have to use a command-line editor or BBEdit's "Open Hidden" feature.

This will work for any other folder in the OS also... just create a text file (UNIX formatted!) called ".hidden" and put the names of any folders or files you want hidden in the finder in that file.



[ Reply to This | # ]
One thing I really miss in Terminal.app
Authored by: Greedo on Apr 24, '03 01:14:47PM

... is the ability to copy-on-select, and (with my 3-button mouse), right-click to paste.

I use this feature on my Windows box (with SecureCRT from Vandyke), and am always annoyed that I seem to need to select, Command-C, Command-V to do the same thing.

Is there a solution for Terminal.app?



[ Reply to This | # ]
Try iTerm
Authored by: googoo on Apr 24, '03 01:24:35PM

iTerm does this. (You can enable/disable this feature in the prefs.)

-Mark



[ Reply to This | # ]
Paste Selection
Authored by: hayne on Apr 24, '03 01:27:09PM

Right there in Terminal's Edit menu is "Paste Selection": Shift-
Command-V
It only works to paste the selection from the same window - you
can't paste the selection from some other Terminal window.



[ Reply to This | # ]
re: One thing I really miss in Terminal.app
Authored by: testrmn on Apr 24, '03 05:01:02PM

I have a four button mouse (two on the side) with scroll wheel. I
used the "Microsoft Mouse" preferences pane to set my mouse
buttons to mimic the unix buttons when using x11 and
terminal.app. Left button is click, wheel button is option-click,
right button is command-click. Now I can highlight and paste
with left and right clicks, and paste by clicking the scroll wheel. I
kept the traditional finder "right click" by remapping my right
side button to control+secondary click.

I can cut and paste between two or more terminal windows and
xterm windows, but not from terminal to xterm.



[ Reply to This | # ]
One thing I really miss in Terminal.app
Authored by: ylon on Apr 25, '03 06:23:35PM

Even better, I use an MS Trackball with a couple of extra buttons
and I set up the middle mouse click to paste (as in XFree86)
and one of the spare buttons to copy. Works nearly as well as
always copying the selection to clipboard as in XF86!



[ Reply to This | # ]
cpmac, mvmac
Authored by: martinx on Apr 24, '03 01:39:32PM

I don't understand why the functionality of moving the whole file
(including resources) isn't directly a part of mv/cp. I mean, I understand
why just porting the unix utilities might result in this situation.

(Well actually I can't understand why mv would even be affected - isn't
moving a file just shuttling its inode to another directory? how would
that affect or cause the resource fork to get lost?)

But under what situation would you want to copy or move a file and lose
the HFS+ specific data? Is there any good reason to not link mv to
mvmac and cp to cpmac? Why didn't Apple do this?



[ Reply to This | # ]
man mv
Authored by: jecwobble on Apr 24, '03 04:14:09PM
This is from the mv man page:
     As the rename(2) call does not work across file systems, mv uses cp(1)
     and rm(1) to accomplish the move.  The effect is equivalent to:

           rm -f destination_path && \
           cp -PRp source_file destination && \
           rm -rf source_file



[ Reply to This | # ]
man mv
Authored by: martinx on Apr 24, '03 05:23:58PM

Right, but MvMac doesn't move files across volumes/filesystems anyway.
The particular question is why MvMac is needed to move files on the
same HFS+ filesystem.



[ Reply to This | # ]
inodes must be changed on same disk mv'ing
Authored by: ylon on Apr 25, '03 06:29:11PM

That's odd. In this case I don't believe the man page. You'll
notice a serious time differential when comparing `cp -fr` with
`mv`. In the case of moving across file systems/networks, this
is true, however when moving on the same disk, it must be
changing inodes. I guess it's time to pull out the source...



[ Reply to This | # ]