PageRenderTime 52ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/bin/ripgrep_debian_install.sh

https://github.com/steeef/dotfiles
Shell | 25 lines | 18 code | 6 blank | 1 comment | 7 complexity | fd9d1160df4c210e2715bf4aa86ce259 MD5 | raw file
  1. #!/usr/bin/env bash
  2. set -e
  3. RIPGREP_VERSION="12.1.1"
  4. RIPGREP_URL="https://github.com/BurntSushi/ripgrep/releases/download/${RIPGREP_VERSION}/ripgrep_${RIPGREP_VERSION}_amd64.deb"
  5. RIPGREP_CHECKSUM="18ef498312073da55d2f2f65c6a906085c68368a23c9a45a87fcb8539be96608"
  6. function cleanup {
  7. if [ -d "${RIPGREP_DOWNLOAD_DIR}" ]; then
  8. rm -rf "${RIPGREP_DOWNLOAD_DIR}"
  9. fi
  10. }
  11. trap cleanup EXIT
  12. if ! command -v rg >/dev/null 2>&1 \
  13. || [ "$(rg --version | head -n 1 | awk '{print $2}')" != "${RIPGREP_VERSION}" ]; then
  14. RIPGREP_DOWNLOAD_DIR="$(mktemp -d)"
  15. (curl -fsSL "${RIPGREP_URL}" -o "${RIPGREP_DOWNLOAD_DIR}/ripgrep.deb" \
  16. && cd "${RIPGREP_DOWNLOAD_DIR}" \
  17. && echo "${RIPGREP_CHECKSUM} *ripgrep.deb" | sha256sum -c - \
  18. && sudo dpkg -i ripgrep.deb)
  19. fi