macosx

Which Terminal App am I Using?

Snippet

macosx has full disk permissions limiting access to certain directories and files. If one app, say iTerm has access but another program does not, say xterm, a bash script might need to check which application can be run with the appropriate permissions.

Look for TERM_PROGRAM

$ echo $TERM_PROGRAM
iTerm.app
 
$ env | grep TERM_
TERM_PROGRAM=iTerm.app
TERM_PROGRAM_VERSION=3.3.12
 
# or in a script
if [[ $TERM_PROGRAM != 'iTerm.app' ]]; then
  echo "You need to run this with iTerm for full disk permissions"
  exit
fi

Open Spotlight Results in Finder

Snippet

Because sometimes when you look for something in Finder, you want to SEE where it is, you don't want to actually open it.

In the results, down arrow until the result desired is highlighted, then Command-Enter to open Finder with the directory and file.

Find files of a particular type in Finder

Snippet

You sorta know the name of the file, and definitely know the file type, but can't seem to get Finder to return any result except mail messages, use kind:

See also, finding files of a particular type in a web search.

kitt logo kind:png 

Delete URLs from Chrome Autocomplete on OSX/macOS

Snippet

On OSX/macosx, it isn't Shift-Delete on a laptop keyboard like all the docs say.

fn + shift + delete

Play audio file at faster than 1x speed

Snippet

Sometimes you want to play a local audio file back faster than 1x speed. Can do!

In Finder, right click on the file, click Open With, then select QuickTime Player.app

option + click-on-fast-forward-button. This will increase playback by 0.1x each time.
option + right-arrow. This one increases from 1x to 2x to 5x.

Option + FF

Use Command as Meta for Emacs on OSX

Snippet

Emacs 23 doesn't use Command ⌘ for the Meta keystroke, requiring using option / alt for the normal keystrokes. Blech. Fix that.

This rather assumes you're using the emacs from http://emacsformacosx.com.

Add this to your ~/.emacs

    (setq mac-option-key-is-meta nil)
    (setq mac-command-key-is-meta t)
    (setq mac-command-modifier 'meta)
    (setq mac-option-modifier nil)

Remove extended attributes of OSX files

Snippet

Remove extended attributes of mac OSX files

# Use the xattr command. You can inspect the extended attributes:
 
$ xattr s.7z
com.apple.metadata:kMDItemWhereFroms
com.apple.quarantine
 
# and use the -d option to delete one extended attribute:
 
$ xattr -d com.apple.quarantine s.7z
$ xattr s.7z
com.apple.metadata:kMDItemWhereFroms
 
# you can also use the -c option to remove all extended attributes:
 
$ xattr -c s.7z
$ xattr s.7z
 
# xattr -h will show you the command line options, and xattr has a man page.

OmniOutliner Pro keyboard shortcut disable

Blog

After who knows how many tries, fits and stops, I finally have what I consider a working unix laptop with my shiny MBP. I like it a lot, as I slowly force it to submit to my will (read: works the way I started working when I was on an SGI IRIX box ten years ago).

Emacs and the terminal window were the two hardest parts to get right. I become very cranky if a system I'm using doesn't have emacs on it (try as I might to switch to vi/vim/gvim at Andy's suggestion and with his help). I become even more cranky if I have to use a mouse on a regular basis to navigate amongst windows: splat-tab is fine, I can even use splat-tilde to navigate through windows of the same application. But force me to use a mouse exclusively to change applications and watch the laptop fly through the air and most likely out the window.

So, when the new install of OmniOutliner Pro overwrote one of my frequently used emacs keystrokes (splat-greater than, or splat-shift-period, which sends the cursor to the bottom of the editing buffer/window or the end of the document in Word speak), I became very, very cranky.

Turns out splat (or flower, or apple, or command, it's all the same key on an Apple keyboard) > is the OmniOutliner Pro Service call to "Add to clippings," essentially copying the system clipboard to an outliner. If OmniOutliner Pro, eh, screw that name, if OOP is installed, this service is installed, and it can't be modified, can't be disabled via the OOP application.

And won't send the keystrokes to emacs.

Fortunately, on the OOP forums, another person had a different OOP service that frustrated him, and Troy B of Omni pointed him to ServiceScrubber, another app that will overwrite the keystroke overwrite.

Download, double-click, double-click, drag, splat-space, s e r *return*, scroll, uncheck, splat-s, splat-q and I'm back in business.

As uncomfortable as I am about installing small random applications on my computer, the mac part not-withstanding, this and DoubleCommand, which Doyle found for me, are the two tiny apps I'm glad I have on my system. I'm very happy other people are scratching those itches and a few dollars via paypal means they're scratching my itch, too.