feat: ProxyCommand support (#26)

* Add base for ProxyCommand

* Fix crashes with ProxyCommand

* Add ProxyCommand to README

---------

Co-authored-by: Simon Gaufreteau <sgaufret@amazon.lu>
This commit is contained in:
Simon Gaufreteau
2026-01-04 17:49:04 +01:00
committed by GitHub
parent 825c534ebe
commit ce9d678652
6 changed files with 87 additions and 32 deletions

View File

@@ -49,7 +49,7 @@ func NewAddForm(hostname string, styles Styles, width, height int, configFile st
}
}
inputs := make([]textinput.Model, 10) // Increased from 9 to 10 for RequestTTY
inputs := make([]textinput.Model, 11)
// Name input
inputs[nameInput] = textinput.New()
@@ -91,6 +91,12 @@ func NewAddForm(hostname string, styles Styles, width, height int, configFile st
inputs[proxyJumpInput].CharLimit = 200
inputs[proxyJumpInput].Width = 50
// ProxyCommand input
inputs[proxyCommandInput] = textinput.New()
inputs[proxyCommandInput].Placeholder = "ssh -W %h:%p Jumphost"
inputs[proxyCommandInput].CharLimit = 200
inputs[proxyCommandInput].Width = 50
// SSH Options input
inputs[optionsInput] = textinput.New()
inputs[optionsInput].Placeholder = "-o Compression=yes -o ServerAliveInterval=60"
@@ -138,6 +144,7 @@ const (
portInput
identityInput
proxyJumpInput
proxyCommandInput
tagsInput
// Advanced tab inputs
optionsInput
@@ -229,11 +236,11 @@ func (m *addFormModel) getFirstInputForTab(tab int) int {
func (m *addFormModel) getInputsForCurrentTab() []int {
switch m.currentTab {
case tabGeneral:
return []int{nameInput, hostnameInput, userInput, portInput, identityInput, proxyJumpInput, tagsInput}
return []int{nameInput, hostnameInput, userInput, portInput, identityInput, proxyJumpInput, proxyCommandInput, tagsInput}
case tabAdvanced:
return []int{optionsInput, remoteCommandInput, requestTTYInput}
default:
return []int{nameInput, hostnameInput, userInput, portInput, identityInput, proxyJumpInput, tagsInput}
return []int{nameInput, hostnameInput, userInput, portInput, identityInput, proxyJumpInput, proxyCommandInput, tagsInput}
}
}
@@ -401,6 +408,7 @@ func (m *addFormModel) renderGeneralTab() string {
{portInput, "Port"},
{identityInput, "Identity File"},
{proxyJumpInput, "ProxyJump"},
{proxyCommandInput, "ProxyCommand"},
{tagsInput, "Tags (comma-separated)"},
}
@@ -489,6 +497,7 @@ func (m *addFormModel) submitForm() tea.Cmd {
port := strings.TrimSpace(m.inputs[portInput].Value())
identity := strings.TrimSpace(m.inputs[identityInput].Value())
proxyJump := strings.TrimSpace(m.inputs[proxyJumpInput].Value())
proxyCommand := strings.TrimSpace(m.inputs[proxyCommandInput].Value())
options := strings.TrimSpace(m.inputs[optionsInput].Value())
remoteCommand := strings.TrimSpace(m.inputs[remoteCommandInput].Value())
requestTTY := strings.TrimSpace(m.inputs[requestTTYInput].Value())
@@ -526,6 +535,7 @@ func (m *addFormModel) submitForm() tea.Cmd {
Port: port,
Identity: identity,
ProxyJump: proxyJump,
ProxyCommand: proxyCommand,
Options: config.ParseSSHOptionsFromCommand(options),
RemoteCommand: remoteCommand,
RequestTTY: requestTTY,