启动 cygwin 时执行命令(从命令行)
想知道是否有人知道如何在 bash 中不使用脚本执行命令。即,我正在使用 Cygwin 并运行 cygwin.bat。基本上,默认脚本是:
bash --login -i
大多数时候这对我来说没问题。但有时,我想传递一个我想要作为默认目录的目录。例如:
cygwin.bat C:\
理想情况下将我的目录(从 bash / cygwin 中)更改为 C: 目录。我尝试将 cygwin.bat 文件更改为:
if [%1%] EQU [] (bash --login -i)
if [%1%] NEQ [] (bash -i -c "cd %1%")
但是 -c "cd %1%"
执行后立即退出。所以我想要的是像 -c
这样的标志,但这不会立即退出 shell。希望我没有错过一些显而易见的事情......谢谢。
wondering if anyone knows how to execute a command from within bash without using scripts. Ie, I'm using Cygwin and running cygwin.bat. Basically, the default script is:
bash --login -i
Which is fine for me most of the time. But sometimes, I want to pass in a directory that I want to be the default. Eg:
cygwin.bat C:\
Would ideally change my directory (from within bash / cygwin) to the C: directory. I've tried to change the cygwin.bat
file to:
if [%1%] EQU [] (bash --login -i)
if [%1%] NEQ [] (bash -i -c "cd %1%")
But the -c "cd %1%"
executes and then immediately exits. So what I'd like is a flag like -c
, but that doesn't immediately exit the shell. Hopefully I didn't miss something blatantly obvious ... thx.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在其后附加一个
;bash
,即bash -i -c "cd %1%; bash"
。虽然不是很漂亮,但我不知道有什么更好的解决方案。You append a
;bash
to it, iebash -i -c "cd %1%; bash"
. Not very pretty though, but I'm unaware of any better solution.