Archive

Posts Tagged ‘Windows start command’

The g Page

August 7th, 2009 subogero Comments off
G’s goal

“g” is a general-purpose command-line launcher for Gnome/Linux, an extended “gnome-open” which can open URLs, files or even programs in a new window. A bit like Windows “start”, just better.

“g” will open a new terminal window.

“g <CLI program>” will open it in a new fully independent terminal window.

“g <GTK+ program>” will open it in a fully independent window.

“g <URL>” will open it with the preferred application.

By an “independent window” I mean two things:

The starting terminal is not blocked while the started app is running;

Closing the starting terminal does not kill the started app.

Bonus: start a Google search for “foo bar” in your preferred browser with

g -g foo bar
Installation:

Download g.tar.gz and extract files in a new directory, preferably “g”.
Type “sudo make” for installation.
Enjoy.

Lessons learned:

How to decide if an argument of a shell-script is a program?

which $1
#prints the location of the command, or nothing if not a command

How to check if a shell-script has no arguments at all?

if [ $# -eq 0 ]

How to check if the last command returned no error in its exit status?

if [ $? -eq 0 ]

The trickiest: how to tell if a command is a terminal- or a GTK+ application?

Search for “libgtk-x11″ in it if it’s a compiled program.
Search for the respective gtk dependency if it’s an interpreter-script:

import gtk # Python
use Gtk2   # Perl

“g” knows these two at the moment, but the list should be extended to all known interpreted languages and graphical toolkits. Actually it should work the other way around, detecting terminal-only applications. But for instance Gimp contains the strings “stdin”, “stdout”, “stderr” and “printf” so I gave up.

I’ve created my first ever very officially looking manual page for “g”, credit goes to Jens Schweikhardt’s very helpful LINUX MAN PAGE HOWTO.

Tao in g

There is more Tao in “g” than in Windows “start”:

Try to start a native Windows program from command line which DOES NOT become fully detached, but blocks your command-line until it closes and returns an exit-status. Hmmm? On Linux, just omit “g”.

On Windows, the commands are scattered around in thousand folders, not listed in the PATH variable. On Linux, on the other hand, all commands are on the PATH, as there are only a few standard places to store them: /bin:/usr/bin:/usr/local/bin. So “g” can access them all.

View the manual page?

man g

Finally, how do you edit the “g” script itself?

g gedit g

There is Tao in Windows start

August 7th, 2009 subogero Comments off

We all remember from the Tao of Programming when the master programmer avoided an embarrassing question about the presence of Tao in DOS. The good news is there is definitely Tao in Windows (but not too much).

It’s called “start“.

It’s not the Start Menu, but a command-line keyword, obviously. I’ve come to appreciate its beauty only after having spent some weeks with Ubuntu. I kept looking for something similar on the internet, and all I found was the “gnome-open” command. Still, the blog-post has ecstatic comments.

I tried “gnome-open”. It opened any file or URL with the associated program as an independent process. So far so good. Until I tried to start a program with “gnome-open”. No way. This was the moment I discovered Tao in Windows’ “start”. Let’s see:

“start” without arguments will open a new terminal window.

“start” with a CLI program as an argument will open it in a new fully independent terminal window.

“start” with a Windows program as an argument will open just that in a fully independent window.

“start” with a file or URL as an argument will open it with the preferred application.

“gnome-open” can do the latter, but not the first three options. So I decided to write my Linux-version of “start” called “go”. Please go to the page.

Back to Windows. The famous “start” has a significant drawback. As in Windows nearly none of the applications are on the PATH, start’s capabilities are just a tiny bit limited. Not so with “go”.