简体   繁体   English

"如何使 ConEmu 在与 Git for Windows 相同的窗口中执行 .sh?"

[英]How to make ConEmu execute .sh in the same window with Git for Windows?

I'm using ConEmu on Windows with Git for Windows installed.我在 Windows 上使用 ConEmu 并安装了适用于 Windows 的 Git。 When I try to execute an .sh script, the software starts an instance of Windows' default console and executes the script there.当我尝试执行 .sh 脚本时,软件会启动 Windows 默认控制台的实例并在那里执行脚本。 How can I make ConEmu / Git for Windows execute the .sh script in the same window the command is initialized from?如何让 Windows 的 ConEmu / Git 在初始化命令的同一窗口中执行 .sh 脚本?

So there are a few things one needs to do after a clean install of ConEmu and Git for Windows to make everything run seamlessly. 因此,在完全安装ConEmu和Git for Windows之后,需要做一些事情才能使所有内容无缝运行。

1) C:\\Program Files\\Git\\bin needs to be added to PATH. 1) C:\\Program Files\\Git\\bin需要添加到PATH。 Git for Windows only appears to add C:\\Program Files\\Git\\cmd to PATH. 仅用于Windows的Git似乎将C:\\Program Files\\Git\\cmd到PATH。 This should allow you to run commands like sh test.sh ABC and they should work 这应该允许你运行像sh test.sh ABC这样的命令,它们应该可以工作

2) To make things even easier and not have to type sh all the time, we need to tell Windows to associate .sh with sh, as well as pass parameters properly . 2)为了使事情变得更容易而且不必一直输入sh ,我们需要告诉Windows将.sh与sh关联,以及正确传递参数 We do this by typing: 我们这样做是键入:

assoc .sh=sh

ftype sh="C:\\Program Files\\Git\\bin\\sh.exe" "%1" %*

3) If parameters are still not passed, it might be a registry issue. 3)如果仍未传递参数,则可能是注册表问题。 To fix it, we press Win+r, type in regedit and run the Registry Editor. 要修复它,我们按Win + r,键入regedit并运行注册表编辑器。 There might be a few places where the edit needs to be made, but one of them should be HKEY_CLASSES_ROOT\\Applications\\sh.exe\\shell\\open\\command . 可能有一些地方需要进行编辑,但其中一个应该是HKEY_CLASSES_ROOT\\Applications\\sh.exe\\shell\\open\\command We edit the entry to say 我们编辑条目说

"C:\\Program Files\\Git\\bin\\sh.exe" "%1" %*

4) Bonus: To make .sh files execute without having to write ".sh" at the end, add .SH to PATHEXT in environmental variables. 4)奖励:要使.sh文件执行而不必在末尾写“.sh”,在环境变量中将.SH添加到PATHEXT

That should allow us to run .sh files from ConEmu using Git for Windows without it opening in a separate window. 这应该允许我们使用Git for Windows从ConEmu运行.sh文件而不在单独的窗口中打开。

  1. Перейти в директорию расположения файла: cd ~\/Desktop Перейти в директорию расположения файла: cd ~\/Desktop<\/li>
  2. Выполнить запуск файла командой: sh {name}.sh (где {name} имя файла без скобок) Выполнить запуск файла командой: sh {name}.sh (где {name} имя файла без скобок)<\/li><\/ol>"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM