OS X hacks 16-Nov-2015 4:42 PM
Edit FancyEdit New New Blog Upload All Recent Home Logout
TOP
>1.
Table Of Contents
  • 1. @@TOC@@

    Get the OS X version number from CLI

    Find out the OS X version number from the command line:

    Coarse:

    defaults read loginwindow SystemVersionStampAsString
    

    Fine:

    sw_vers
    sw_vers | grep ProductVersion | awk '{print $2}'
    

    Add spacers to the dock

    Add a space to the left side (apps)

    defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}'
    

    Add a space to the right side (docs)

    defaults write com.apple.dock persistent-others -array-add '{tile-data={}; tile-type="spacer-tile";}'
    

    Then, to make it take effect

    killall Dock
    

    Disable Spotlight

    From this hint (modified)

    • Mac OS X 10.5, 10.4
    1. disable spotlight auto-launching
      1. edit /etc/hostconfig
      2. change "SPOTLIGHT=-YES-" to "SPOTLIGHT=-NO-"
    2. turn off indexing and erase the index
      1. mdutil -i off /
      2. mdutil -E /
    • Mac OS X 10.6

      1. sudo mdutil -a -i off

    To turn it back on:

    1. mdutil -i on /
    2. In etc/hostconfig change the NO back to YES

    Next, eliminate it from the title bar:

    • Mac OS X 10.4

      1. sudo sh
      2. mv /System/Library/CoreServices/Search.bundle ~root
      3. exit
      4. reboot
    • Mac OS X 10.5

      1. sudo sh
      2. cd /System/Library/CoreServices
      3. mv Spotlight.app Spotlight_10.5.app
      4. killall Spotlight
    • Mac OS X 10.6

      1. sudo chmod 600 /System/Library/CoreServices/Search.bundle/Contents/MacOS/Search
      2. killall SystemUIServer

    SSD Tweaks

    1. Disable Sudden Motion Sensor

      sudo pmset -a sms 0
      
    2. Disable hibernate image

      sudo pmset -a hibernatemode 0
      sudo rm /private/var/vm/sleepimage
      
    3. noatime hack

    4. System Preferences - Energy Saver - don't put hard disks to sleep.

    Check some settings with: pmset -g


    Disable Dashboard

    1. turn on dashboard (F12) kill all running items
    2. in terminal: defaults write com.apple.dashboard mcx-disabled -boolean YES
    3. in terminal: killall Dock
    4. right click icon in dock, "remove from dock"

    Show full paths in finder window titles

        defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES
        killall Finder
    

    Smart album of 'unnamed' faces in iPhoto '09

    Create a smart album with the criteria:

    • Name
    • Does not contain
    • blank

    Pinning of the dock

    To pin the dock to the left/right/top/bottom instead of the center:

        defaults write com.apple.Dock pinning start ; killall Dock
    

    Valid pinning settings:

    • start
    • center (default)
    • end

    Search from bash

        goog() {
          open http://google.com/search?q=`echo $* | sed -e "s/ /%20/g"`
        }
    
        wik() {
          open http://en.wikipedia.org/wiki/`echo $* | sed -e "s/ /%20/g"`
        }
    

    Terminal window resize (bash-iTerm/Terminal script)

    #!/bin/sh
    echo ^[[8;50;150;t
    

    where "^[" is "escape". Backslashed semicolons are for shell escaping. This sets the terminal it is run in to be (rows,cols) to (50,150).


    iChat behind a WRT 54g firewall

    1. Find the IP address of the machine.
    2. Set the DMZ to be that IP address.
    3. Start iChat

    Perl CPAN

    Add modules to perl via cpan:

    sudo perl -MCPAN -e "shell"
    

    in your .bashrc:

    export FTP_PASSIVE=1
    

    then to install:

    install Net::Telnet 
    

    etc


    Sing a little song

    say -v bad news do you like cheese do you like cheese do you like cheese do you like cheese do you like cheese do you like cheese do you like cheese do you like cheese do you like cheese do you like cheese do you like cheese
    

    rescale an application's everything

    for everything:

    defaults write -g AppleDisplayScaleFactor 0.5
    

    for a specific app:

    defaults write com.apple.SystemPreferences AppleDisplayScaleFactor .5
    

    Move OS X's SSH port elsewhere

    from this page...

    in /etc/services:

    myNew-ssh   9999/tcp # new ssh port
    

    in /System/Library/LaunchDaemons/ssh.plist

    <key>SockServiceName</key>
    <string>myNew-ssh</string>
    

    Then restart "Remote Login" via Sharing preferences.


    iTunes 9 Zoom Button (+)

    Restore the "proper" behavior of the (+) button in iTunes 9.0.1 and higher to maximize the window, like every other app on OS X.

    defaults write com.apple.iTunes zoom-to-window -bool YES
    

    iTunes Stream Helpers

    One of the sites that I use to listen to mp3 streams, does not have their stream's names configured properly, so in iTunes, they all show up with the same name, or a self-similar enough name that it is impossible to tell which is which by just looking at them. Here's what I did to help differentiate them.

    1. Create a playlist for these. You can do a smart playlist (type contains "stream") or a manual playlist that you drop the streams into. Either way works fine.
    2. Put the streams into the playlist. (duh)
    3. cmd-j (ctrl-j) to bring up "View Options"
    4. [x] Episode ID, [OK] -- episode ID is not modified when playing a stream, like the Name or other fields which might change.
    5. Drag the "Episode ID" column in the playlist view over to be next to the "Name" column.
    6. Click in this field for each of the streams, and enter some descriptive text for this stream. "Background Music" or "Requests" etc.

    Now, you can just look at that column to know which stream link is which!


    create a Mavericks install disc

    Rather than complicated processes, Apple has provided a tool that lets you create a bootable install media. First, hfs-journaled format a 8+ gig USB disk, named /Volumes/Untitled, then run:

    sudo '/Applications/Install OS X Mavericks.app/Contents/Resources/createinstallmedia' --volume '/Volumes/Untitled' --applicationpath '/Applications/Install OS X Mavericks.app' --nointeraction
    

    Here's the OS X El Capitan version:

    sudo /Applications/Install OS X El Capitan.app/Contents/Resources/createinstallmedia --volume /Volumes/Untitled --applicationpath /Applications/Install OS X El Capitan.app --nointeraction
    

    It should look pretty similar. ;)


    Show a message on the OS X Lock/Login screen

    Go to preferences, select "Security and Privacy". Unlock padlock in the bottom left. On the General tab, tick the "Show a message when the screen is locked" item, and set the lock message. Use "Option-Enter" to do multiline items.<

Get the OS X version number from CLI

Find out the OS X version number from the command line:

Coarse:

defaults read loginwindow SystemVersionStampAsString

Fine:

sw_vers
sw_vers | grep ProductVersion | awk '{print $2}'

Add spacers to the dock

Add a space to the left side (apps)

defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}'

Add a space to the right side (docs)

defaults write com.apple.dock persistent-others -array-add '{tile-data={}; tile-type="spacer-tile";}'

Then, to make it take effect

killall Dock

Disable Spotlight

From this hint (modified)

  1. disable spotlight auto-launching
    1. edit /etc/hostconfig
    2. change "SPOTLIGHT=-YES-" to "SPOTLIGHT=-NO-"
  2. turn off indexing and erase the index
    1. mdutil -i off /
    2. mdutil -E /

To turn it back on:

  1. mdutil -i on /
  2. In etc/hostconfig change the NO back to YES

Next, eliminate it from the title bar:


SSD Tweaks

  1. Disable Sudden Motion Sensor

    sudo pmset -a sms 0
    
  2. Disable hibernate image

    sudo pmset -a hibernatemode 0
    sudo rm /private/var/vm/sleepimage
    
  3. noatime hack

  4. System Preferences - Energy Saver - don't put hard disks to sleep.

Check some settings with: pmset -g


Disable Dashboard

  1. turn on dashboard (F12) kill all running items
  2. in terminal: defaults write com.apple.dashboard mcx-disabled -boolean YES
  3. in terminal: killall Dock
  4. right click icon in dock, "remove from dock"

Show full paths in finder window titles

    defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES
    killall Finder

Smart album of 'unnamed' faces in iPhoto '09

Create a smart album with the criteria:


Pinning of the dock

To pin the dock to the left/right/top/bottom instead of the center:

    defaults write com.apple.Dock pinning start ; killall Dock

Valid pinning settings:


Search from bash

    goog() {
      open http://google.com/search?q=`echo $* | sed -e "s/ /%20/g"`
    }

    wik() {
      open http://en.wikipedia.org/wiki/`echo $* | sed -e "s/ /%20/g"`
    }

Terminal window resize (bash-iTerm/Terminal script)

#!/bin/sh
echo ^[[8;50;150;t

where "^[" is "escape". Backslashed semicolons are for shell escaping. This sets the terminal it is run in to be (rows,cols) to (50,150).


iChat behind a WRT 54g firewall

  1. Find the IP address of the machine.
  2. Set the DMZ to be that IP address.
  3. Start iChat

Perl CPAN

Add modules to perl via cpan:

sudo perl -MCPAN -e "shell"

in your .bashrc:

export FTP_PASSIVE=1

then to install:

install Net::Telnet 

etc


Sing a little song

say -v bad news do you like cheese do you like cheese do you like cheese do you like cheese do you like cheese do you like cheese do you like cheese do you like cheese do you like cheese do you like cheese do you like cheese

rescale an application's everything

for everything:

defaults write -g AppleDisplayScaleFactor 0.5

for a specific app:

defaults write com.apple.SystemPreferences AppleDisplayScaleFactor .5

Move OS X's SSH port elsewhere

from this page...

in /etc/services:

myNew-ssh   9999/tcp # new ssh port

in /System/Library/LaunchDaemons/ssh.plist

<key>SockServiceName</key>
<string>myNew-ssh</string>

Then restart "Remote Login" via Sharing preferences.


iTunes 9 Zoom Button (+)

Restore the "proper" behavior of the (+) button in iTunes 9.0.1 and higher to maximize the window, like every other app on OS X.

defaults write com.apple.iTunes zoom-to-window -bool YES

iTunes Stream Helpers

One of the sites that I use to listen to mp3 streams, does not have their stream's names configured properly, so in iTunes, they all show up with the same name, or a self-similar enough name that it is impossible to tell which is which by just looking at them. Here's what I did to help differentiate them.

  1. Create a playlist for these. You can do a smart playlist (type contains "stream") or a manual playlist that you drop the streams into. Either way works fine.
  2. Put the streams into the playlist. (duh)
  3. cmd-j (ctrl-j) to bring up "View Options"
  4. [x] Episode ID, [OK] -- episode ID is not modified when playing a stream, like the Name or other fields which might change.
  5. Drag the "Episode ID" column in the playlist view over to be next to the "Name" column.
  6. Click in this field for each of the streams, and enter some descriptive text for this stream. "Background Music" or "Requests" etc.

Now, you can just look at that column to know which stream link is which!


create a Mavericks install disc

Rather than complicated processes, Apple has provided a tool that lets you create a bootable install media. First, hfs-journaled format a 8+ gig USB disk, named /Volumes/Untitled, then run:

sudo '/Applications/Install OS X Mavericks.app/Contents/Resources/createinstallmedia' --volume '/Volumes/Untitled' --applicationpath '/Applications/Install OS X Mavericks.app' --nointeraction

Here's the OS X El Capitan version:

sudo /Applications/Install OS X El Capitan.app/Contents/Resources/createinstallmedia --volume /Volumes/Untitled --applicationpath /Applications/Install OS X El Capitan.app --nointeraction

It should look pretty similar. ;)


Show a message on the OS X Lock/Login screen

Go to preferences, select "Security and Privacy". Unlock padlock in the bottom left. On the General tab, tick the "Show a message when the screen is locked" item, and set the lock message. Use "Option-Enter" to do multiline items.<>