diff --git a/pkg/commands/oscommands/os.go b/pkg/commands/oscommands/os.go index b328345e9..64d9edab8 100644 --- a/pkg/commands/oscommands/os.go +++ b/pkg/commands/oscommands/os.go @@ -6,6 +6,7 @@ import ( "os" "os/exec" "path/filepath" + "runtime" "strings" "sync" @@ -267,3 +268,20 @@ func GetLazygitPath() string { } return `"` + filepath.ToSlash(ex) + `"` } + +func UpdateWindowTitle() error { + if runtime.GOOS != "windows" { + return nil + } + path, getWdErr := os.Getwd() + if getWdErr != nil { + return getWdErr + } + title := fmt.Sprint(filepath.Base(path), " - Lazygit") + args := append([]string{"/C", "title"}, strings.Split(title, " ")...) + cmd := exec.Command("cmd", args...) + if err := cmd.Run(); err != nil { + return err + } + return nil +} diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 4d11efcc5..ffae386fc 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -683,6 +683,8 @@ func (gui *Gui) loadNewRepo() error { return err } + oscommands.UpdateWindowTitle() + return nil }