如何创建在特定文件夹中打开Cygwin的Cygwin快捷方式?这样就不用打字了

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

每次我发射Cygwin。


当前回答

在我的Windows电脑上,它没有显示:

切尔 -i -t 薄荷

因为薄荷shell是不可用的,但你可以选择各种其他shell,如ash bash cmd dash mksh pdksh posh tcsh zsh passwd。

所以我用:

Chere -i -s bash

其他回答

最好这样做:

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"

在cygwin终端运行如下命令:

回显"cd your_path" >> ~/.bashrc

在打开一个新的bash会话时运行.bashrc脚本。当您打开一个新的cygwin会话时,上面的代码改变了your_path目录。

如果您希望将该目录作为默认目录,只需在~/中添加一个cd语句。概要文件。

我倾向于使用该方法来设置我的常用目录,并为我的常见情况定义别名:

alias tom="cd /users/tom"

或者类似的东西。这让我可以非常快速地更改目录。

我制作了一个.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"

我已经做了一个注册表编辑脚本打开Cygwin在任何文件夹你右键单击。在我的GitHub上。

这是我的GitHub

来自Github的64位机器RegEdit示例代码:

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\""