Open Cygwin at a specific folder

后端 未结 29 2441
悲哀的现实
悲哀的现实 2020-12-12 08:49

How can I create a Cygwin shortcut that will open Cygwin at a specific folder? This would obviate having to type

cd /cygdrive/c/Users/Tom/Desktop/

相关标签:
29条回答
  • 2020-12-12 09:22

    I used the following lines of code to start zsh in the current directory in Win7.

    Windows Registry Editor Version 5.00
    
    [HKEY_CLASSES_ROOT\Directory\Background\shell\cygwin_bash]
    @="Open Cygwin Here"
    "NoWorkingDirectory"=""
    
    [HKEY_CLASSES_ROOT\Directory\Background\shell\cygwin_bash\command]
    @="\"C:\\Programmieren\\cygwin64\\bin\\mintty.exe\" -i /Cygwin-Terminal.ico /bin/zsh --login -c 'cd \"%V\";zsh'"
    

    note that i used %V instead of %L or %1 (since both didn't work for me)

    0 讨论(0)
  • 2020-12-12 09:25

    I use and Icon to launch my cygwin without the chere package.

    1. Create a shortcut on my desktop for the cygwin terminal.
    2. R-click the icon and select properties.
    3. On the shortcut tab, use this for the TARGET: C:\cygwin64\bin\mintty.exe -i /Cygwin-Terminal.ico -c 'cd'
    4. For START IN, Put the path of the dir/folder where you want to launch cygwin. i.e. C:\some\dir\name\here
    0 讨论(0)
  • 2020-12-12 09:25

    I have made a registry edit script to open Cygwin at any folder you right click. It's on my GitHub.

    Here's my GitHub

    Sample RegEdit code from Github for 64-bit machines:

    REGEDIT4
    
    [HKEY_CLASSES_ROOT\Directory\shell\CygwinHere]
    @="&Cygwin Bash Here"
    
    [HKEY_CLASSES_ROOT\Directory\shell\CygwinHere\command]
    @="C:\\cygwin64\\bin\\mintty.exe -i /Cygwin-Terminal.ico C:\\cygwin64\\bin\\bash.exe --login -c \"cd \\\"%V\\\" ; exec bash -rcfile ~/.bashrc\""
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\CygwinHere]
    @="&Cygwin Bash Here"
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\CygwinHere\command]
    @="C:\\cygwin64\\bin\\mintty.exe -i /Cygwin-Terminal.ico C:\\cygwin64\\bin\\bash.exe --login -c \"cd \\\"%V\\\" ; exec bash -rcfile ~/.bashrc\""
    
    0 讨论(0)
  • 2020-12-12 09:25

    I had also problem with git, that used to "steal" my cygwin commands - so i needed to run
    C:\cygwin\bin\mintty.exe -
    but after installing chere and executing chere -i -t mintty -f as admin (see above), you can simply use :
    C:\cygwin\bin\mintty.exe -e /bin/xhere /bin/bash.exe "."
    I added this in Total Commander as custom button (right click on panel > add ...) and it works very well.

    0 讨论(0)
  • 2020-12-12 09:27

    When a fresh install is needed, I create a Windows "user environment variable " named HOME and assigns it the path of wherever "My Documents" reside.

    The cygwin installer detects the HOME variable, automatically translates this into a cygpath and selects this it to be my ~ directory.

    This has worked fine for every workstation I have used professionally the last 5 years (about 3 or 4, Win7). I have always been the only user on these machines, cannot say what the effect is.

    0 讨论(0)
  • 2020-12-12 09:32

    Open Cygwin terminal as Administrator

    In powershell (using chocolatey):

    choco install cyg-get
    

    In cygwin Will Install right-click menu

    cyg-get install chere
    chere -i
    

    Now you can right click and use "Bash Prompt Here" in any folder.

    0 讨论(0)
提交回复
热议问题