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

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

每次我发射Cygwin。


当前回答

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

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

alias tom="cd /users/tom"

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

其他回答

当您安装Cygwin时(或者如果您已经安装了Cygwin,请再次下载并重新开始安装以运行更新),请确保您在“shell”类别下选择了chere包。

启动Cygwin后,打开Cygwin终端(以管理员身份)并键入命令:chere -i -t mintty -s bash。

现在在Windows右键上下文菜单中应该有“Bash Prompt Here”。

(mintty是Cygwin的默认终端。如果你不选择-t选项,你的“Bash Prompt Here”将使用与Windows命令提示符相同的终端,这可以防止水平调整大小。)

我使用以下几行代码在Win7的当前目录中启动zsh。

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\cygwin_bash]
@="Open Cygwin Here"
"NoWorkingDirectory"=""

[HKEY_CLASSES_ROOT\Directory\Background\shell\cygwin_bash\command]
@="\"C:\\Programmieren\\cygwin64\\bin\\mintty.exe\" -i /Cygwin-Terminal.ico /bin/zsh --login -c 'cd \"%V\";zsh'"

请注意,我使用%V而不是%L或%1(因为两者都不适合我)

要创建一个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终端运行如下命令:

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

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

对于cygwin64或没有chere的安装,您可以在注册表项中使用以下命令(假设windows由于您的路径,也假设cygwin安装目录为c:\cygwin64)

C:\cygwin64\bin\mintty.exe /bin/sh -lc 'cd "`cygpath "%V"`"; bash'

适用于Windows 7和8 注册表文件可在这里下载:http://tomkay.me/blog/Cygwin64---Open-Here-18

Windows Registry Editor Version 5.00
; Open cygwin to folder
; http://tomkay.me - Tom Kay

[HKEY_CLASSES_ROOT\Folder\shell\open_cygwin]
@="Open Cygwin Here"

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

[HKEY_CLASSES_ROOT\Directory\Background\shell\open_cygwin]
@="Open Cygwin Here"

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