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!

25 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)

  15. thanks, very much, it worked well

  16. Thank you, saved me a lot of frustration.

  17. Thanks. And thanks Shantanu for

    $> chere -i -t mintty

    I didn’t know it was using mintty (or even what mintty is), but I really like how it handles resizing the window.

  18. [...] may also be interested in chere a context menu entry for Open bash [...]

  19. Very helpful post, Mr Peter! :) Straight and to the point.

    Windows 7 x64 (Russian) — works very well.

  20. Hmm I tried this, installed the required package, ran the command (with cygwin in admin mode), it executed without error, however cygwin does not appear in my context menus :(
    PS. Windows 8.

  21. Jerry I have the same problem.

    Ran:

    $ chere -i -t mintty

    Without a problem but nothing changes in explorer. Running Win7 x64

  22. Thanks for this great tip! I’ve recently been forced at work to use a Win 7 PC instead of my trusty Linux Mint box and I’ve been missing my command line functions. This restores some of the convenience.

  23. When I run chere -i i get this

    JitendraVyas :: ~ » chere -i
    Shell defaulting to zsh defined for Jitendra Vyas
    Error (5): Access is denied.

    /usr/bin/chere Error: Hive not writable
    /usr/bin/chere: Aborting.
    JitendraVyas :: ~ »

  24. FYI, chere package is not available in cygwin 64 bits (http://cygwin.com/ml/cygwin/2013-10/msg00359.html)

  25. If chere doesn’t appear in your list, you can use the script I made to do this.

    http://github.com/umer936/CygwinHere

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.

Comments will be closed on Tuesday, November 25th, 2014.