This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Useful Cygwinism: "Explorer Here"


Thought I'd share a neat trick with my fellow Cygwinners that I find extremely
useful, but that's maybe not all that obvious to people, and I've never seen it
mentioned.

The Problem:
You're cd'ing around at the bash command prompt, and you come to a directory
that you want to do some complex file/directory manipulations on; say, delete
all files except three.  That'd be a cinch in Windows' Explorer, but would
require all kinds of typing at the bash prompt.  Who has that kind of time in
this workaday world?  Not this soldier!

The Solution:
A tiny little alias I like to call "Explorer Here".  Add this little gem to your
.bash_profile, and wipe that sweat from your brow my friend!:

# Easy "Explorer Here" command
x()
{
	if [ "${1}" = "" ];
	then
		XPATH=".";
	else
		XPATH="$(cygpath -w "${1}")";
	fi
	explorer $XPATH &
}

Now, at the command prompt all you have to do is type "x" and hit enter, and an
explorer box pops up in your current directory!  AND, if you want to you can
specify the path thus "x /posix/path/here"!  PLUS, it doesn't block, mainly
because I can't think of a reason you'd ever want it to.

But Can It Core A Apple?:
Ohhoho, can it core a apple!  I have used this constantly for many months and
it's never let me down yet.  In fact I use it far more often than "Bash Here".

So that's it.  Seems like this would make a good entry in the User Guide, maybe
under "Setting Up Cygwin/Customizing Bash", or maybe it would be good to create
a "Using Cygwin/Useful Cygwinisms" for cygwin-specific tips and tricks like
this.  David S-B, are you maintaining the User Guide too or just the FAQ?

--
Gary R. Van Sickle
Brewer.  Patriot.


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]