aliases

package
v1.135.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package aliases stores user-defined command shortcuts in ~/.config/bitbottle/aliases.yml. Two flavors:

  • command aliases: `bitbottle alias set prs 'pr list --author @me'`
  • shell aliases: `bitbottle alias set deploy '!ssh prod ...'` (! prefix)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckShadow

func CheckShadow(name string, builtins []string) error

CheckShadow returns an error when name conflicts with a built-in command. Caller passes the list of top-level command names from the root cobra command.

Types

type Entry

type Entry struct {
	Name      string
	Expansion string
}

type Expansion

type Expansion struct {
	// Args is non-nil for command aliases. The first element is the bitbottle
	// subcommand to dispatch; remaining elements are its args. Caller's trailing
	// args (after the alias name on the command line) are appended verbatim.
	Args []string

	// Shell, when non-empty, is the literal command line to hand to $SHELL -c.
	// Args is nil in this case. Argument interpolation ($1..$9, $@) has already
	// been applied.
	Shell string
}

Expansion describes the result of resolving an alias.

func Resolve

func Resolve(store *Store, name string, trailing []string) (*Expansion, bool, error)

Resolve looks up name in store and returns its Expansion.

trailing is the slice of CLI args that followed the alias name — these are either appended (for command aliases) or interpolated into $1..$9 / $@ for shell aliases.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is a thread-safe handle to the aliases file.

func New

func New(dir string) *Store

func (*Store) Delete

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

func (*Store) Get

func (s *Store) Get(name string) (string, bool)

func (*Store) List

func (s *Store) List() []Entry

List returns all aliases sorted by name.

func (*Store) Load

func (s *Store) Load() error

Load reads aliases.yml. A missing file is treated as an empty store.

func (*Store) Save

func (s *Store) Save() error

func (*Store) Set

func (s *Store) Set(name, expansion string) error

Set records expansion under name. Caller must check shadowing of built-ins before calling (see CheckShadow).

Jump to

Keyboard shortcuts

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