Giter Club home page Giter Club logo

na's Introduction

sodium

Sodium

Nested aliases for your shell.

Quick start

  1. Install na

    go install github.com/rostrovsky/na@latest

    ...or download binary from the releases page and put it somewhere in your $PATH.

  2. Set up your aliases in config file.

  3. Generate autocompletions for your shell:

    • bash

      source <(na completion bash)
    • zsh

      source <(na completion zsh)
    • powershell

      Register-ArgumentCompleter -CommandName na -ScriptBlock $__naCompleterBlock
      na completion powershell | Out-String | Invoke-Expression
    • fish

      na completion fish | source
  4. Use it!

    na # and then press Tab ↹ as many times as you need

Config file

Config file schema

Minimal form

# minimal form config example
aliases:
  ssh:
    dev:
      host-x: ssh user@host-x
      host-y: ssh user@host-y
    prod:
      host-a: ssh user@host-a
      host-b: ssh user@host-b
  grep:
    heron: grep -hEron --with-filename --color=always

Full form

Compared to the minimal form, in the full form:

  • you must add mandatory _cmd key which contains aliased command
  • you can add optional _info key that enriches autocompletion hints with description.
# full form config example
aliases:
  ssh:
    _info: aliases for SSH connections
    dev:
      _info: DEV environments aliases
      host-x:
        _info: makes ssh connection to host X on DEV env
        _cmd: ssh user@host-x
      host-y:
        _info: makes ssh connection to host Y on DEV env
        _cmd: ssh user@host-y
    prod:
      _info: PROD environments aliases
      host-a:
        _info: makes ssh connection to host A on PROD env
        _cmd: ssh user@host-a
      host-b:
        _info: makes ssh connection to host B on PROD env
        _cmd: ssh user@host-b
  grep: # _info key is completely optional though recommended
    heron:
      _cmd: grep -hEron --with-filename --color=always

Config file location

By default, na expects configuration file placed in ~/.config/sodium/.narc.yaml (or .yml).

You can override default config file location by setting SODIUM_CONFIG environment variable.

Supported shells

na supports all cobra-generated autocompletions:

  • bash
  • fish
  • powershell
  • zsh

Reserved aliases

Below aliases cannot be used due to being cobra bultins:

  • completion
  • help
  • --help
  • -h
  • any alias starting with underscore _

Debug logs

If you need to see the debug logs, set SODIUM_LOG_LEVEL env variable to debug (case insensitive).

License

MIT

na's People

Contributors

rostrovsky avatar

Watchers

 avatar

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.