salias

command module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2018 License: MIT Imports: 13 Imported by: 0

README

Sub-Alias

wercker status
Apply alias to sub-commands

DEMO

Description

I don't like longer commands. So I often use alias.
Just like following:

$ alias d=docker
$ d ps
# `docker ps`

Infrequently, we want to use alias to sub-command.
However, alias command can apply for command only.

salias means sub-alias. salias makes it possible to apply alias to sub-commands.

Usage

Set a subalias:

$ salias <program> <subalias>=<subcommand>

Remove a subalias:

$ unsalias <program> <subalias>

For example:

$ salias go i=install # set a sub-alias
$ salias docker c=container
$ exec $SHELL # reload the shell

$ go i github.com/golang/go
# `go install github.com/golang/go` 

$ docker c ls
# `docker container ls`

$ unsalias go i # delete a sub-alias

Equipments

  • Go v1.8 or newer
  • bash, Zsh or fish

Installation

$ export GOPATH=~/go # if $GOPATH is not set
$ go get github.com/lycoris0731/salias
$ sudo ln $GOPATH/bin/salias /usr/bin/
Set sub-alias definition file

Please create one of these files:

  • $SALIAS_PATH

  • $XDG_CONFIG_HOME/salias/salias.toml

  • $HOME/salias.toml

Then use salias <command> <subalias>=<subcommand> to set sub-alias. Or edit salias.toml manually.

Make sub-alias initializes automatically

Add following command.

.bashrc or .zshrc.

source <(salias --init) # or `salias -i` for short

config.fish

source (salias --init | psub)

How It Works

When initialization, salias registers the command as salias's alias.

# [go]
# b = "build"
$ source <(salias --init)
$ type go
go is an alias for salias --run go

salias find sub-alias that is sub-command of passed command as arguments.
If hit sub-alias, execute it.
Or not found, execute as it is.

License

Please see LICENSE.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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