Nested aliases for your shell.
-
Install
na
go install github.com/rostrovsky/na@latest
...or download binary from the releases page and put it somewhere in your
$PATH
. -
Set up your aliases in config file.
-
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
-
-
Use it!
na # and then press Tab ↹ as many times as you need
# 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
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
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.
na
supports all cobra-generated autocompletions:
- bash
- fish
- powershell
- zsh
Below aliases cannot be used due to being cobra bultins:
completion
help
--help
-h
- any alias starting with underscore
_
If you need to see the debug logs, set SODIUM_LOG_LEVEL
env variable to debug
(case insensitive).
MIT