From 555d8bbc96dcd2351e9c3d8ec3ed9d983adb0abc Mon Sep 17 00:00:00 2001 From: Birger Skogeng Pedersen Date: Wed, 19 Jan 2022 10:42:32 +0100 Subject: [PATCH] set repo name as window title when loading repo, fix #1691 --- pkg/commands/oscommands/os.go | 18 ++++++++++++++++++ pkg/gui/gui.go | 2 ++ 2 files changed, 20 insertions(+) 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 }