OSX Tips and Tricks

Well, it’s official – I’ve been working on the new project, Truvay. I think it’s going to be an awesomely useful site. As part of my contract, I get the opportunity to write a blog post on Carsonified.com every week. So I figure I might as well use this first week to raid for twitter followers spread the awesome give you guys some handy OSX hints that I’ve picked up along the way. Hopefully there’ll be some you don’t know. What’s that? You’re on a PC? Well, that’s a shame. How sad, too bad.

I’m sick of the lists that say “prioritize your tasks by due date” and “give yourself a break every 15 minutes”. They’re great, and they offer great advice, but everybody who has a blog has written one. They’re safe and easy, and they’re tips you can’t really argue with. Where’s the value? So this week, I’m focussing on some really geeky tips. There’s a good chance you’ll know some of them. If some of them are a bit over your head, please feel free to skip them. But if I’m wrong about anything, let me know. I’d rather look like a fool than have you guys get the wrong info. I’m not going to just write some generic list of boring safe tips so I can’t get in trouble – these are real tips that I use. If they break your computer, you’ll have to fix it, but you should have backed up. On that note:

TIP ZERO IS BACK EVERYTHING UP ALL THE TIME. Yeah, this one should go without saying. I use Time Machine. If you’re not backing everything up, you’ll be afraid to make any mistakes – and if you’re afraid to make any mistakes, you won’t learn anything. So give yourself plenty of leeway by backing your stuff up. Then back up your backups until it makes you recurse.
1) Speed up SSH connection startup time:
Put this text into a file called ~/.ssh/config

Host *
ControlMaster auto
ControlPath ~/.ssh/master-%r@%h:%p

It’ll speed up multiple SSH connections to the same host by using the same TCP/IP connection. This should save you a bit of hassle. 2) If you have Python installed, which you should, add this text to your ~/.bash_profile file (or ~/.bashrc file on Linux):

alias webshare='python -c "import SimpleHTTPServer;SimpleHTTPServer.test()"'

Then, when you’re in a directory in the terminal, simply type “webshare” and hit enter, and your files will be available at your.ip.here:8000 – perfect for quickly sharing files over a network. But remember not to leave this running.
My Shared folder example

2.5) You can add this code to your .bash_profile as well, to highlight Git folders and branches in your command line prompt like in my example. It shows who you’re logged in as, the computer name, what folder you’re in, and what Git branch you’re in – if you’re using Git. Nice and useful. Like this: Whoa! Is that Truvay? Whoa, is that Truvay!? Anyway, if you’re not using Git yet, you will be soon. Just stay tuned to this Carsoni-channel, at roughly this Carsoni-time…

3) Hold down CMD and click to interact with background windows in OSX. You can click buttons, highlight text, drag, close, minimize, maximize… lots of things. While it sounds like a gimmick, this is actually surprisingly useful. However, watch out for the text, because apple-clicking the text in the window’s title bar is also a shortcut for the next tip…

4) Selecting a directory on the path you’re in. Safari and Finder enable this – right-, ctrl- or cmd-click on the text in the title bar of a window, and it gives you a drop-down list of the parent directories. In Safari, this means the parent folder of the current page. You can then quickly and easily navigate to a parent or grandparent folder. 5) Dragging widgets off the dashboard: As a precursor, use these useful widgets:

  • iStat Pro (for watching how hot your computer gets)
  • Transmit drop zone widget (for drag and drop FTP goodness)
  • Uptime (so you can brag to PC users about how you never have to restart)

Then, once you’re in the dashboard, click and drag a widget, and then while still dragging, hit the dashboard button. Voila, a widget on your desktop. It’s just like using Vista! Come back next week for a list of awesome widgets.

Tumblr on your desktop

6) Get the MultiClutch preference pane to enable multi-finger gestures on Leopard. It’s awesome – I use three finger swipes: Swipe Up for CMD-N, Swipe Down for CMD-W, and left and right for next/previous tab. The settings can be changed per-application, too, since not all programs use the same options. Adium uses CMD+left/right for switching chat tabs, for instance. If I could export them for you, I would have. But I can’t, so I didn’t.

6.5) In case you noticed my awesome time format in my menu bar – you can do that too! It just takes a little bit of copy-and-paste-fu. The instructions are a little verbose for here – but there’s a good example here.
7) Exposé and then Spaces: Hit your Exposé shortcut key (F8 by default), and then hit your spaces key. All your applications are shown exposé style (read: they’re all visible) but under Spaces. They resize themselves when you drag them around. Pro tip: if you hold down CMD, all the windows for an application will drag together.

Whoa! Expose AND Spaces together!

8) Shortcut keys:

Finder:
Ctrl-scroll – zoom in and out
Ctrl-alt-CMD-8 – crazy backwards inverse screen mode
CMD-option-H – hide all other applications
Ctrl-shift-eject – turn the screen off

File Browser Prompt:
CMD-D – go to the desktop folder
CMD-H – go to the home folder

Text:
Ctrl-E – end of line
Ctrl-A – start of line
Option-right – end of current or next word
Option-left – beginning of current or previous word

Safari:
CMD-L : current address
CMD-option-F: highlight the search bar
CMD-option-W : close all other tabs

These are just some of the ones I use every day. There’s loads more of them, and they’re really useful to know – being able to do tricky little things with the finder is surprisingly useful.

9) You’ll need Spark to help you create these next few shortcuts. Spark is a fantastic hotkey-mapping program for OSX, which comes with a cool and powerful language called AppleScript. You can use this to do loads of cool things – including running shell scripts! That’s what we’re going to use it for. Go check it out – make some shortcuts for apps and folders and stuff, and come back. Don’t worry, I’ll wait.

10) TinyURL shortcut key: use this Applescript in Spark to create a TinyURL from your current selection. Hit CMD-1 to create a new Applescript script:

Applescript prompt in Spark

And in that textarea, ignoring the awful formatting, put this:

set the ClipURL to (the clipboard as string)

ignoring case
if ((characters 1 through 4 of ClipURL as string) is not "http") then
return "Malformed URL."
else
set curlCMD to ¬
"curl --stderr /dev/null "http://tinyurl.com/api-create.php?url=" & ClipURL & """

-- Run the script and get the result:
set tinyURL to (do shell script curlCMD)
set the clipboard to (tinyURL as string)
return tinyURL
end if
end ignoring

Assign a shortcut key (I use CMD-option-T) and now, when you copy a URL, you can hit CMD-option-T and have a tinyURL instead. Magic!

11) In Spark, Use this applescript to restart apache as an administrator:

do shell script "apachectl graceful" with administrator privileges

Now you’re on the way to automating anything you do in the command line. Git? Rsync? Twitter? dscacheutil -flushcache? Whatever you like. Just be sure to use them loads so they stay stuck in your mind. Plus, if you use all the modifier keys, Shift Control Option and Command at the same time, you’re less likely to override an existing shortcut – plus it’s easy to remember since you’re just mashing them all at once. I use Shift-Control-Option-Command-A to reload Apache, and Shift-Control-Option-Command-R (for restart) to restart Passenger. Sounds way harder than it is. Remember – if computers were heavy metal, keyboard shortcuts would be power chords.

12) Use Lingon to manage your cron jobs. OSX makes running startup scripts difficult – they’re in .plist files, which are a bit tricky to read. Lingon makes this super-easy, so you can run tasks whenever a file is modified, or if anything is placed into a folder, or at a certain time of day… you can even make the task keep running “no matter what happens.” I’m not sure what that means, exactly. I’d like to see the Armageddon edge-case scenario. Anyway, if I had a dedicated computer for work, or if I ever got to the office on time, I’d make a script that started up all my programs for me before I got to work, so at 9am I could sit down to a fully prepared and ready computer with all my apps open.

13) Use DropBox for your Firefox profile folder. This means that your profile folder is backed up to the clouds and you can use your profile from several computers. I haven’t used this much, since I use Safari, but it worked just fine when I was using Firefox. I don’t recommend this if you don’t know what you’re doing, and I don’t take any responsibility if you somehow break your machine. However, once you’ve backed everything up – please don’t break your computer, use this command:

"cd ~/Library/Application Support/Firefox/ && mv Profiles ~/Dropbox/ && ln -s ~/Dropbox/Profiles ."

(via me) and your profile will be backed up onto your dropbox. This is great if you have two computers.So that’s all for this week, ladies – catch me the same time next week or add me on twitter for more cool stuff. Let me know if you have any more tips, or suggestions for my tips, and I’ll include them. I rocked out to Boston, Manowar, ZZ Top and Ozzy while I wrote this post.

Tweet me what I should write about next wee: Awesome OSX Apps, How Much Deadlines Suck, Rails Tips, or Hair Metal.

Guitarist image via Stuart Brown / CC BY-NC-SA 2.0.

Free Workshops

Watch one of our expert, full-length teaching videos. Choose from HTML, CSS or WordPress.

Start Learning

Comments

0 comments on “OSX Tips and Tricks

  1. Elliott I understand very little in this post but its good to see you on the Carsonified blog.

  2. Some awesome tips! I’m constantly blown away by the power of OS X.

    A little tip of my own – you can write scripts to do stuff in whatever language you like (*cough* Ruby) and then execute them on a shortcut key – giving you an infinite amount of power.

  3. Nice list of tips! Definitely some to take away.

    Curious… what’s the code for the purple-like colour from your screenshot (the “~/Sites/truvay” text)? I haven’t had any luck finding the ANSI code for it.

  4. Hey Frank, I’m not exactly sure – but I think it’s [33[01;34m] – from what I recall, the 01 in the 01:34m means it’s light, as opposed to dark. which is 0:34m.

  5. Hey Frank, I’m not exactly sure – but I think it’s [33[01;34m] – from what I recall, the 01 in the 01:34m means it’s light, as opposed to dark. which is 0:34m.

  6. Awesome tips! One useful keyboard shortcut I always set up in FastScripts (an alternative to Spark – which I didn’t know about before) is to show the home folder from *anywhere*. That way, you can navigate your file system very rapidly.. just hit your key combo and bam, another Finder window is open and ready to go. Couple that with Spotlight to launch apps and I haven’t used the dock in months.

  7. Hi Elliott,

    Great OSX tips. I was wondering…would it be possible to setup a tutorial on how to work on Webpages using a Mac. Things like setting up PHP, Virtual Host, where to save your sites…etc. I would love to desgin my sites locally and test locally with out any missing images, then have no problem posting them to the server.

    I see that you store all your sites in /Sites/. I would like to preview my page on a local URL. Any thoughts/suggestions?

    Thank you,
    Michael

  8. Great post. Much better than your average OS X tips post.

    Once of my personal favourite tips is to un-minimise a window using only the keyboard. If you Cmd-Tab to an open but minimised app, it won’t un-minimise. BUT, if you continue to hold Cmd and press Opt before then releasing Cmd, the window pops up.

    Sounds tricky but it’s second nature once you get used to it.

  9. I am also interested in Michael’s comment — where to save things on a Mac. The ~/Sites folder seems like a logical place, but may require some customization. I work with Flash, PHP, and other languages so things get a bit cluttered.

  10. Dave and Michael, your best bet is to use MAMP. I used MAMP Pro for quite a while, and it provides an easy way to set up Apache and MySQL. If you don’t need or want to tinker with Apache, it’s a good piece of starting kit. However, later if you do need to edit the config files, you’ll find it quite tricky. At that point, you may want to consider moving to the built-in Apache. Long story short, it’ll do for now.

    Tim: That’s awesome! I didn’t know that one – I’ll be using it.

    Jamie: That’s a good point too – you can use Spark, or a cron job, to run any script you like.

  11. Pingback: OS X Tips and Tricks

  12. I just love #1, it’s like POWER directly in my term !

    BTW, if you want to pimp your Terminal.app just a bit more :
    This
    helps you change the default ANSI colors of the terminal.

    Mine looks just like the TextMate theme “Blackboard” now ;)

    Cheers !

  13. Elliott, thanks for the excellent post – love the multi-clutch tip.

    Tim, your un-minimize thing is a killer! Anything that leads to fewer mouse clicks is a plus, and this is an especially good one.

    Thanks to both of you.

  14. If any rubyists are hankering for a solution to #2, I just wrote the quickshare gem to do the job.

    As an added bonus it broadcasts the presence of the service over bonjour to save you having to remember hostnames, ports, etc.

  15. Fantastic Elliott, really appreciated. Didn’t know about dragging widgets but now I come to try the magic doesn’t happen for me. Do you have something else running/enabled to allow this to work. I was also really interested in Multiclutch, would I be right in thinking this only works with the new trackpads??

  16. Pascal: Any recent multi-touch trackpad will do it. The best part is, Apple have been quietly releasing multi-touch trackpads for a while. I bought my macbook pro in about February, and it works perfectly.

  17. Hi Elliott,

    Thanks for your answer. Are there any tutorial sites/examples out there on setting your work station. I need things like PHP, Apache, MySql. I have already setup most of this here and there. Now I can’t PHP to work. When I go to local/mysite/default.php…nothing happens…page will not display.

    Thoughts/suggestions?

    Thanks in advance!

    Michael

  18. Pingback: Delicious Bookmarks (2009-02-04 - 2009-02-07) | Quixotic Bravado by Josh Babetski

  19. Pingback: ZenLinuxNH Blog » Blog Archive » Killer SSH Tip