Open Cygwin at a specific folder
When you install Cygwin (or 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.
After Cygwin is launched, open up a Cygwin terminal (as an administrator) and type the command: chere -i -t mintty -s bash
.
Now you should have "Bash Prompt Here" in the Windows right-click context menu.
(mintty is Cygwin's default terminal. If you don't choose it with the -t
option, your "Bash Prompt Here" will use the same terminal as the Windows Command Prompt, which prevents horizontal resizing.)
From the cygwin terminal, run this command:
echo "cd your_path" >> ~/.bashrc
The .bashrc script is run when you open a new bash session. The code above with change to the your_path directory when you open a new cygwin session.
Here's what I use. It doesn't require chere
package or registry tinkering. Works on Windows 7.
Go to your "Send To" folder:
C:\Users\<your_user_name>\AppData\Roaming\Microsoft\Windows\SendTo
Create a shortcut named Bash Here
having this in the Target
field:
C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico C:\cygwin\bin\bash.exe -l -c "cd \"$0\" ; exec bash"
In the Windows Explorer, you right-click on a folder & select Send To > Bash Here
.
And here's the opposite trick, opening a Windows Explorer in your current bash dir. Create this alias:
alias winx='/cygdrive/c/Windows/explorer.exe /e,\`cygpath -w .\`'
Note: the cygpath -w .
part above is enclosed in back-ticks.
Now just type winx
at the bash prompt, and a Win Explorer pops up there.
Note: If winx directs you to your documents folder, try
alias winx='/cygdrive/c/Windows/explorer.exe /e,`cygpath -w $PWD`'