feat: added sorting of recently opened remeber paths

This commit is contained in:
2025-06-02 08:06:13 +01:00
parent 8cef2527d6
commit 6506df75b4
2 changed files with 38 additions and 14 deletions

26
app.go
View File

@@ -187,11 +187,37 @@ func (a *App) Enter(value string) {
}
func (a *App) EnterDir(value string) {
updateRemeberPath(a, value)
fmt.Printf("ghostty --working-directory=%s", value)
runtime.Quit(a.ctx)
}
func (a *App) OpenEditor(value string) {
updateRemeberPath(a, value)
fmt.Printf("czed %s", value)
runtime.Quit(a.ctx)
}
func updateRemeberPath(a *App, value string) {
if a.remeberedPath[0] != value {
remeberPath, err := GetRemeberPath()
if err != nil {
os.Exit(1)
return
}
nlist := []string{value}
for _, elm := range a.remeberedPath {
if value != elm {
nlist = append(nlist, elm)
}
}
err = os.WriteFile(remeberPath, []byte(strings.Join(nlist, "\n")), 0644)
if err != nil {
os.Exit(1)
return
}
}
}