如何创建在特定文件夹中打开Cygwin的Cygwin快捷方式?这样就不用打字了
cd /cygdrive/c/Users/Tom/Desktop/
每次我发射Cygwin。
如何创建在特定文件夹中打开Cygwin的Cygwin快捷方式?这样就不用打字了
cd /cygdrive/c/Users/Tom/Desktop/
每次我发射Cygwin。
当前回答
我已经做了一个注册表编辑脚本打开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\""
其他回答
如果您希望将该目录作为默认目录,只需在~/中添加一个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"
在我的Windows电脑上,它没有显示:
切尔 -i -t 薄荷
因为薄荷shell是不可用的,但你可以选择各种其他shell,如ash bash cmd dash mksh pdksh posh tcsh zsh passwd。
所以我用:
Chere -i -s bash
将以下代码保存为文件: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'"
我已经创建了批处理文件,并将其放到Cygwin的/bin目录中。开发此脚本的目的是允许安装/卸载注册表项,以便在Cygwin中打开选定的文件夹和驱动器。详情请参见http://with-love-from-siberia.blogspot.com/2013/12/cygwin-here.html。
更新:此解决方案与早期建议相同,但Windows注册表的所有操作都隐藏在脚本中。
执行安装命令
cyghere.bat /install
执行卸载命令
cyghere.bat /uninstall