I used iTerm for some time and switched now back to the Terminal.app again. One nice feature about iTerm is that double clicking on text does not select the word under the cursor, but rather the pathname.

I miss this feature and I googled a bit to find out if/how I can select pathnames (without selecting it by hand) in Terminal.app. The only tip I found was Terminal.app: Selecting Pathnames. This suggests to use holding the option key while double clicking. Unfortunately, this does not work for me (on Snow Leopard).

So how do I select pathnames instead of words in Terminal.app on Snow Leopard?


After some more googling I finally found the answer to my own question: in Leopard and Snow Leopard, you have to Command+Shift+Double Click. This has the following behaviour:

  • If the text at the mouse position is an URL, open it.
  • Otherwise select it as an pathname

See also Apple Discussions and Mac OS X Hints.

| improve this answer | |
  • For those who read as badly as I do: it's not just an additional Shift, but also Command rather than Option... – Arjan Sep 22 '09 at 22:20

Not a direct answer to your question as it's already been answered, but I'm betting you're selecting a path so that you can copy it and paste it somewhere else. There are a couple of commands/keystrokes that are worth knowing about so you can avoid touching your mouse (and slowing things down in the terminal).

The first is the "pbcopy" command. Anything piped to it will be put in your clipboard, so if you want to have the current working directory in your clipboard, you can use:

pwd | pbcopy

I've got this aliased to cpwd in my zshrc:

alias cpwd='pwd | pbcopy'

Another is that I often want the last argument to the last command so that I can do something with it again, pressing "opt-." (or esc-. if you haven't selected preferences->keyboard->use option as meta key) will automatically put the last arg for the previous command at the cursor location.

I use this all the time to operate on a file/directory, so if I just moved a file somewhere else, I can edit it like this:

mv /usr/local/foo /Users/tnaleid/bar

Typing "vi " and then hitting opt-. will put this on my command line so I can execute or edit to taste:

vi /Users/tnaleid/bar
| improve this answer | |
  • 2
    I wanted to vote -1, because this really has absolutely nothing to do with his question. But pbcopy is a great utility and this is otherwise a very helpful post I would normally vote +1, so I took no action... – Josh Sep 23 '09 at 0:44
  • yeah, I'm totally guessing at the OPs reason for wanting to select pathnames and I thought that many people who did a search on something like this might actually be wanting to do some of the stuff I have in my answer. Since there's already a great answer about how to do what the OP wanted, I didn't think it'd hurt to add this (thanks for not down voting :). – Ted Naleid Sep 23 '09 at 16:16

Last argument of the last command is !$

mv xyz /a/b/pqr

vi !$
| improve this answer | |
  • 1
    Didn't answer the question. – livibetter Nov 21 '12 at 3:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.