PageRenderTime 68ms CodeModel.GetById 33ms RepoModel.GetById 1ms app.codeStats 0ms

/install_ripgrep.sh

https://github.com/carno/scripts
Shell | 27 lines | 18 code | 5 blank | 4 comment | 1 complexity | 7d0be9ddbb992eb4ce8d315fb024dcda MD5 | raw file
  1. #!/usr/bin/env bash
  2. set -eo pipefail
  3. _WORKDIR=$(mktemp -d)
  4. declare -r _WORKDIR
  5. _cleanup() {
  6. rm -rf "${_WORKDIR:?Empty _WORKDIR}"
  7. }
  8. trap _cleanup EXIT
  9. _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')
  10. if [[ -z "${_RG_TGZ}" ]]; then
  11. echo "[ !! ] Failed to find latest ripgrep release archive"
  12. exit 3
  13. fi
  14. cd "${_WORKDIR}"
  15. wget -q "${_RG_TGZ}"
  16. tar -xzf ./*.tar.gz
  17. # copy binary
  18. install -v ripgrep*/rg /usr/local/bin/
  19. # copy man
  20. install -v ripgrep*/doc/rg.1 /usr/local/share/man/man1/
  21. # copy completion
  22. install -v ripgrep*/complete/rg.bash /etc/bash_completion.d/