Skip to content

Commit cd3dd99

Browse files
author
Taranveer Bains
committed
chore: use executable path to get name
1 parent 91641a0 commit cd3dd99

File tree

2 files changed

+9
-20
lines changed

2 files changed

+9
-20
lines changed

.goreleaser-rc.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,6 @@ brews:
7575
homepage: https://github.com/tearingItUp786/chatgpt-tui
7676
commit_author:
7777
name: tearingitup786
78-
install: |
79-
bin.install "rc-nekot" => "rc-nekot-unwrapped"
80-
81-
(bin/"rc-nekot").write <<~EOS
82-
#!/bin/bash
83-
export NEKOT_APP_DIR={{.ProjectName}}
84-
exec "#{bin}/rc-nekot-unwrapped" "$@"
85-
EOS
86-
87-
chmod 0755, bin/"rc-nekot"
8878
# Setting this will prevent goreleaser to actually try to commit the updated
8979
# formula - instead, the formula file will be stored on the dist folder only,
9080
# leaving the responsibility of publishing it to the user.

util/db.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,32 @@ import (
88
"log"
99
"os"
1010
"path/filepath"
11+
"strings"
1112

1213
_ "github.com/mattn/go-sqlite3"
1314
"github.com/pressly/goose/v3"
1415
)
1516

16-
// originally called chatgpt-tui but changed to nekot
1717
func GetAppDirName() string {
18-
if envAppDir := os.Getenv("NEKOT_APP_DIR"); envAppDir != "" {
19-
return envAppDir
20-
}
21-
return ".chatgpt-tui"
18+
exePath, err := os.Executable()
19+
if err != nil {
20+
return ".chatgpt-tui" // fallback
21+
}
22+
binaryName := filepath.Base(exePath)
23+
binaryName = strings.TrimSuffix(binaryName, filepath.Ext(binaryName)) // remove .exe if present
24+
25+
return "." + binaryName
2226
}
2327

2428
func GetAppDataPath() (string, error) {
25-
// Get the user's home directory
2629
homeDir, err := os.UserHomeDir()
2730
if err != nil {
2831
return "", err
2932
}
3033

31-
// Define the application-specific part of the path
3234
appDirName := GetAppDirName()
33-
34-
// Combine them to form the full path
3535
fullPath := filepath.Join(homeDir, appDirName)
3636

37-
// Optionally, create the directory if it doesn't already exist
3837
err = os.MkdirAll(fullPath, 0755)
3938
if err != nil {
4039
return "", err

0 commit comments

Comments
 (0)