Tag is a wrapper CLI for ag
and rg
. It parses the output
and creates shell aliases to open vim at the locations of the searches.
Tag is meant to be a transparent wrapper around ag
or rg
, in order
to make this work, you need to add a bit of configuration to your shell
to auto-source the aliases after running a search. Here's some example
configurations for common shells, replace ag
with rg
in these
examples if you'd prefer.
bash - ~/.bashrc
if hash ag 2>/dev/null; then
tag() { command tag "$@" && source /tmp/tag_aliases_$USER 2>/dev/null; }
alias ag="tag ag"
fi
zsh - ~/.zshrc
if (( $+commands[tag] )); then
tag() { command tag "$@" && source /tmp/tag_aliases_$USER 2>/dev/null }
alias ag="tag ag"
fi
fish - ~/.config/fish/functions/tag.fish
function tag
command tag $argv; and source /tmp/tag_aliases_$USER ^/dev/null
alias ag "tag ag"
end
- manual
In order for tag to work, you just need to call it passing the
underlying tool to call, currently only ag
is supported, and then pass
any other arguments you'd like. Then tag will create a file at
/tmp/tag_aliases_$USER
that you need to source from your shell.
On macOS:
$ brew install keith/formulae/tag
Building manually:
Using stack:
$ stack install --local-bin-path /usr/local/bin
This is inspired by this project, I plan to expand it to work with more tools, such as find.