Code Monkey home page Code Monkey logo

salias's Introduction

Sub-Alias

CircleCI
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.13 or newer
  • bash, Zsh or fish

Installation

$ go get github.com/ktr0731/salias
$ sudo ln $GOPATH/bin/salias /usr/bin/ # If $GOPATH/bin is not in $PATH.

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.

salias's People

Contributors

ktr0731 avatar

Stargazers

 avatar mugi avatar Karthik avatar nokazn avatar Joe Casadonte avatar phyten avatar akiaki susuki avatar TAKAHASHI Manaka avatar Tajima Sachiko avatar Lukas Bachschwell avatar  avatar Sahel Jalal avatar MOCHIZUKI Natsune avatar  avatar KINOSHITA Minoru avatar Nicolas Marshall avatar micnncim avatar Takumi KAGIYAMA avatar Scott Ivey avatar Chuang Zhu avatar Riki Makita avatar Kazuki Hashimoto avatar chyroc avatar Yuki Ito avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

tabo-syu

salias's Issues

alias creator plugin

Provide a new plugin that creates new aliases from frequency used commands, etc.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.