From 6506df75b49cb03ad435fc9dd3a7681813b44e3c Mon Sep 17 00:00:00 2001 From: Andre Henriques Date: Mon, 2 Jun 2025 08:06:13 +0100 Subject: [PATCH] feat: added sorting of recently opened remeber paths --- README.md | 26 ++++++++++++-------------- app.go | 26 ++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 2e62a37..5b0fb66 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,14 @@ -# README +# RAILGUN -## About +# Building +```bash +wails build +``` -This is the official Wails Svelte-TS template. - -## Live Development - -To run in live development mode, run `wails dev` in the project directory. This will run a Vite development -server that will provide very fast hot reload of your frontend changes. If you want to develop in a browser -and have access to your Go methods, there is also a dev server that runs on http://localhost:34115. Connect -to this in your browser, and you can call your Go code from devtools. - -## Building - -To build a redistributable, production mode package, use `wails build`. +# Remebering paths +```bash +# this will save the current path in railgun for easy acess +railgun --remeber +# and this will forget the current path +railgun --forget +``` diff --git a/app.go b/app.go index ec0b1a3..d55c9a0 100644 --- a/app.go +++ b/app.go @@ -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 + } + } +}