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

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

每次我发射Cygwin。


当前回答

您可以通过在Cygwin.ico文件的路径中添加icon字段来将图标添加到shell中。

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\cygwin_bash]
@="Cygwin"
"Icon"="\"C:\\cygwin64\\Cygwin.ico\""

[HKEY_CLASSES_ROOT\Directory\Background\shell\cygwin_bash\command]
@="C:\\cygwin64\\bin\\mintty.exe -e /bin/xhere /bin/bash.exe"

其他回答

在cygwin终端运行如下命令:

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

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

当需要重新安装时,我创建了一个名为HOME的Windows“用户环境变量”,并将其分配给“我的文档”所在的路径。

cygwin安装程序检测HOME变量,自动将其转换为cygpath,并选择它作为我的~目录。

这在我过去5年专业使用的每个工作站(大约3或4,Win7)上都工作得很好。我一直是这些机器上唯一的用户,不能说效果是什么。

最好这样做:

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"

可能是最简单的一个:

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。

将以下代码保存为文件:cygwin_bash.reg

这将同时添加在当前目录中打开Cygwin和在指定文件夹中打开Cygwin。

使用”。Bashrc“而不是”。bash_profile”配置。由于exec bash. .bashrc是为交互式非登录shell执行的。参见:https://apple.stackexchange.com/questions/51036/what-is-the-difference-between-bash-profile-and-bashrc

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\z_cygwin_bash]
@="Cygwin Here"
"Icon"="C:\\cygwin64\\Cygwin.ico"

[HKEY_CLASSES_ROOT\Directory\Background\shell\z_cygwin_bash\command]
@="C:\\cygwin64\\bin\\mintty.exe /bin/sh -lc 'cd \"`cygpath \"%V\"`\"; exec bash'"

[HKEY_CLASSES_ROOT\Directory\shell\z_cygwin_bash]
@="Cygwin Here"
"Icon"="C:\\cygwin64\\Cygwin.ico"

[HKEY_CLASSES_ROOT\Directory\shell\z_cygwin_bash\command]
@="C:\\cygwin64\\bin\\mintty.exe /bin/sh -lc 'cd \"`cygpath \"%V\"`\"; exec bash'"