PDA

View Full Version : [ubuntu] CLI "open" (ala OSX)



iaw4
September 6th, 2012, 06:29 PM
(I am switching from OSX to ubuntu.)

under OSX, I can type in a Terminal "open file.xls" and file is opened by the desktop with the system app. is there an equivalent ubuntu 12.04 CLI command?

sisco311
September 6th, 2012, 06:33 PM
xdg-open or gnome-open

iaw4
September 19th, 2012, 05:13 PM
is there an easy way to also specify the application?

open -a "Emacs" hello.html

(the advantage is that the errors and warnings don't go to the terminal, and an accidental C-C on the launch terminal won't abort the program.)

/iaw

vexorian
September 19th, 2012, 05:36 PM
well, if what you want is not to let closing the terminal kill the app then you can use disown



emacs hello.html & disown


If you want to disable messages, then you can redirect output to /dev/null


emacs hello.html 1> /dev/null 2> /dev/null

Combining them you got:


emacs hello.html 1> /dev/null 2> /dev/null & disown

Which is awful, but you can turn it into a .sh script:



#!/bin/sh
$@ 1> /dev/null 2> /dev/null & disown
[/code]

Then just run it:
scriptname.sh emacs file.html

iaw4
September 21st, 2012, 05:40 PM
thanks for the help. I went with defining this special for emacs, and using a bash function in .bashrc:

function emacs() { /usr/bin/emacs "$@" 1> /dev/null 2> /dev/null & disown ;}