如何创建在特定文件夹中打开Cygwin的Cygwin快捷方式?这样就不用打字了
cd /cygdrive/c/Users/Tom/Desktop/
每次我发射Cygwin。
如何创建在特定文件夹中打开Cygwin的Cygwin快捷方式?这样就不用打字了
cd /cygdrive/c/Users/Tom/Desktop/
每次我发射Cygwin。
当前回答
@echo off
C:
SET mypath=%~dp0
c:\cygwin\bin\bash -c "cd '%mypath%'; export CHERE_INVOKING=1; exec /bin/bash --login -i"
将上述命令复制到一个文本文件中,并将其保存为。bat在“您感兴趣的文件夹”中。 它应该在“您感兴趣的文件夹”中打开cygwin。
其他回答
这是唯一的Cygwin64注册表解决方案,为我工作在Windows 8.1:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\mintty]
@="Mintty from Here"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\Directory\shell\mintty\command]
@="C:\\cygwin64\\bin\\mintty.exe -h always -e /usr/bin/ash -c 'cd \"$(/usr/bin/cygpath \"%L\")\"; exec /usr/bin/bash '"
请确保根据需要修改'C:\cygwin64'路径。
我制作了一个.reg文件,在右键单击上下文菜单中放入“打开Cygwin Here”选项。 它取决于Cygwin“chere”包,如果在初始设置中没有安装它,可以使用apt-cyg安装它。
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\cygwin_bash]
@="Open Cygwin Here"
[HKEY_CLASSES_ROOT\Directory\Background\shell\cygwin_bash\command]
@="C:\\cygwin\\bin\\mintty.exe -e /bin/xhere /bin/bash.exe"
@echo off
C:
SET mypath=%~dp0
c:\cygwin\bin\bash -c "cd '%mypath%'; export CHERE_INVOKING=1; exec /bin/bash --login -i"
将上述命令复制到一个文本文件中,并将其保存为。bat在“您感兴趣的文件夹”中。 它应该在“您感兴趣的文件夹”中打开cygwin。
我已经创建了批处理文件,并将其放到Cygwin的/bin目录中。开发此脚本的目的是允许安装/卸载注册表项,以便在Cygwin中打开选定的文件夹和驱动器。详情请参见http://with-love-from-siberia.blogspot.com/2013/12/cygwin-here.html。
更新:此解决方案与早期建议相同,但Windows注册表的所有操作都隐藏在脚本中。
执行安装命令
cyghere.bat /install
执行卸载命令
cyghere.bat /uninstall
要创建一个Windows快捷方式,在您自己选择的目录中启动Cygwin终端,请尝试以下操作:
Right-click on the Windows desktop, select 'New', and then select 'Shortcut'. For location of the item, enter the following text, changing the mintty path as needed and substituting the name of the desired directory where indicated. C:\cygwin64\bin\mintty.exe /bin/sh -lc 'cd DESIRED-DIRECTORY; exec bash' For example, the OP would use the following text: C:\cygwin64\bin\mintty.exe /bin/sh -lc 'cd /cygdrive/c/Users/Tom/Desktop/; exec bash' Click 'Next'. Enter the desired name for the shortcut and click 'Finish'.
可以在桌面上放置多个快捷方式,在各种经常访问的目录中打开Cygwin终端。
灵感来自解决方案张贴如何打开一个Cygwin shell在一个特定的目录从Netbeans?在superuser.com上。