by Oliver; Dec. 9, 2014
Hear ye! Hear ye! Tips for Macintosh computing.
Use Hot Corners and Keyboard ShortcutsTurn on Hot Corners in:
System Preferences > Mission ControlI like to use:
Use keyboard shortcuts via:
System Preferences > Keyboard > ShortcutsIn particular, I like to map Option left to "Move left a space" and Option right to move right:
Require a Password to Wake Your Mac from SleepThis is a good policy to ensure people don't tamper with your computer if you leave it idle. Go to:
System Preferences > Security & PrivacyAnd require a password a few minutes after sleep or screen saver begins.
Install iTerm2iTerm2 improves on the ordinary terminal and makes it easy to set up key-bindings for shortcuts. In particular, I like to map Control left to jump word left and Control right to jump word right. To do this, check your terminal preferences to see how it treats Control left and Control right:
Here, it's Esc [5C and Esc [5D so executing:
# make cursor jump over words bind '"\e[5C": forward-word' # control+arrow_right bind '"\e[5D": backward-word' # control+arrow_leftin the shell will accomplish this. On OS 10.9.5, it seems to be slightly different:
bind '"\e[1;[5C": forward-word' # control+arrow_right bind '"\e[1;[5D": backward-word' # control+arrow_leftIn any case, check your terminal preferences and proceed accordingly. For a more thorough explanation, read about keyboard shortcuts, readline functions, and key bindings here.
Install brewbrew calls itself, "The missing package manager for OS X" and that's about right. Download brew to install things with ease from the command line (it's far superior to its rival, macports). As the homepage notes, here's how to get it:
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Install wgetwget downloads stuff from the web via the command line. Get it with brew:
$ brew install wget
Install pippip is the python package manager. Follow the instructions and first download get-pip.py:
$ wget https://bootstrap.pypa.io/get-pip.pyThen install it:
$ sudo python get-pip.py
Install the Command Line Developer ToolsAt some point in the recent past, Apple decided to become authoritarian and horrible and stopped including basic tools, like gcc, with Macintosh. To get the so-called command line developer tools, I remember having to formally register as a developer with Apple—as if I were a sex offender in a school zone! They came bundled with Xcode. This blog post describes various ways you can get your hands on the developer tools. If your OS is up to date, it should prompt you to download them when you install brew.
Install the GNU CoreutilsThe GNU Coreutils are the lifeblood of the command line. Macintosh has its own version of them but, annoyingly, many of the commands behave differently (e.g., readlink) or don't exist (e.g., seq). So don't mess around and get the GNU ones posthaste. The easiest way to get them is with brew:
$ brew install coreutilsRead more about putting the coreutils on a Mac.
Install tmuxtmux is an awesome terminal multiplexer, which is superior to the built-in GNU screen utility. If you're using tmux and you accidentally quit or close your terminal, you'll be able to reaccess your specific terminal sessions and programs you were running won't have aborted. That's because tmux has accomplished the neat trick of decoupling your command line sessions from a specific running instance of your shell. Download it with brew:
$ brew install tmuxRead more about how to use tmux, as well as how to set up your tmux.conf configuration file, here.
Set up your .bash_profile, .bashrc, and Other DotfilesTo set up your dotfiles, clone mine via GitHub. You can read more about the subject of dotfiles here. One note: on Macintosh, when you open up a new shell, this happens automatically:
$ source ~/.bash_profileTo underline this point, your .bash_profile, not your .bashrc, gets sourced.
Generate ssh KeysIf you're planning to ssh, you'll want to generate ssh keys:
$ cd ~/.ssh $ ssh-keygen -t rsaRead more about the process here.
Install VLCVLC is a great, free video player. Read about all its cool features:
10 Useful Features Hidden in VLC, The Swiss Army Knife of Media Players
25 things you can do with VLC Media player!
Install youtube-dlEver wanted to download a YouTube video? youtube-dl makes it easy. Again, you can get it with brew:
$ brew install youtube-dl
Install ImagemagickImagemagick is an awesome tool suite for manipulating images, in all sorts of ways, from the command line. Get it with brew:
$ brew install imagemagickRead my guide to simple Imagemagick commands.
Download TorData collection is big business nowadays. Every company wants to know exactly who you are and exactly what you're doing on the internet. Advertisers pay for databases rich with granular information about people's habits, political views, shopping tendencies, dating profiles, etc. Using Tor, an open source IP anonymizer, can help thwart this. As Tor's homepage says, "Tor is NOT all you need to browse anonymously! You may need to change some of your browsing habits to ensure your identity stays stafe." Tor doesn't support some things—for example, as of this writing, you can't watch most video (including YouTube) on Tor. To state the obvious, most services that require a user account are out of bounds with Tor and Gmail simply won't allow it—seeming to say, No free email if you don't tell us your IP.
Read about Tor on Wikipedia.
ssh into Your MacTo ssh into your Mac, go to:
System Preferences > Sharingand turn on Remote Login:
copy the ssh address, as it's given in the window (I've censored mine). A word of caution: ssh is safe, but I wouldn't leave this option on, unless you have a good reason.
Tip: If you turn on Remote Login, you can copy files onto your Mac directly over the internet, sans hard drive, with rsync.
What to Do if The Dock, Spaces, The Finder, or Another Program CrashesYou can force quit a program, by invoking Command-Option-Esc. As this page instructs, if the Dock or Spaces fritzes out, try:
$ killall -KILL DockIf the Finder crashes:
$ killall -KILL FinderIf the menubar crashes:
$ killall -KILL SystemUIServer
How to Retrieve Passwords Saved on Your ComputerSuppose you forgot the password to an email account, but you know it's saved in Chrome. How would you retrieve it? Go to:
Applications > Utilities > Keychain AccessFind the service corresponding to your password, click on it, and then check Show Password. You'll need to type in your Mac's account password to see it.
Take a screenshotTo take a screenshot, press Command-Shift-3. You can also use the program Grab in the Utilities folder.
Video Screen Capture (i.e., Record Your Computer Screen)You can record your screen with QuickTime versions greater than 10. The steps are given in this post. To quote verbatim:
- In QuickTime Player, choose File > New Screen Recording.
- Choose options for the screen recording from the arrow pop-up menu.
- Arrange the computer windows as you want to capture them, and then click the Record button.
- To stop the recording, click the Stop button, or press Command-Control-Escape.
Make Your Macintosh SpeakMacs come with a command line utility, say, that makes your computer speak:
$ say "hello world"(ideal for ordering co-workers around:)
You can also read a whole file. Suppose the file juicy.txt is:
It was all a dream I used to read Word Up magazine Salt'n'Pepa and Heavy D up in the limousine Hangin' pictures on my wall Every Saturday Rap Attack, Mr. Magic, Marley Marl I let my tape rock 'til my tape pop Smokin' weed and bamboo, sippin' on private stock Way back, when I had the red and black lumberjack With the hat to matchThen:
$ say -f juicy.txt --progress -r 400 -v "Fred"specifies we want the voice "Fred" to read it at 400 words per minute.
Listen to Thousands of Channels on Free Internet RadioThere are thousands of free radio stations at your fingertips in iTunes. Simply navigate to the Internet Radio section:
Make Files or Folders InvisibleAnother Mac-specific command line utility is SetFile, which is used for setting file attributes. One neat thing you can do with this is to make files invisible in the GUI:
$ SetFile -a V myfile # make myfile invisible in the GUI $ SetFile -a v myfile # make myfile visible in the GUI
Encrypt a Folder on Your MacThere's a nice tutorial on how to encrypt your folder as a disk image here. To summarize, open the program:
Applications > Utilities > Disk UtilityNavigate via menu to:
File > New > Disk Image from FolderChoose the folder you want to encrypt and select the options:
- Image Format: read/write
- Encryption: 256-bit AES encryption
Make sure to uncheck the 'Remember password' box. Once the image has been created, throw away the original folder using 'Secure Empty Trash' or shred on the command line. Now you'll need a password everytime you try to mount your .dmg file (i.e., open the folder).
If you simply want to encrypt a text file, you can do that with the command line utility gpg, as I discuss here.
Check When Your Files Were Last Accessed; Check When Your Computer Was Last OnTo check when your files were last accessed in the GUI, open up a folder, click on the action wheel, and select:
Show View OptionsThat should pop up a window that looks like this:
Choose Date Last Opened and sort your files by that attribute. Alternately, on the command line you can use the utility mdls:
$ mdls myfile.txtwhich "lists the metadata attributes for the specified file". If the metadata contains a field like ItemLastUsedDate, you have your answer. Files traditionally have 3 time stamps stored in the metadata: the last access date, the last modify date, and the birth date. Another way to get at this information is with the unix utility stat:
$ stat myfile.txtI'm not an expert on these commands, but by playing with them a bit I've found that the mdls access time stamp does not get updated if you access the file on the command line (say, with cat), and only reflects file access from the GUI. In contrast, the stat access time reflects command line activity.
One way to see when your computer's been on—and sometimes to glean information about what programs have been run—is to examine the system logs:
$ syslog | lessYou can see more log files in the path: