Lurker News
OSX Terminal: hold option and click a position in the current line to move your cursor to that position. #yearslost

Comments (395) 107 threads

Show all comments

Showing thread 2 of 107

adventureloop3 replies#
Another really useful command is the open

    $ open filename.png
    $ open .
    $ open -e filename.txt
    $ open -a Pixen filename.png
The first command will open the file with the default application.

Open . will open the current directory in finder, which I find very helpful.
The -e flag will open the file in textedit.
The -a will open the file in the given application name.

panzi2 replies#
Under Linux there is a similar command: xdg-open
richardwhiuk2 replies#
or gnome-open.

On Windows the equivalent is start (e.g. start C:\ )

Someone1 reply#
I use start all the time, but also frequently curse at its stupid argument grammar and its interaction with auto-quoting on auto-completion. For example, type

  start C:\Doc
Next, hit tab to get

  start "C:\Documents and Settings"
Now, hit return, and watch a new command window open with title "C:\Documents and Settings".

Reason? If the first argument is a quoted string, it is used as the title of the window being opened (http://www.microsoft.com/resources/documentation/windows/xp/..., http://stackoverflow.com/questions/154075/using-the-dos-star...)
If you ever use start in batch scripts, pass a dummy first argument of ""

Continue this thread — 1 reply

panzi#
I think xdg-open defers to gnome-open/kde-open/... depending on what DE is currently running. Not sure about that. Anyway, xdg-open should be installed anywhere where any kind of DE is installed.
jlgaddis#
For the lazy:

  $ echo "alias o='xdg-open'" >> ~/.bashrc
LinaLauneBaer2 replies#
open -n is also useful: Allows you to run two instances of the same app at a time.
jballanc#
Try "open -h NSString.h"...
cooper12#
Thank you for this! It always frustrated me that I couldn't open multiple videos at once in VLC.
micampe1 reply#
Also very useful for similar use cases is qlmanage.

    $ qlmanage -p
mjs3 replies#
This seems to run whatever code usually runs when you hit [space] on a filename in a Finder window. (Except that it outputs a bunch of debugging information.) Under what circumstances is that any better or more useful than "open"?
lexy0202#
Because it essentially acts like quick look for the terminal.
micampe#
Correct (man 1 qlmanage). Depending on the type of file, it is usually faster to open quicklook than opening the file in its default application, especially if you just want to take a look and you don’t actually need to edit the file.
cooper12#
You can hide the debugging info by redirecting the output streams.

    $ qlmanage -p  &>/dev/null