Cygwin open command

Posted on Saturday, September 19, 2015


In OSX there is a great command called open.  It can be used for several things. But what  I use it most for is for opening the current folder I am in on the command line.



For example you could run


> open .


And it opens the directory you are in!

It's just a nice convenient command line tool to have.


I tend to migrate back and forth from OS X to Win 7 on an almost daily basis.

Cygwin is a lifesaver on Windows as it give me a pseudo command line linux to work from.

But it has not open tool….

Well as it turns out its pretty easy to make one.  Here is how.

Here is the simple script the get the job done….


> vi /usr/bin/open


And place the following script into it and save.


#!/bin/bash
#
# open script that works somewhat
# similar to the open command in OSX
#
# Does not yet currently open web pages
#
#######################################

cygstart -o "$1"





Make it executable


> chmod a+x /usr/bin/open


Run it


> open .





Works like a charm J


99/100 I am usually just running the open . command but you can specify any folder



> open /etc




> open /cygdrive/c/Program\ Files





Oh hey it even works for opening web pages….



> open www.google.com



Worked…. Nice to know























References



No comments:

Post a Comment