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

Upgrade the CVS command line tools UNIX
Type cvs -v in the terminal to see which version you have. More than likely you'll see Concurrent Versions System (CVS) 1.10 `Halibut' (client/server)

Here's how to compile version 1.11.1p1. These instructions will replace the existing Apple-supplied CVS files including the html documentation. By default, 'make' wants to install texi info files for the docs, but we're going to trash those and create html versions instead, as with Apple's distribution. Also we change the other default UNIX installation directories to use Mac OS X specific ones.

Read the rest of the article for the step-by-step instructions.
read more (121 words)   Post a comment  •  Comments (5)  
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[6,122 views] Email Article To a Friend View Printable Version
More Terminal keybindings for the bash shell UNIX
In other *nix prompts, you can do history searches for partial commands. For instance, if you find yourself typing "telnet 192.168.1.12" repeatedly, you can type "tel and hit Page Up to search for the last command you typed that began with "tel" You can hit Page Up repeatedly to find the previous command that began the same way. You can also hit Page Down to go forward in the search if you hit Page Up too many times and missed the command you wanted.

Terminal uses Page Up and Page Down for scrolling, which is great for new users, but seriously slows power users down. Other unices use Shift-Page Up and Shift-PageDown for scrolling.

To restore command completion from history (in bash), you can use (mind the quotes!):
bind '"M-e": history-search-backward'
bind '"M-r": history-search-forward'
This binds Option-E to the reverse search (Page Up on Linux) and Option-R to a forward search (Page Down on Linux). To use this, the "Option (alt) key acts as meta key" item under Emulation in Terminal preferences must be on.

I put these commands in my .profile so that my terminal would always be configured to my tates. I'm sure there's an analogous command in tcsh.

On a side note, if you want a more powerful history search, you can hit Control-R to do a full interactive history search under bash. You hit Control-R at the prompt and type some text. Each letter you type will make the search more detailed. For example, if you want to find the last command that you executed with 192.168.1.12 as a parameter, you can hit Control-R and begin typing the IP. When you type the "1" the last command with a "1" in it will be displayed. When you type "9" the last command with a "19" in it will be displayed, and so on. Hitting Control-R again tries to find another command that matches.
  Post a comment  •  Comments (1)  
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[5,368 views] Email Article To a Friend View Printable Version
Create a command-line calculator UNIX
I love this, even though I didn't think of it myself. ;-)

Want a simple calculator that works at the Terminal prompt? As per the suggestion on this website, just put this in your ".cshrc" (or "aliases.mine" as the case may be):
alias calc 'awk "BEGIN{ print \!* }" ' 
That's it. Then run
% source .cshrc
% rehash
and you can do basic arithmetic in the Terminal application:
% calc 545+56
601
% calc 545-56
489
% calc 545*56
30520
% calc 545/56
9.73214
I like this especially because now I don't have to use the wretched Numlock key on my iBook.
  Post a comment  •  Comments (6)  
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[5,537 views] Email Article To a Friend View Printable Version
A replacement for the 'basename' command UNIX
I've written many unix scripts over the past years and very early on I found myself using the basename command numerous times.

As I'm always concerned about performance I looked into using the powerful shell built-in variable substition feature to reduce my use of basename.

Read the rest of the article to see what I came up with...
read more (213 words)   Post a comment  •  Comments (1)  
  • Currently 3.60 / 5
  You rated: 4 / 5 (5 votes cast)
 
[5,046 views] Email Article To a Friend View Printable Version
Create customized new terminal windows UNIX
Since I installed OS X, I've wanted to be able to pop up Terminal windows that have a specified title and are running a specified application. I'm about 90% there, and thought I'd share what I've written with the MacOSXhints gang.

Note that this is a Unix shell script that you'll want to copy onto your system, save with some name ('newterm'), then use chmod +x newterm or similar to ensure that it's executable.

Then you can start up a new Terminal window with the title "my terminal" and the core shell of /usr/bin/vi (for example), with:
newterm "Edit Window" "/usr/bin/vi"
Pretty cool, eh?

Read the rest of the article for the "new term" shell script.
read more (324 words)   Post a comment  •  Comments (3)  
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[5,459 views] Email Article To a Friend View Printable Version
Create a fixed-length bash shell prompt UNIX
This tip is stolen from instructions in the Bash Prompt HOWTO. It's not terribly innovative, and most Unix distributions (MacOS X included) come with a tolerably decent default prompt; consequently, even many very experienced Unix users don't know a lot about prompt configuration (I certainly didn't). But if you compile and install bash on MacOS X, you'll find that you are left with a very unsatisfactory default prompt. It was this problem that led me to sniff this information out.

This tip solves the dilemma of whether to use \W (current directory without path) or \w (complete path to current directory) in the prompt. On the one hand, \W doesn't contain the path (am I in /etc or /usr/local/etc?), but \w (which contains the path) can monopolize the command line. The solution: Include only the last x characters of the current working directory.

This tip will work swimmingly with bash, and maybe someone can explain how to do the same thing with tcsh in the replies (I'm a bash partisan myself, and I heartily recommend it to anyone who has to use the shell regularly). Read the rest of this article for instructions on creating a fixed-length bash shell prompt.
read more (191 words)   Post a comment  •  Comments (22)  
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[7,527 views] Email Article To a Friend View Printable Version
Modular profile file for your shell UNIX
This tip is a shell setup technique that I have stolen from Mandrake Linux. It is only good for people that have heavilly customized their /etc/profile file, so the instructions assume a good deal of terminal knowledge. Instead of having one, monolithic profile file that is littered with different commands and environment settings, you can modularize it into a bunch of tidy, discrete items. You can do this as follows:
  1. su to root and cd to the /etc directory.

  2. Create a directory in /etc called profile.d.

  3. Use your favorite console text editor to add the following lines to the beginning of your profile file:
    for PROFILE_SCRIPT in $( ls /etc/profile.d/*.sh ); do
    . $PROFILE_SCRIPT
    done
  4. Convert all of the commands in your profile file to individual shell scripts, and save them in /etc/profile.d (make sure they end in .sh), and delete them from /etc/profile.
Voila! Instead of having one, confusing, hard to navigate profile file, you have tidy, individual scripts. For example, my alias for ll (I use bash, so that ll is not built in) is in /etc/profile.d/alias_ll.sh, and my prompt code is in /etc/profile.d/prompt.sh.
  Post a comment  •  Comments (2)  
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[7,080 views] Email Article To a Friend View Printable Version
Setting up lpd printing on OS X UNIX
lpd is the standard Unix printing system, so others who come from the Unix community (as I did; a longtime Linux and NeXT user) might be interested in sharing their printers to their other Unix machines.

See, not having lpd as the printing system in OS X was a big bummer to me, because it meant that I could no longer print with my NeXT and other Unix computers, because my printer is now hooked to my G4 Cube (permanently assigned to OS X 10.1). With this little hacked up lpd, I can now do that again. :)

Read the rest of the article for the how-to.

[Editor's note: I have not done this on my machine as of yet, but 'eagle' vouches that it works but only on PostScript printers! Any errors in the following article are a result of my formatting work; please let me know if you see any troublesome lines!]
read more (338 words)   Post a comment  •  Comments (9)  
  • Currently 2.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[17,710 views] Email Article To a Friend View Printable Version
Run a caching-only name server UNIX
This one is for you hacking nuts that do absolutely everything possible to optimize your OS X machine.

If you are on a broadband network, then you can slightly optimize your internet access by installing bind, the Berkeley Internet Name Domain server name server as a caching server.

Using this caching nameserver setup should give you instant dns lookups on (pretty much) any hostname that has been used by any application on your machine at any time since the last reboot. Thus, if you access ftp.xyz.com using Fetch, the nameserver will look up the hostname and store it, so that tomorrow when you access it with Internet Explorer the caching nameserver will return the lookup information instantly.

If you'd like to set this up on your machine, read the rest of the article.

[Editor's note: I have not tried this myself yet, and it's a relatively complex hint. I believe I didn't lose anything in the formatting process, but please post if you notice any errors.]
read more (722 words)   Post a comment  •  Comments (30)  
  • Currently 5.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[20,087 views] Email Article To a Friend View Printable Version
High bit shell commands with AppleScript UNIX
I have written a script (with the help of James Sorenson) that allows AppleScript to execute shell commands containing high bit characters via the Terminal. The script additionally allows a very long sequence of commands to be run.

Please be careful with this for the time being. I have only tested it a little, and I would appreciate any input.

Download the Script

Note: The script passes the commands directly to the terminal, so you need to properly quote and/or escape the strings beforehand. Check out this hint for a way of doing this.
  Post a comment  •  Comments (0)  
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[3,305 views] Email Article To a Friend View Printable Version