Skip to content

Command Line Tool

Linwei edited this page Feb 29, 2020 · 28 revisions

This plugin provides you an asyncrun.py script (in the bin folder) when you want to run tasks right in your shell.

Setup

To use it, copy the files from bin to /usr/local/bin or ~/bin, or simpily add bin folder to your $PATH in bashrc.

Usage

Then, in any child directories of your project, just type:

$ asynctask project-build

You don't have to jump back to your project root manually, because profile-build has a cwd=<root>.

Command

$ asynctask <taskname> [path]

Run the given task with the path, the path can be either a file name or a directory. It is used to extract macros like $(VIM_FILENAME) or $(VIM_ROOT), if path is omitted, current working directory will be used:

$ asynctask project-build .
$ asynctask project-build

The two commands works exactly the same way. The two below are also equivalent:

$ asynctask project-build ../project2
$ cd ../project2 && asynctask project-build && cd -

More examples:

# run with a file name, for tasks containing $(VIM_FILENAME), $(VIM_FILEPATH) ...
$ asynctask file-build hello.c

# execute the file
$ asynctask file-run hello.c

# run with a path, when the path is omitted, current cwd is used.
$ asynctask project-build ../project2

# build with "release" profile
$ asynctask -profile=release project-build

# run with interactive mode
$ asynctask -i

# use fzf to select tasks
$ asynctask -f

alias asynctask -f to task and use fzf for interactive mode:

Configurate

The config file locates in ~/.config/asynctask/asynctask.ini, no need to create this file if you don't want to change the default values below:

[default]
# comma separated list for additional global configs
extra_config=~/.vim/tasks.ini
root_marker=.git,.svn,.root,.project,.hg
cfg_name=.tasks
system=win32

# file type detection, to match commands with filetypes and fill $(VIM_FILETYPE) field.
# in asynctasks.vim, vim did this for you, but in command line, we will detect ourself.
[filetype]
asm=*.asm,*.s,*.S
bash=*.bash
c=*.[cChH],.[cChH].in
cmake=CMakeLists.txt
cpp=*.[cChH]pp,*.hh,*.[ch]xx,*.cc,*.cc.in,*.cpp.in,*.hh.in,*.cxx.in
cs=*.cs
....
text=*.txt
vim=*.vim
yaml=*.yaml,*.yml
zsh=*.zsh

This config is useful when you need change one or more options:

[default]
system=macos
extra_config=~/.vim/tasks,~/.local/etc/tasks
cfg_name=.git/tasks.ini

[filetype]
# add a new filetype
actionscript=*.as,*.as3

Shell and Vim Specific Task

Use slash in the section name:

[task1/vim]
command=echo for vim only

[task2/shell]
command=echo for shell only

Command Line Snippets

Have difficult to remember long commands ? tired to type repetitive commands ??

asynctask.py would also be useful when you need a bash snippets manager:

Clone this wiki locally