ali - cli utility for more convenient and quick work with routine teams
- Improved alias settings. added more flexible settings.
- The second version introduced plugins, templates, and a complete switch to using
yamlconfigurations. support fortomlandjsonconfigurations has been removed.
install by go install:
go install github.com/algrvvv/ali@latestsetup global config
# init global config
ali setupyou can also use the --editor flag to specify the default config editor.
in the example below, all configurations will be edited using
the ali edit command using the vs code code editor
ali setup --editor=codeali completion your_shell > dir/for/completion
# for example
ali completion zsh > ~/tmp/ali
source ~/tmp/ali
# It's better to put this command in your shell configuration, for example ~/.zshrcThe application has a global configuration and any number of local configurations.
To do this, go to the desired directory and use the command: ali init.
All local overlapping aliases have an advantage over global ones.
> ali help
ali - cli app for your aliases
Usage:
ali [flags]
ali [command]
Available Commands:
completion Generate completion script
edit Edit global or local config
help Help about any command
init Init new local config
list Get list aliases
setup Setup global config
version See app version and more information
Flags:
-D, --debug print debug messages
-h, --help help for ali
-L, --local-env use only local env
--output-color string color of the ouput of the parallel command
-p, --parallel do parallel command
--print print result command before start exec
--without-output dont show parallel commands output
Use "ali [command] --help" for more information about a command.The application configuration is stored in a file with the .yaml extension.
The aliases section contains a list of the type alias = command and there is
also the app section, which contains so far the only setting that is responsible
for the default configuration editor.
To edit the global configuration, use: ali edit
To edit the local configuration, use: ali edit --local
By default, vi opens to edit the configuration.
Example:
aliases:
# test alias
test: 'echo "hello world"'
app:
editor: 'vim'Example of a more flexible setup:
aliases:
lara:
parallel: true # commands in alias exec parallel
aliases: [l, laravel] # also can use: ali laravel
desc: start laravel server + vuejs # desc for alias
dir: ~/path/to/project # dir for exec alias
env:
SERVER_PORT: 8888 # env variable for this alias
cmds:
- php artisan serve --port $SERVER_PORT
- npm run devExample of additional settings.
Loading a different configuration. it is possible to download several by specifying several paths.
Recursive loading is currently not supported.
include:
- ~/some/path/
- ~/path/some/.ali
aliases:
t: echo 'test alias'You can also add both global environment variables and local ones, that is, only for a specific alias.
env:
NAME: name
aliases:
t:
env:
NAME: another_name
cmds:
- echo "hello, $NAME"It is also possible to store environment variables in a separate file, which can be entered in .gitignore, so as not to publish in repositories.
by default, the file name should match .alienv.
in order to use another file, you can use
ali --env-file=".another_env_file" yourAliasNamethe syntax of such a file is the simplest. it's just a yaml key map value.
key: valuePass arguments inside a command:
# in configuration
hello: echo "hello, <user>"ali hello --user=$(whoami)
# equal: echo "hello, $(whoami)"passing arguments after the command:
# in configuration
gl: git log -n ali gl 3
# equal: git log -n 3Parallel commands are commands that will be executed in parallel in a single terminal session.
Configuration example:
aliases:
lara:
parallel: true # use for parallel exec
cmds:
- php artisan serve --port $SERVER_PORT
- npm run devTo run parallel commands, use ali CommandName or ali commandName
There are also additional settings for parallel commands.
For example, the --without-output flag to disable command output.
It is also possible to change the output color by using flag --output-color.
Available colors:
- red
- green
- yellow
- blue
- magenta
- cyan
- gray
- orange
- pink
- lime
- white
At the moment, these commands will only be displayed in the list using the-f flag.
since version v1.6.3 it is now possible to create and use variables.
they are stored in the configuration under the tag vars.
They can also be divided into global or local ones.
below is an example from the local yaml config:
vars:
execute: go run main.go
roomcode: myroomcode
user: myuser
aliases:
# golang
single: "{{execute}} --user={{user}}"
host: "{{execute}} --host --code {{roomcode}} --user={{user}}"
guest: "{{execute}} --guest --code {{roomcode}} --user={{user}}"It is also possible to reassign variables for the duration of execution, that is, not in the file, but only once at the time of command execution.
you can follow the example below:
ali single -V_execute=mybuild --printusing the --print flag, we will see the final command to execute.
the output before execution will be as follows:
mybuild --user=myuserhow does it work?
to reassign a variable, you need to use V_ at the beginning of the flag,
and then use the variable name, followed by its value.
important! it is necessary to pass the value through the
=sign.
To see their list, you can use the ali list -v command.
throwing flags that are not used directly or by substituting an argument into a command works as follows. We have an alias:
aliases:
run: go run main.goand we want to add a flag that is missing there, but we don't want to add it to the file, since we won't need it later.
in this case, we will use the following command (we will also use --print to see the final command)
ali run --myarg=myvalue --printouput:
command: go run main.go --myarg=myvalue
important! it is necessary to pass the value through the
=sign.
Templates are prepared examples of .ali configurations that can be created or overwritten into an existing local config.
create new template:
ali templ testTempl --newedit template:
ali templ testTempl --editimport template and create local config:
ali templ testTemplif you want to rewrite existed config:
ali templ testTempl --forceshow templ list:
ali templ --listPlugins are slightly different from templates. unlike them, they are provided so that you can run a script or any other action with a single command.
create new plugin:
ali plug testPlug --newAfter creation, you will be given the path where the plugin should be placed. initially, there will be only its configuration file, in which it is enough to specify the description of the plugin, as well as how to launch it. This approach will add even more flexibility and will not be tied to a specific language.
plugin configuration example:
desc: test python plugin
exec: python3 main.pyyou can use anything in this directory, the main thing is to specify how your plugin will run.
launch plugin:
ali plug testPlugshow plugins list:
ali plug --listTo get logs, use --debug or -D
To use only local aliases, use -L or --local-env.
This can be useful when using ali list -L to output only a list of local aliases.
- добавить разные варианты алиасов;
- добавить разделение команд на несколько, а не использование
&&; - перейти в целом на yaml конфиг;
- синонимы к алиасам;
- правильный вывод всех алиасов;
- можно добавить версию приложения в самое начало (нах);
- переменные окружения;
- поиск по синонимам - сначала по точным совпаденияем, а только потом по синонимам;
- шаблоны;
- директория выполнения команды (dir);
- удалить возможность изменять путь к локальному конфигу;
- include;
- почистить не используемый код;
- дописать документацию в ридми
- улучшить документацию команд именно в утилите, а не в доках