如何启动与使用脚本特定的工作目录一个Git Bash的窗口? [英] How to launch a Git Bash window with particular working directory using a script?

查看:686
本文介绍了如何启动与使用脚本特定的工作目录一个Git Bash的窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何可以启动使用脚本(无论是bash或Windows批处理)指定的工作目录一个新的Git Bash的窗口?

How can I launch a new Git Bash window with a specified working directory using a script (either bash or Windows batch)?

我的目标是从一个脚本启动多个混帐击窗口,每个窗口设置为不同的工作目录。这样我可以快速获得启动计算机,而不必打开混帐击窗口和浏览每一个正确的工作目录后继续工作。

My goal is to launch multiple Git Bash windows from a single script, each set to a different working directory. This way I can quickly get to work after booting the computer instead of having to open Git Bash windows and navigating each one to the correct working directory.

推荐答案

Git的Bash使用的cmd.exe 为它这是由<提供从MSYS / MinGW的终端加一些推广code> sh.exe ,一种的cmd.exe 包装器。在Windows中,使用启动一个新的终端启动命令。

Git Bash uses cmd.exe for its terminal plus extentions from MSYS/MinGW which are provided by sh.exe, a sort of cmd.exe wrapper. In Windows you launch a new terminal using the start command.

因此​​,这将启动与特定的工作目录一个新的Git的Bash终端的shell脚本是:

Thus a shell script which launches a new Git Bash terminal with a specific working directory is:

(cd C:/path/to/dir1 && start sh --login) &
(cd D:/path/to/dir2 && start sh --login) &

这是相当于Windows批处理脚本是:

An equivalent Windows batch script is:

C:
cd \path\to\dir1
start "" "%SYSTEMDRIVE%\Program Files (x86)\Git\bin\sh.exe" --login 
D:
cd \path\to\dir2
start "" "%SYSTEMDRIVE%\Program Files (x86)\Git\bin\sh.exe" --login 

要得到相同的字体和窗口大小为的Git猛砸从开始菜单启动,这是最简单的开始菜单快捷方式设置复制到命令控制台默认值(改变默认设置,打开 CMD。 exe文件,左键单击左上角的图标,然后选择默认值)。

To get the same font and window size as the Git Bash launched from the start menu, it is easiest to copy the start menu shortcut settings to the command console defaults (to change defaults, open cmd.exe, left-click the upper left icon, and select Defaults).

这篇关于如何启动与使用脚本特定的工作目录一个Git Bash的窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆