hostutil

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package hostutil provides shared utilities for host URL handling.

Index

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

func IsLocalhost(host string) bool

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

func Normalize(host string) string

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

func OpenBrowser(url string) error

OpenBrowser opens the specified URL in the default browser.

func RequireSecureURL added in v0.2.0

func RequireSecureURL(rawURL string) error

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.

func SplitPane added in v0.3.0

func SplitPane(ctx context.Context, mux Multiplexer, exe string, args ...string) error

SplitPane opens a new pane in the detected multiplexer running the given command. exe and args are passed as discrete tokens — never shell-interpolated.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL