-
Notifications
You must be signed in to change notification settings - Fork 14
/
git.ahk
32 lines (32 loc) · 835 Bytes
/
git.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
git(cmd, dir="") {
return gitout("git " cmd, dir)
}
gitout(cmd, dir:="") {
tf = %A_Temp%\gitout%A_ScriptHwnd%.txt
try {
RunWait cmd.exe /v:on /c "%cmd% >"%tf%" 2>&1 & exit !ErrorLevel!", %dir%
exit_code := ErrorLevel
FileRead t, *P65001 *t %tf%
} finally
FileDelete %tf%
ErrorLevel := exit_code
return RTrim(t, "`n")
}
gitsh(cmd, dir:="") {
return gitout("""" gitdir() "\bin\sh"" -l -c " cmd, dir)
}
gitdir() {
static dir := ""
if (dir != "")
return dir
pf := A_ProgramFiles
if FileExist(pf "\Git")
return dir := pf "\Git"
EnvGet pf, ProgramW6432
if FileExist(pf "\Git")
return dir := pf "\Git"
EnvGet pf, ProgramFiles(x86)
if FileExist(pf "\Git")
return dir := pf "\Git"
throw Exception("Git not found!")
}