Entries classified under osx


Mac OS X Things - Disable Dashboard
- I wanted to like it but...
To links osx tips mac ... on Mon 07/04/05 at 04:43 AM
DarwinPorts Guide
- Alright, it looks like I'm going to have to break down and learn how to package ports since none of this crap is working on Tiger.
To links osx unix apple bsd tools ... on Wed 06/15/05 at 06:15 PM
The Apple Blog - Quicksilver Changes Everything
- Seriously.
Python Metadata Importer
- A Spotlight Plugin that imports and indexes Python source code. w00t!
To links coding python osx mac ... on Wed 05/25/05 at 08:24 PM

OS X Network Location support from the command line

I move between three different network configurations with my powerbook in an average day. Two of these configurations have proxy servers and one does not. Mac OS X has really excellent network location support that lets me configure this stuff once so that switching locations is as simple as invoking QuickSilver, typing the first few letters of the network location and BAM.

Most applications automatically pick up the new proxy configuration but some do not, like Firefox (which is one of three big reasons I still use Safari). I do a lot of work from the command line with network based tools such as curl, wget, port, http_ping, links, svn, etc. None of these use the system proxy settings but most support specifying a proxy server via the http_proxy environment variable.

I've searched high and low for a mechanism that would handle setting the http_proxy variable based on my current network location but have come up with nothing.

First, you need to create a file /etc/http_proxy that specifies the proxy servers for each Network Location you have setup in your Network Preferences (If anyone can figure out how to get the proxy information directly please let me know. I can get the current network location but not information about it). The file might look something like this:

Work = http://proxy.example.com:80
Library = http://proxy.library.com:80

The keys are the names of your network locations and the values are in http://proxy-host:proxy-port form.

Next, you'll need to put the following script somewhere along your $PATH named proxy-config and give it a chmod +x too.

 #!/bin/bash 

 # source this into your current to have the proxy 
 # environment variables needed by many command line 
 # apps setup correctly.

 # get the current network location name
 netloc=$(/usr/sbin/scselect 2>&1 | egrep '^ * ' | \
          sed 's:.*((.*)):\1:')

 # find the proxy in /etc/http_proxy based on the 
 # current location
 http_proxy=$(egrep "$netloc[ \t]*=" /etc/http_proxy | \
              sed 's/.*=[ \t]*(.*)/\1/')

 if [ -n "$http_proxy" ]; then
   export http_proxy
   export HTTP_PROXY="$http_proxy"
 else
   unset http_proxy
   unset HTTP_PROXY
 fi

 # the rest of this is used for symlink commands
 bn=$(basename $0)
 if [ "$bn" != "proxy-config" ]; then
     dn=$(cd $(dirname $0); pwd)
     for p in $(echo $PATH | sed 's/:/ /g'); do
       [ "$p" != "$dn" ] && [ -x "$p/$bn" ] && exec "$p/$bn" "$@"
     done
 fi

This script has two usage scenarios. You can source this into your current shell to have the http_proxy set correctly based on your current network location:

$ . proxy-config
$ echo $http_proxy
http://proxy.example.com:80

Alternatively, you can create symlinks to the proxy-config script using the names of commands that require http_proxy and the script will automatically set the variable and exec the real command.

Got that? No? Okay, let's move on.

Pretend you have /usr/bin/curl and you put the script from above at /usr/local/bin/proxy-config. You can get curl to use the approriate proxy settings by doing something like this:

# mkdir /usr/local/proxybin
# cd /usr/local/proxybin
# ln -s ../bin/proxy-config curl
# ls -l
total 4
lrwxr-xr-x  1 root wheel 19 May 11 13:30 curl -> ../bin/proxy-config

As long as /usr/local/proxybin is on your $PATH before /usr/bin, executing curl will actuall call proxy-config. proxy-config will then setup the proxy settings and exec /usr/bin/curl.

Now just create a symlink just like the one made for curl for anything else that requires proxy settings and enjoy network location support from the command line.

To weblog osx tools bash unix ... on Wed 05/11/05 at 05:50 PM

Turn HTML off completely in Mail.app

I hate HTML mail. Apple's Mail has a preference that allows you to turn on plain text emails for sending but there's nothing obvious that let's you specify that you always want to read mail using plain text. There's a hidden preference that can be set by dropping the following into a shell:

defaults write com.apple.mail PreferPlainText -bool TRUE

You should now get all mail as boring old readable plain text.

To weblog osx mac tips ... on Fri 05/06/05 at 11:50 AM

My last experience with amazon.com

I put Tiger on order from amazon.com on April 17. They had a pretty good deal at $94.99 (suggested retail is $129) and promised to ship on April 28.

At work on Friday, somebody mentioned that microcenter had Tiger boxes on the shelves for $79.99. I was tempted to cancel my amazon order but figured it had already shipped--it was the day after the promised ship date.

Logging on I found that it had not shipped but was Shipping Soon:

We are preparing these items for shipment and this portion of your order cannot be canceled or changed.

So not only had it not shipped the day after promised but I'm now unable to cancel the order. It looked like the earliest I could expect Tiger would be today (May 2nd). I was mildly pissed off but shrugged it off as I was going to be away from the computer all weekend.

This morning I jump on to see what I missed over the weekend. Reviews, tips, tricks, hints, guides, and everything else Tiger dominated my aggregator. This jogs my memory and so I go to amazon to check the status of my order. Imagine my chagrin when the following advert popped up on the same page telling me that my order had still not shipped.

OS X Tiger

I'm no longer an amazon.com customer.

To weblog ramblings amazon osx ... on Mon 05/02/05 at 11:22 AM

Everything You Need to Know to Install Tiger
- Will be useful if amazon ever decides to ship my stuff.
To links mac osx ... on Mon 05/02/05 at 08:42 AM
Preparing for Mac OS X 10.4 (Tiger) Installation -- Avoiding issues before and after updating
- Notes on stuff that should be backed up and other tips for a smooth upgrade. The comment thread looks promising as well with everyone reporting in with problems and opinion.
To links osx mac diversions ... on Fri 04/29/05 at 06:52 PM
Paul Graham - Return of the Mac
To links diversions osx ... on Wed 03/30/05 at 02:05 PM
Clutter by Sprote Rsrch.
- "Clutter is a small Mac OS X application that lets you put music CDs on your desktop. You can drag them anywhere. Line them up neatly or put them in piles, it's your choice."
To links osx mac apps diversions ... on Tue 01/18/05 at 05:56 PM
Gish
- Supposedly kick ass video game for OS X, Linux, and Windows. Free demo available.
To links diversions games linux osx ... on Mon 12/13/04 at 11:39 PM
Apple of IBM's eye?
- Did IBM drop the x86 PC so it could start selling Mac's? Interesting..
To links diversions osx ... on Mon 12/06/04 at 07:15 PM
G4 Optimized Firefox builds..
- Haven't tried yet but these optimized builds are rumoured to blow the doors off the standard distribution.
To links moz osx web ... on Mon 11/08/04 at 04:28 PM
HOW-TO: Get music OFF your iPod
- only takes 15 pages to explain.
To links cool ipod osx tools ... on Tue 11/02/04 at 06:58 PM
Kula: 1001
- A flickr desktop client.
To links osx tools web ... on Thu 10/28/04 at 08:25 PM
Ted's Macintosh Tips and Tricks
- Excellent repository of OS X configurations, tips, applications, etc.
To links osx tips ... on Wed 10/20/04 at 04:38 AM
anacron for Mac OS X 10.3
- Hard to believe this isn't part of the standard distribution.
To links osx tools ... on Mon 10/18/04 at 04:01 AM
Mac Takes Honors as Best Unix Desktop
- "KDE and GNOME have both gotten much better, but let's get real. They're not even in the same ballpark." -- Ouch. True though...
To links linux osx unix ... on Thu 10/14/04 at 06:55 AM
Rixstep
- "A repository of every keyboard secret in OS X."
To links osx reference ... on Wed 10/13/04 at 04:55 PM
Synergy
- "share a single mouse and keyboard between multiple computers with different operating systems" via PhotoMatt.
To links linux osx tools ... on Thu 09/23/04 at 12:37 PM
GNOME: We've overtaken Windows, bring on Apple
- Title is a bit misleading. GNOME feels they have reached Windows' level of functionality (I'd agree) and are now shooting to bring the featureset in line with Apple's OS X.
To links gnu linux osx ... on Thu 09/16/04 at 06:09 AM
Magical Macintosh Key Sequences
- Collection of poorly documented OS X key-sequences.
To links osx reference ... on Tue 09/14/04 at 03:38 AM
Goban
- Hey tkington! I noticed this come in on my OSX del.icio.us feed.
To links game osx ... on Fri 09/10/04 at 12:10 AM

30 Pixels, 30 Lines

It is perhaps slightly amusing that writing 30 lines of code in Emacs and resizing the Emacs window under OS X requires an equivalent amount of time.

To osx emacs ramblings weblog ... on Wed 09/08/04 at 04:00 AM

Quick OS X (and Emacs) Keystroke Reference

Emacs keystrokes supported by all OS X applications that use native text widgets.

To emacs osx reference ... on Wed 09/08/04 at 03:41 AM

Useful OS X Keystrokes
To links osx ... on Wed 09/08/04 at 03:27 AM
Apache Web Serving With Mac OS X
- Six part series on OSX's built in Apache httpd configuration.
To links osx ... on Fri 08/27/04 at 02:36 AM
Colloquy: IRC Client
- Solid OS X interface.
To links osx ... on Thu 08/19/04 at 01:35 AM
TerminalColors
- Modify the RGB values used for ANSI colors in Terminal.app.
To links osx tools ... on Wed 08/18/04 at 03:40 AM