I’ve moved on from
ps aux | grep -i processname; kill PID. The Mac (along with many other Unix-likes) has two handy utilities:
pgrep does a case-insensitive search for processes matching the expression you provide, and returns all matching PIDs, one per line.
pkill does the same search, but just kills the matching processes instead of returning the PIDs.
A common use case for me is
middleman hanging when I change the
config.rb. I could kill it using the following:
kill `pgrep middleman`
One of the benefits of using
pkill is that you can run the command interactively. Handy if you end up searching on the scripting language running the process, rather than something a bit more unique.
Chrome has a terrific feature that lets you close all the tabs to the right of the current one. Very handy if you’ve opened a bunch of links from search results, found the one you want, and want to get rid of all the rest. Safari is a bit more limited; you can only close all but the current tab. You can get around that via Applescript.
First, make sure “Show Script menu in menu bar” is checked in the Applescript Editor preferences. Enter the following script into Applescript Editor, and save it to
tell window 1 of application "Safari"
close (tabs where index > (get index of current tab))
If you wanted to be able to assign a keyboard shortcut for this, you can turn the script into a service using ThisService, and assign the shortcut in the Keyboard Preferences Pane.
(via Ask Different)
Changing DNS servers isn’t something most people need to do frequently. When you do need to change them up, though, it takes too many clicks in System Preferences. Use
networksetup at the command line instead. For example, to change your DNS server to the OpenDNS servers, issue the following (if you’re using Ethernet):
sudo networksetup -setdnsservers Ethernet 18.104.22.168 22.214.171.124
To get a list of all the network services you could be using, run
If you make a lot of changes to your network throughout the day, it’s worth getting to know what
networksetup can do. And don’t forget that any command you can run in a shell can be incorporated into an AppleScript or Automator workflow with
do shell script.
There are a number of apps floating around that can strip rich text formatting from whatever you’ve copied to the pasteboard. I’m not sure why you’d need to buy an app for this. Here are two ways to get plain text.
⌘⌥⇧V – Paste and match style will give you plain text if you’re pasting into plain text. Otherwise you’ll get rich text that matches the formatting applied to wherever you’re pasting the text. I use this one a tonne in spreadsheets where I’m collecting information from web pages.
pbpaste | pbcopy – run this at the command prompt. It just pipes the pasteboard contents back into the pasteboard, but will remove all formatting as a result.
I currently have two large external drives with a number of partitions I’m using to clean up and organize my accumulated files. I only need to see those volumes when I’m actually doing the organization, and I definitely don’t want to see them when I’m running the App Store, as they really slow things down and result in a list of 45 applications that need updating. I decided to figure out how to keep them from showing up, and I’ll walk you through the process here. Continue reading