Documentation
¶
Overview ¶
Package hostutil provides shared utilities for host URL handling.
Index ¶
- func ApplyLayout(ctx context.Context, mux Multiplexer, layout string) error
- func CurrentPaneCommands(ctx context.Context, mux Multiplexer) ([]string, error)
- func IsLocalhost(host string) bool
- func IsRemoteSession() bool
- func Normalize(host string) string
- func OpenBrowser(url string) error
- func RequireSecureURL(rawURL string) error
- func SplitPane(ctx context.Context, mux Multiplexer, exe string, args ...string) error
- type Multiplexer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyLayout ¶ added in v0.3.0
func ApplyLayout(ctx context.Context, mux Multiplexer, layout string) error
ApplyLayout sets the multiplexer pane layout.
func CurrentPaneCommands ¶ added in v0.3.0
func CurrentPaneCommands(ctx context.Context, mux Multiplexer) ([]string, error)
CurrentPaneCommands returns the commands running in each pane (tmux only).
func IsLocalhost ¶
IsLocalhost returns true if host is localhost, a .localhost subdomain, 127.0.0.1, or [::1] (with optional port).
func IsRemoteSession ¶ added in v0.3.0
func IsRemoteSession() bool
IsRemoteSession returns true when running inside an SSH session, detected via SSH_CONNECTION, SSH_CLIENT, or SSH_TTY environment variables.
func Normalize ¶
Normalize converts a host string to a full URL. - Empty string returns empty - localhost/127.0.0.1 defaults to http:// - Other bare hostnames default to https:// - Full URLs are used as-is
func OpenBrowser ¶
OpenBrowser opens the specified URL in the default browser.
func RequireSecureURL ¶ added in v0.2.0
RequireSecureURL returns an error if the URL uses http:// for a non-localhost host. Localhost (127.0.0.1, ::1, *.localhost) is exempt for local development.
Types ¶
type Multiplexer ¶ added in v0.3.0
type Multiplexer string
Multiplexer identifies a detected terminal multiplexer.
const ( MultiplexerNone Multiplexer = "" MultiplexerTmux Multiplexer = "tmux" MultiplexerZellij Multiplexer = "zellij" )
func DetectMultiplexer ¶ added in v0.3.0
func DetectMultiplexer() Multiplexer
DetectMultiplexer returns the active terminal multiplexer, if any.