Open Cygwin Bash Shell Here

cygwin-prompt-here-3

If you’re like me, you love shortcuts and other tools that improve productivity. One of the other things I’ve gained a liking for is the Bash shell, after spending time in a Unix environment. Since I couldn’t live without this, and the other tools that typically come with a Unix environment, I installed the great Cygwin, in order to create a Linux-like environment on my Windows PC. (Not ready to make the full jump to Linux yet, for gaming reasons)

However, one thing that always irked me was having to manually navigate to a certain folder after opening up a Bash shell in Cygwin. For Windows, there is a PowerToy called “Open Command Window Here”, that provides a context menu option for quickly opening a (Windows) command prompt with the location set to the selected folder. This is helpful, since you often have the folder open when you want to also have a command prompt at the same location. Now, all I needed was the equivalent function, but for the Cygwin Bash shell, instead of the Windows Command prompt.

Creating a “Bash Prompt Here” shortcut

I did some searching and found a myriad of solutions to my problem, most of which were somewhat complicated. Thankfully, I did find one link that suggested an easier solution.

Basically, here’s what you do. When you install Cygwin (of if you’ve already installed it, download it again and start setup again to run an update), make sure that you select the chere package under the “Shells” category.

cygwin-prompt-here-1

After Cygwin is launched, open it up and type the command chere -i, like so:

cygwin-prompt-here-2

You should now see the following option in your folder’s context menu, and more importantly, it works!

cygwin-prompt-here-3

Hope you found this helpful!

14 Comments »

  1. Great tip – thanks

  2. Error (5): Access is denied.

    /usr/bin/chere Error: Hive not writable
    /usr/bin/chere: Aborting.

    This is the response I get, whats up?

    My working directory is
    /cygdrive/c/Users/Me

  3. Hi Enzo

    I had the same problem. However, if you run Cygwin bash shell as admin you will have sufficient permissions to add the shell extension.

    Cheers
    Dennis

  4. Thanks peter! Works fine in windows 7 64bit

  5. Possibly the best thing I’ve seen this year! Good solid random geekery. Nice one.

  6. Thanks Peter! I just installed Cygwin and was searching for “Bash prompt here” and had forgotten how I had done it before. Great post!

  7. Awesome, thanks!

  8. [...] Cygwin: bash here [...]

  9. Elaborating on what dnorgaard said, you can hold down Ctrl+Shift (Windows 7) while clicking on a program icon in order to run it as an adminstrator. This fixed the “hive not writable” error for me.

  10. First up, awesome!!! thanks for that tip.

    From cygwin home dir, is there a way to setup a batch file with predefined locations so that I can get to where I need simply by launching that file?

    something like a .bat file equivalent of windows

  11. Awesome. Thanks.

  12. Hi,
    Nice tip. I use the ‘mintty’ terminal rather than the default.

    $> chere -i -t mintty

    Obviously, the package “mintty” needs to be installed as well! :)

  13. @puakv: You can use symbolic links.

    $> ln -s

    so for example if you want to link to /cygdrive/d/work/project001 do this

    $> ln -s /cygdrive/d/work/project001

    Some more info: http://www.nixtutor.com/freebsd/understanding-symbolic-links/ and of course there is always the man file :)

  14. hmmm my syntax lines got mis-printed. http://unitstep.net/blog/2009/05/16/open-cygwin-bash-shell-here/comment-page-1/#comment-284146

    The first $> line should read

    $> ln -s (target_dir) (optional_name)

Post a Comment

(required)

(will not be published) (required)

XHTML tags allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Note: rel="nofollow" will be added to all links in comments.