Erco's Mac OSX Page |
This is a hodge podge of comments I have about Mac OSX. Mainly this is here as a reminder for myself on how to do certain things I easily forget, or need to be able to show others in detail while on the road.
In general, OSX from the point of view of this Unix savvy developer who had never owned a Mac before OSX 10.0, I'd say OSX is a damned good system. Before Apple embraced unix (eg. OS9 and older), I refused to touch that stuff; OS9's operating system design (and its ilk) seemed clumsy when familiar with unix. I feel the same way about Windows, but Microsoft is taking a longer time to see the friggin light.
As successive releases of OSX have come out (10.1, 10.2, etc), I adjust my comments. But since OSX 10.5, I have less to talk about, as the OS has stabilized quite a bit. Here are links to my older pages:
Lately OSX has for the most part stabilized (10.5, 10.6), so I don't really have new comments about them. Some old comments still hold true (still no 'focus-follows-mouse' option, windows still can't be resized from the window edges, windows can't be moved off the top of the screen, etc..)
So what follows are just general noteworthy things about OSX.
For instance, the following bourne shell script which I call 'next' shows how to use AppleScript to tell iTunes to advance to the next song, and shows the name of the next song being played:
next -- Skips to the next track in iTunes |
#!/bin/sh echo -n "Telling itunes to play next song: " osascript << EOF tell application "iTunes" next track get name of current track end tell EOF |
I saved this script in my PATH with the filename 'next', made it executable (with chmod +x next) so that I can now just type 'next' in a Terminal window or ssh session to skip to the next song.
I run this when I want to skip the current song playing.
Here's another script that tells iTunes to play if iTunes is paused, and even starts iTunes running if it's not open already:
play -- Starts iTunes playing |
#!/bin/sh echo -n "Telling itunes to play: " osascript << EOF tell application "iTunes" play get name of current track end tell EOF |
I usually run this when I return from lunch, or done with a phone call, and want to continue playing iTunes from where it left off.
Here's another script that tells iTunes to pause, which I use whenever I want to leave for lunch, or if I need to take a phone call.
pause -- Pauses iTunes |
#!/bin/sh echo -n "Telling itunes to pause: " osascript << EOF tell application "iTunes" pause get name of current track end tell EOF |
Since I spend most of my time at a unix prompt or in unix text editors, it's easy for me to just run 'pause' when a phone call comes in or if I want to go to lunch, and 'play' when done. If I'm in a text editor, which is most of the time, I can just hit ^Z and run the command.
To ensure these commands work from any machine on my network, I have aliases for next/pause/play that 'rsh' the command on the one Mac I use for iTunes playback. This way, I can still run 'pause' without concern of which machine I'm logged into at the time.
OSX has never used the normal /etc/passwd way of configuring users, preferring its own method. Over time, Apple has changed the way user accounts are managed, and have changed the command line tools to manipulate them; Tiger (and older) had one way of managing this, Leopard and newer switched to a new way.
Both are documented here:
Creating A User: Tiger (10.4) and Older |
#!/bin/csh -f # # make-render-user - Run this script to create the 'render' user on a machine # 1.0 05/10/06 - erco@(email surpressed) - Supports Tiger (10.4), Panther (10.3) # set username = render # user's name set uid = 555 # must be an unused uid set gid = 20 # 20=staff set passwd = 'oFxbR2cAnG902' # passwd is 'render' # CREATE PASSWD ENTRY echo ${username}:${passwd}:${uid}:${gid}::0:0:${username}:/Users/${username}:/bin/bash | niload passwd / # CREATE USER'S HOME DIRECTORY if ( ! -d /Users/${username} ) then cp -R '/System/Library/User Template/English.lproj' /Users/${username} endif # ENSURE OWNERSHIPS ASSIGNED TO USER'S ENTIRE HOME DIRECTORY /usr/sbin/chown -R ${uid}:${gid} /Users/${username} |
Creating A User: Leopard (10.5) and Up |
#!/bin/sh # # make-render-user - Run this script to create the 'render' user on Leopard (and up) # 1.0 05/10/06 - erco@(email surpressed) (original Tiger version) # 1.1 05/13/09 - erco@(email surpressed) (changed for Leopard) # username=render # user's name uid=555 # must be an unused uid gid=20 # 20=staff passwd=render # the actual *cleartext* password for the user # CREATE THE USER dscl . -create /Users/$username dscl . -create /Users/$username UserShell /bin/bash dscl . -create /Users/$username RealName $username dscl . -create /Users/$username UniqueID $uid dscl . -create /Users/$username PrimaryGroupID $gid dscl . -create /Users/$username NFSHomeDirectory /Users/$username dscl . -passwd /Users/$username $passwd # CREATE THE USER'S HOME DIRECTORY cp -R '/System/Library/User Template/English.lproj' /Users/$username # ENSURE OWNERSHIPS ASSIGNED TO USER'S ENTIRE HOME DIRECTORY chown -R ${uid}:${gid} /Users/$username |