Open Cygwin at a specific folder

后端 未结 29 2565
悲哀的现实
悲哀的现实 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:20

    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\\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`'
    

提交回复
热议问题