Home > Linux > Making Windows more Unixy

Making Windows more Unixy

At work I’m stuck on Windows (XP). At home I use Linux (Arch) and Windows (7). I still use Windows because I need to check that software I write runs on Windows, and certain things like iTunes and Spotify still work much better on Windows. I hate developing on Windows though.

I, like many others, would like to be able to have a Unixy (I didn’t think it was a real word, but look!) experience on Windows, so I (like many others) installed Cygwin.

Installing Cygwin

Installing Cygwin’s pretty easy. Just download setup.exe (using the link “Install or update now! (using setup.exe)”) and run it. Follow the instructions, using the suggested values, until you get to Select Packages. Select Packages is a bit like apt-get on Debian or Ubuntu, or Pacman on Arch Linux. It provides an interface for installing and uninstalling packages for your Cygwin installation. For now, go with the defaults, but add Shells -> chere (see below for why). To install chere, click on the text that says “Skip”. This will change to the latest version number of chere. You can run setup.exe again any time without reinstalling Cygwin, so don’t feel like you need to find everything you’re ever going to need. Now click next, and be prepared to wait a looooong time (it could take longer than an hour).

Open Cygwin Here!

There’s a PowerToy for Windows XP which will allow you to right click on a folder and open a command window. On Windows Vista and 7 this is built in. It’s hidden unless you hold Ctrl+Shift when right clicking. It would be even more useful if you could open a Cygwin shell in this way too. Luckily, you can! That’s what chere is for. Just installing chere in Cygwin won’t cut it though, you need to install it into Windows. To do this, run chere -i (for install) in Cygwin. On Windows Vista or 7 you’ll need to run Cygwin as administrator (right click the icon and select “Run as administrator”) for this to work.

Open Explorer Here!

I’d like to be able to do the opposite – that is, open an explorer.exe window with the working directory of the Cygwin shell. This is fairly easy to do as a bash script. Make a new file called openexp or something equally cryptic and save it in /bin (this is a Cygwin dir). Make it executable (chmod +x /bin/openexp) and put the following line in it:

explorer $(cygpath --windows $(pwd))

Now, when you want to open explorer from Cygwin just run openexp.

If you’re new to Bash you may need this explained. Like most codey things, it’s best explained from the inside out.

pwd: pwd stands for present working directory, and outputs the current path.

$(pwd): $() is used for command substitution. $(pwd) is replaced by `/home“ or whatever

cygpath --windows $(pwd): cygpath –windows converts its path argument from Cygwin (Unix) form to Windows form. Its argument will be the working directory in Unix form.

explorer $(cygpath --windows $(pwd)): explorer.exe is Windows Explorer. It takes a directory as an argument – this will be the Windows formatted version of the working directory.

Categories: Linux Tags: , ,
  1. July 27th, 2010 at 11:37 | #1

    In fact, the menu item for opening a command window in the selected directory can be shown by just holding down the Shift key when right-clicking the folder — there is no need for Ctrl.

  2. July 27th, 2010 at 13:20 | #2

    Ah, I didn’t know that, thanks!

  3. December 11th, 2013 at 04:03 | #3

    If you are still enthusiastic about becoming a celebrity’s protector, join a security firm and do your best to work your way to the top. The practices of rescue and fire services at the airport are at International Civil Aviation Organization (ICAO) standards and requirements for aerodrome rescue and fire services. One you complete the above, your training is never officially complete.

  1. No trackbacks yet.

Comments parsed as Markdown.