Skip to content

Commit

Permalink
fix dir param extension
Browse files Browse the repository at this point in the history
  • Loading branch information
pomdtr committed Nov 30, 2023
1 parent 736f191 commit d862798
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions internal/tui/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os/exec"
"path/filepath"
"sort"
"strings"

"github.com/atotto/clipboard"
tea "github.com/charmbracelet/bubbletea"
Expand Down Expand Up @@ -348,6 +349,24 @@ func (c *RootList) Update(msg tea.Msg) (Page, tea.Cmd) {
case types.ActionTypeExec:
cmd := exec.Command("sh", "-c", msg.Command)
cmd.Dir = msg.Dir
if strings.HasPrefix(cmd.Dir, "~") {
homeDir, err := os.UserHomeDir()
if err != nil {
return c, c.SetError(err)
}

cmd.Dir = filepath.Join(homeDir, strings.TrimPrefix(cmd.Dir, "~"))
}

if !filepath.IsAbs(cmd.Dir) {
wd, err := os.Getwd()
if err != nil {
return c, c.SetError(err)
}

cmd.Dir = filepath.Join(wd, cmd.Dir)
}

return c, tea.ExecProcess(cmd, func(err error) tea.Msg {
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion www/frontend/docs/reference/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ This fallback mechanism allows you to have a project specific configs, and a glo
// command to run
"command": "sunbeam edit config.fish",
// working directory to run the command in
"cwd": "~/.config/fish"
"dir": "~/.config/fish"
}
],
"extensions": {
Expand Down

0 comments on commit d862798

Please sign in to comment.