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

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

每次我发射Cygwin。


当前回答

找到Cygwin.bat文件并制作如下内容:

@echo off
set newpath=%cd:\=/%
pushd "%~dp0"
chdir bin
bash --login -i -c "cd \"%newpath%\"; exec bash"

将cygwin.bat的路径添加到环境path中。

现在在任何文件夹中,你都可以输入地址栏:

cygwin

你也可以在cmd.exe中输入

其他回答

我也有问题与git,它曾经“窃取”我的cygwin命令-所以我需要运行 C: \ cygwin \ bin \ mintty.exe - 但是在安装chere并以管理员身份执行chere -i -t mintty -f之后(见上文),你可以简单地使用: C:\cygwin\bin\ minty .exe -e /bin/xhere /bin/bash.exe 我在Total Commander中添加了这个自定义按钮(右键单击面板> add…),它工作得非常好。

@echo off
C:
SET mypath=%~dp0
c:\cygwin\bin\bash -c "cd '%mypath%'; export CHERE_INVOKING=1; exec /bin/bash --login -i"

将上述命令复制到一个文本文件中,并将其保存为。bat在“您感兴趣的文件夹”中。 它应该在“您感兴趣的文件夹”中打开cygwin。

我使用和图标启动我的cygwin没有chere包。

在我的桌面上为cygwin终端创建一个快捷方式。 右击图标并选择属性。 在快捷选项卡上,对TARGET使用这个: C:\cygwin64\bin\mint .exe -i /Cygwin-Terminal.ico -c 'cd' 对于START IN,将目录/文件夹的路径放在您想要的位置 启动cygwin。例如C: \一些\ dir \名字\

我使用以下几行代码在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上。