summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJosh Medeski <[email protected]>2025-07-10 06:12:19 -0500
committerGitHub <[email protected]>2025-07-10 06:12:19 -0500
commit6d393759e15801eb49f3a652351b6bdfe5147071 (patch)
tree2739b330b14b0e0cc6658c5837ff16ab47be8fab
parenta1701678cdde92117c085dcdf6bf5629b576e689 (diff)
downloadopencode-6d393759e15801eb49f3a652351b6bdfe5147071.tar.gz
opencode-6d393759e15801eb49f3a652351b6bdfe5147071.zip
feat(tui): subsitute cwd home path on status bar (#808)
-rw-r--r--packages/tui/internal/components/status/status.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/packages/tui/internal/components/status/status.go b/packages/tui/internal/components/status/status.go
index a92cbf2f6..d0d61b173 100644
--- a/packages/tui/internal/components/status/status.go
+++ b/packages/tui/internal/components/status/status.go
@@ -2,6 +2,7 @@ package status
import (
"fmt"
+ "os"
"strings"
tea "github.com/charmbracelet/bubbletea/v2"
@@ -20,6 +21,7 @@ type StatusComponent interface {
type statusComponent struct {
app *app.App
width int
+ cwd string
}
func (m statusComponent) Init() tea.Cmd {
@@ -100,7 +102,7 @@ func (m statusComponent) View() string {
Foreground(t.TextMuted()).
Background(t.BackgroundPanel()).
Padding(0, 1).
- Render(m.app.Info.Path.Cwd)
+ Render(m.cwd)
sessionInfo := ""
if m.app.Session.ID != "" {
@@ -156,5 +158,12 @@ func NewStatusCmp(app *app.App) StatusComponent {
app: app,
}
+ homePath, err := os.UserHomeDir()
+ cwdPath := app.Info.Path.Cwd
+ if err == nil && homePath != "" && strings.HasPrefix(cwdPath, homePath) {
+ cwdPath = "~" + cwdPath[len(homePath):]
+ }
+ statusComponent.cwd = cwdPath
+
return statusComponent
}