Sub-alias
Go Makefile
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
Gopkg.lock
Gopkg.toml
LICENSE
Makefile
README.md
main.go
main_test.go
salias_test.toml
wercker.yml

README.md

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.

Example

~/salias.toml

[go]
i = "install"
b = "build"
r = "run"

[docker]
i = "image"
c = "container"

[docker-compose]
l = "logs -f"
$ go i github.com/golang/go
# `go install github.com/golang/go` 

$ docker i ls
# `docker image ls`

$ alias d=docker
$ d c ls
# `docker container ls`

Equipments

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

Installation

$ go get github.com/lycoris0731/salias

Usage

Set sub-alias definition file

Please set the file to one of following.

  • $SALIAS_PATH
  • $XDG_CONFIG_HOME/salias/salias.toml
  • $HOME/salias.toml

Add following command.

.bashrc or .zshrc.

source <(salias __init__)

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 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.