diff --git a/README.md b/README.md index 4b50d7f..aca88f0 100644 --- a/README.md +++ b/README.md @@ -168,6 +168,7 @@ make run | ↑↓/jk | Navigate servers | | Enter | SSH into selected server | | c | Copy SSH command to clipboard | +| h | Copy Host to clipboard | | g | Ping selected server | | r | Refresh background data | | a | Add server | diff --git a/internal/adapters/ui/handlers.go b/internal/adapters/ui/handlers.go index 897e053..71c5db0 100644 --- a/internal/adapters/ui/handlers.go +++ b/internal/adapters/ui/handlers.go @@ -71,6 +71,9 @@ func (t *tui) handleGlobalKeys(event *tcell.EventKey) *tcell.EventKey { case 'c': t.handleCopyCommand() return nil + case 'h': + t.handleCopyHost() + return nil case 'g': t.handlePingSelected() return nil @@ -139,6 +142,17 @@ func (t *tui) handleCopyCommand() { } } +func (t *tui) handleCopyHost() { + if server, ok := t.serverList.GetSelectedServer(); ok { + host := server.Host + if err := clipboard.WriteAll(host); err == nil { + t.showStatusTemp("Copied: " + host) + } else { + t.showStatusTemp("Failed to copy to clipboard") + } + } +} + func (t *tui) handleTagsEdit() { if server, ok := t.serverList.GetSelectedServer(); ok { t.showEditTagsForm(server) diff --git a/internal/adapters/ui/server_details.go b/internal/adapters/ui/server_details.go index 48befc3..1c89574 100644 --- a/internal/adapters/ui/server_details.go +++ b/internal/adapters/ui/server_details.go @@ -213,7 +213,7 @@ func (sd *ServerDetails) UpdateServer(server domain.Server) { } // Commands list - text += "\n[::b]Commands:[-]\n Enter: SSH connect\n f: Port forward\n x: Stop forwarding\n c: Copy SSH command\n g: Ping server\n r: Refresh list\n a: Add new server\n e: Edit entry\n t: Edit tags\n d: Delete entry\n p: Pin/Unpin" + text += "\n[::b]Commands:[-]\n Enter: SSH connect\n f: Port forward\n x: Stop forwarding\n c: Copy SSH command\n h: Copy Host\n g: Ping server\n r: Refresh list\n a: Add new server\n e: Edit entry\n t: Edit tags\n d: Delete entry\n p: Pin/Unpin" sd.TextView.SetText(text) } diff --git a/internal/adapters/ui/status_bar.go b/internal/adapters/ui/status_bar.go index 1d3c690..7fc3573 100644 --- a/internal/adapters/ui/status_bar.go +++ b/internal/adapters/ui/status_bar.go @@ -20,7 +20,7 @@ import ( ) func DefaultStatusText() string { - return "[white]↑↓[-] Navigate • [white]Enter[-] SSH • [white]f[-] Forward • [white]x[-] Stop Forward • [white]c[-] Copy SSH • [white]a[-] Add • [white]e[-] Edit • [white]g[-] Ping • [white]d[-] Delete • [white]p[-] Pin/Unpin • [white]/[-] Search • [white]q[-] Quit" + return "[white]↑↓[-] Navigate • [white]Enter[-] SSH • [white]f[-] Forward • [white]x[-] Stop Forward • [white]c[-] Copy SSH • [white]h[-] Copy Host • [white]a[-] Add • [white]e[-] Edit • [white]g[-] Ping • [white]d[-] Delete • [white]p[-] Pin/Unpin • [white]/[-] Search • [white]q[-] Quit" } func NewStatusBar() *tview.TextView {