Today I Learned

8 posts about #osx

All the different ways to lock your Mac computer

  • Using the keyboard: CTRL-SHIFT-eject
  • Using Alfred: execute the lock command
  • Using a taskbar icon from Keychain:
    • Open the app Keychain Access
    • Preferences --> Enable the option Show keychain status in menu bar
    • A lock-shaped icon will appear in the taskbar, with the option Lock Screen
  • Use Hot Corners:
    • System Preferences --> Desktop & Screen Saver --> Hot Corners button
    • Set one of the corners as Put Display to Sleep
    • Mouse into the direction of that corner (on the monitor closest to that side, for multi-monitor setups)
  • If all else fails, just hold the Power button on your keyboard for a second to put your computer to sleep

Record File Handle Usage in OSX

lsof is a helpful tool for looking at what files a process currently has open, however sometimes a process may only access a file for a second and lsof may miss the moment.

For OSX we also have Instruments. This is included with XCode and is pretty straight forward to use:

  • Open Instruments
  • Select File Activity
  • Select the process
  • Hit Record
  • Perform your action
  • Stop Recording

You can also save the log for later analysis.

Hotkey to switch control mode in Mac Screen Share

I use MacOS screen sharing to power pair programming sessions that I have in my development team. There are two modes for the navigator to use when observing the driver's screen (assuming that the screen being shared is of the driver): Observe Mode to disallow taking control of the screen, or a self-explanatory Control Mode.

I like being in Observe Mode as the navigator so that I don't mistakingly take control of the driver's screen and start polluting the screen with accidental key strokes. But if I ever need to switch control, I would have to then make a mouse click on the correct icon. This gets annoying if I am observing in Full Screen mode (which is almost always). I would have to exit full screen mode first in order to switch to taking control.

SOLUTION: I can instead use the CMD-ALT-X key combination to quickly switch control mode :D

Unicode Entry on Mac OSX

If you have the code point of a Unicode character, it is possible to enter these characters into (almost) any program on Mac OSX, by first jumping through a few hoops:

  • Open Language & Region.
  • At the bottom right, open Keyboard Preferences...
  • Click the plus sign at the bottom left to add a new Input Source.
  • Under the Others category, select the Unicode Hex Input source.
  • Check the Show Input menu in menu bar option.

You should now see a country flag in your menu bar, which will allow you to switch between different Input Sources (e.g. Canadian English, U.S, Unicode Hex Input). Whenever you want to enter Unicode characters, switch to the Unicode Hex Input source.

Now, you can hold down ⌥ (Option/Alt) and enter your code point to type Unicode characters. For instance, the ⌥ character has code point 2325 and can be entered by holding Option and entering 2325.

Disabling emdash substitutions in OSX apps

Problem

I use the slack app on my Mac, but it keeps replacing double dashes with an emdash.

e.g. --stat becomes —stat

Solution

In the slack app (and many other apps I presume?), right-click the field that has the problem, and turn off this option:

Substitutions -> Smart Dashes

Open a Mingle ticket via Alfred

Open Alfred Preferences -> Features -> Web Search -> Add Custom Search

Usage: Open Alfred search, type mingle 9800

iTerm2 Window Arrangements

Motivation

Over the course of development on a project, there are many common jobs that one may run on a daily basis, such as:

  • Starting a Rails app and watching a log tail
  • Running a Zeus server and monitoring its status
  • Monitoring RSpec output
  • Keeping an IRB session open for quick experiments

I like to have a consistent workspace and layout that I can assume is readily available, as opposed to hunting down multiple terminal windows on my desktop. iTerm2 happens to provide a built-in mechanism for preserving workspaces and layouts.

Solution

Once you have all of your iTerm2 panes, windows, and tabs arranged to your liking, you can hit ⌘⇧s (Command-Shift-S) to Save and name your arrangement.

The next time you start iTerm2, you can Restore your saved layout by pressing ⌘⇧r (Command-Shift-R).

Toggle Do Not Disturb

Option-click the Notification Menu icon to toggle OS X notifications. The icon is most likely in the top right hand corner of your menu bar.