diff --git a/internal/views/details.go b/internal/views/details.go index b39732c8..d6901609 100644 --- a/internal/views/details.go +++ b/internal/views/details.go @@ -6,6 +6,7 @@ import ( "strconv" "strings" + "github.com/atotto/clipboard" "github.com/derailed/k9s/internal/config" "github.com/derailed/k9s/internal/ui" "github.com/derailed/tview" @@ -77,6 +78,7 @@ func (v *detailsView) bindKeys() { tcell.KeyTab: ui.NewKeyAction("Next Match", v.nextCmd, false), tcell.KeyBacktab: ui.NewKeyAction("Previous Match", v.prevCmd, false), tcell.KeyCtrlS: ui.NewKeyAction("Save", v.saveCmd, true), + ui.KeyC: ui.NewKeyAction("Copy", v.cpCmd, false), } } @@ -111,6 +113,14 @@ func (v *detailsView) saveCmd(evt *tcell.EventKey) *tcell.EventKey { return nil } +func (v *detailsView) cpCmd(evt *tcell.EventKey) *tcell.EventKey { + v.app.Flash().Info("Content copied to clipboard...") + if err := clipboard.WriteAll(v.GetText(true)); err != nil { + v.app.Flash().Err(err) + } + return nil +} + func (v *detailsView) backCmd(evt *tcell.EventKey) *tcell.EventKey { if !v.cmdBuff.Empty() { v.cmdBuff.Reset()