如何创建在特定文件夹中打开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。
其他回答
可能是最简单的一个:
1)创建文件foo.reg
2)插入内容:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\background\shell\open_mintty]
@="open mintty"
[HKEY_CLASSES_ROOT\Directory\background\shell\open_mintty\command]
@="cmd /C mintty"
3)执行foo.reg
现在只需右键单击任何文件夹,单击打开mintty,它将在该文件夹中生成mintty。
正如two7s_clash所说,你首先需要安装chere包和安装mintty:
以管理员身份打开Cygwin终端 Apt-cyg安装chere 这里有薄荷
现在你可以在Windows资源管理器(上下文菜单)中用鼠标右键在特定目录中打开cygwin,并选择“Bash Prompt Here”。
您也可以使用windows命令提示符从指定目录打开cygwin:
打开windows命令提示符 导航(cd)到自定义目录 执行C:\cygwin64\bin\ minty .exe C:\cygwin64\bin\env.exe chere_invoke =1 C:\cygwin64\bin\bash.exe 该命令将打开cygwin,并从命令提示符获取当前目录。
FreeCommander
此命令还可以用于从自定义文件管理器(如freecommand)打开cygwin。
要打开从freecommand获取的当前目录的cygwin,请执行以下操作:
工具->收藏工具->收藏工具编辑…(Ctrl + Shift + Y) 添加一个新的工具栏(+图标),快捷方式:插入 名称:cygwin 程序或文件夹:C:\cygwin64\bin\mint .exe 开始文件夹:%ActivDir% 参数:C:\cygwin64\bin\env.exe chere_invoke =1 C:\cygwin64\bin\bash.exe -l
你可以添加自定义快捷方式从freecommand打开cygwin:
工具->定义键盘快捷键 向下滚动到“最喜欢的工具01”(或“最喜欢的工具N”) 指定新的快捷键:我使用Ctrl + Shift + T
伟大的参考:MinTTY维基,文章提示:开始在一个特定的目录
最好这样做:
HKEY_CLASSES_ROOT\Directory\shell\BashHere
Enter Data: Bash Here
HKEY_CLASSES_ROOT\Directory\shell\BashHere\command
Enter Data:
cmd.exe /c C:\cygwin\bin\bash.exe --login -c "cd '%1'; exec /bin/bash"
要创建一个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上。
我已经创建了批处理文件,并将其放到Cygwin的/bin目录中。开发此脚本的目的是允许安装/卸载注册表项,以便在Cygwin中打开选定的文件夹和驱动器。详情请参见http://with-love-from-siberia.blogspot.com/2013/12/cygwin-here.html。
更新:此解决方案与早期建议相同,但Windows注册表的所有操作都隐藏在脚本中。
执行安装命令
cyghere.bat /install
执行卸载命令
cyghere.bat /uninstall