-
-
Save hypevhs/341cc7e428b6d17e6a501065fe761b71 to your computer and use it in GitHub Desktop.
Install ripgrep on Ubuntu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Install ripgrep on Ubuntu | |
# Requires wget(1), curl(1), jq(1) | |
# | |
# I'm not responsible for any damages. Tested on WSL Ubuntu 18.04.4 LTS. | |
# List of changes from upstream: | |
# - use /usr/bin/env bash | |
# - set -e for zero error tolerance, and set -x for debugging | |
# - handle newer ripgrep release directory structure | |
# - set correct file ownerships | |
# - install zsh completion, if necessary | |
set -xe | |
[[ $UID == 0 ]] || { echo "run as sudo to install"; exit 1; } | |
REPO="https://github.com/BurntSushi/ripgrep/releases/download/" | |
RG_LATEST=$(curl -sSL "https://api.github.com/repos/BurntSushi/ripgrep/releases/latest" | jq --raw-output .tag_name) | |
RELEASE="${RG_LATEST}/ripgrep-${RG_LATEST}-x86_64-unknown-linux-musl.tar.gz" | |
TMPDIR=$(mktemp -d) | |
cd $TMPDIR | |
wget -O - ${REPO}${RELEASE} | tar zxf - --strip-component=1 | |
mv rg /usr/local/bin/ | |
mv doc/rg.1 /usr/local/share/man/man1/ | |
mv complete/rg.bash /usr/share/bash-completion/completions/rg | |
chown root:root \ | |
/usr/local/bin/rg \ | |
/usr/local/share/man/man1/rg.1 \ | |
/usr/share/bash-completion/completions/rg | |
# optional: install zsh | |
ZSHDIR="/usr/local/share/zsh/site-functions" | |
if [ -d "$ZSHDIR" ]; then | |
ZSHFILE="$ZSHDIR/_rg" | |
mv complete/_rg "$ZSHFILE" | |
# required for compaudit | |
chmod 755 "$ZSHFILE" | |
chown root:staff "$ZSHFILE" | |
fi | |
mandb | |
# to uninstall: | |
# sudo rm /usr/{local/{bin/rg,share/{man/man1/rg.1,zsh/site-functions/_rg}},share/bash-completion/completions/rg} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment