/install_ripgrep.sh
https://github.com/carno/scripts · Shell · 27 lines · 18 code · 5 blank · 4 comment · 1 complexity · 7d0be9ddbb992eb4ce8d315fb024dcda MD5 · raw file
- #!/usr/bin/env bash
- set -eo pipefail
- _WORKDIR=$(mktemp -d)
- declare -r _WORKDIR
- _cleanup() {
- rm -rf "${_WORKDIR:?Empty _WORKDIR}"
- }
- trap _cleanup EXIT
- _RG_TGZ=$(curl -s https://api.github.com/repos/BurntSushi/ripgrep/releases/latest | grep -E -o 'https://github.com/BurntSushi/ripgrep/releases/download/.*x86_64-unknown-linux.*tar.gz')
- if [[ -z "${_RG_TGZ}" ]]; then
- echo "[ !! ] Failed to find latest ripgrep release archive"
- exit 3
- fi
- cd "${_WORKDIR}"
- wget -q "${_RG_TGZ}"
- tar -xzf ./*.tar.gz
- # copy binary
- install -v ripgrep*/rg /usr/local/bin/
- # copy man
- install -v ripgrep*/doc/rg.1 /usr/local/share/man/man1/
- # copy completion
- install -v ripgrep*/complete/rg.bash /etc/bash_completion.d/