Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ require (
require (
github.com/alecthomas/chroma/v2 v2.19.0 // indirect
github.com/aymanbagabas/git-module v1.8.4-0.20231101154130-8d27204ac6d2
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1
github.com/aymerick/douceur v0.2.0 // indirect
github.com/charmbracelet/x/ansi v0.10.1
github.com/cli/browser v1.3.0 // indirect
Expand Down
1 change: 1 addition & 0 deletions internal/config/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ type Config struct {
Theme *ThemeConfig `yaml:"theme,omitempty" validate:"omitempty"`
Pager Pager `yaml:"pager"`
ConfirmQuit bool `yaml:"confirmQuit"`
OscClipboard bool `yaml:"oscClipboard"`
ShowAuthorIcons bool `yaml:"showAuthorIcons,omitempty"`
SmartFilteringAtLaunch bool `yaml:"smartFilteringAtLaunch" default:"true"`
IncludeReadNotifications bool `yaml:"includeReadNotifications" default:"true"`
Expand Down
14 changes: 14 additions & 0 deletions internal/tui/modelUtils.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"text/template"
"time"

"github.com/aymanbagabas/go-osc52/v2"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
log "github.com/charmbracelet/log"
Expand All @@ -26,6 +27,19 @@ import (
"github.com/dlvhdr/gh-dash/v4/internal/tui/markdown"
)

func oscCopy(text string) error {
s := osc52.New(text)

if _, ok := os.LookupEnv("TMUX"); ok {
s = s.Tmux()
} else if _, ok := os.LookupEnv("STY"); ok {
s = s.Screen()
}

_, err := s.WriteTo(os.Stdout)
return err
}

func (m *Model) getCurrSection() section.Section {
sections := m.getCurrentViewSections()
if len(sections) == 0 || m.currSectionId >= len(sections) {
Expand Down
14 changes: 12 additions & 2 deletions internal/tui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,12 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, cmd
}
number := fmt.Sprint(currRowData.GetNumber())
err := clipboard.WriteAll(number)
var err error
if m.ctx.Config.OscClipboard {
err = oscCopy(number)
} else {
err = clipboard.WriteAll(number)
}
if err != nil {
cmd = m.notifyErr(fmt.Sprintf("Failed copying to clipboard %v", err))
} else {
Expand All @@ -319,7 +324,12 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, cmd
}
url := currRowData.GetUrl()
err := clipboard.WriteAll(url)
var err error
if m.ctx.Config.OscClipboard {
err = oscCopy(url)
} else {
err = clipboard.WriteAll(url)
}
if err != nil {
cmd = m.notifyErr(fmt.Sprintf("Failed copying to clipboard %v", err))
} else {
Expand Down