Skip to content

Commit f9ff55a

Browse files
committed
Cleanup: move UpdateWindowTitle to platform-specific source files
No need to do a runtime check if we already have the platform-specific files.
1 parent c0dcf7d commit f9ff55a

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

pkg/commands/oscommands/os.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package oscommands
22

33
import (
4-
"fmt"
54
"io"
65
"os"
76
"os/exec"
@@ -329,15 +328,3 @@ func GetLazygitPath() string {
329328
}
330329
return `"` + filepath.ToSlash(ex) + `"`
331330
}
332-
333-
func (c *OSCommand) UpdateWindowTitle() error {
334-
if c.Platform.OS != "windows" {
335-
return nil
336-
}
337-
path, getWdErr := os.Getwd()
338-
if getWdErr != nil {
339-
return getWdErr
340-
}
341-
argString := fmt.Sprint("title ", filepath.Base(path), " - Lazygit")
342-
return c.Cmd.NewShell(argString, c.UserConfig().OS.ShellFunctionsFile).Run()
343-
}

pkg/commands/oscommands/os_default_platform.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,7 @@ func getUserShell() string {
3434

3535
return "bash"
3636
}
37+
38+
func (c *OSCommand) UpdateWindowTitle() error {
39+
return nil
40+
}

pkg/commands/oscommands/os_windows.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
11
package oscommands
22

3+
import (
4+
"fmt"
5+
"os"
6+
"path/filepath"
7+
)
8+
39
func GetPlatform() *Platform {
410
return &Platform{
511
OS: "windows",
612
Shell: "cmd",
713
ShellArg: "/c",
814
}
915
}
16+
17+
func (c *OSCommand) UpdateWindowTitle() error {
18+
path, getWdErr := os.Getwd()
19+
if getWdErr != nil {
20+
return getWdErr
21+
}
22+
argString := fmt.Sprint("title ", filepath.Base(path), " - Lazygit")
23+
return c.Cmd.NewShell(argString, c.UserConfig().OS.ShellFunctionsFile).Run()
24+
}

0 commit comments

Comments
 (0)