aliases

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package aliases stores named shortcuts for `with exec` invocations and generates the shell lines that activate them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ShellLine

func ShellLine(name string, a Alias, shell ShellType) string

ShellLine returns a shell command that defines the given alias.

Types

type Alias

type Alias struct {
	Command      []string `json:"command"`
	User         string   `json:"user,omitempty"`
	Password     string   `json:"password,omitempty"`
	PasswordSet  bool     `json:"password_set,omitempty"`
	PasswordFile string   `json:"password_file,omitempty"`
}

Alias is one saved `with exec` shortcut.

type ShellType

type ShellType int

ShellType selects the shell dialect for ShellLine.

const (
	// ShellBash generates bash-compatible `alias name='...'` lines.
	ShellBash ShellType = iota
	// ShellZsh generates zsh-compatible lines (identical syntax to bash).
	ShellZsh
	// ShellFish generates fish-compatible `alias name '...'` lines.
	ShellFish
)

type Store

type Store struct {
	Aliases map[string]Alias `json:"aliases"`
}

Store is the on-disk collection of aliases.

func Load

func Load(path string) (*Store, error)

Load reads the store from path. A missing file returns an empty store.

func (*Store) Names

func (s *Store) Names() []string

Names returns all alias names sorted alphabetically.

func (*Store) Remove

func (s *Store) Remove(name string) bool

Remove deletes an alias. Returns true if the alias existed.

func (*Store) Save

func (s *Store) Save(path string) error

Save writes the store to path with 0600 permissions.

func (*Store) Set

func (s *Store) Set(name string, a Alias)

Set adds or overwrites an alias.

Jump to

Keyboard shortcuts

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