-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathrg.sh
24 lines (21 loc) · 972 Bytes
/
rg.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
RIPGREP_DIR=$HOME/.local/tools/ripgrep
RIPGREP_SRC_NAME=$HOME/.local/packages/ripgrep.tar.gz
RIPGREP_LINK="https://github.com/BurntSushi/ripgrep/releases/download/13.0.0/ripgrep-13.0.0-x86_64-unknown-linux-musl.tar.gz"
USE_CACHE=false
if [[ -z "$(command -v rg)" ]] && [[ ! -f "$RIPGREP_DIR/rg" ]]; then
echo "Install ripgrep"
if [[ "$USE_CACHE" = false || ! -f $RIPGREP_SRC_NAME ]]; then
echo "Downloading ripgrep and renaming"
wget $RIPGREP_LINK -O "$RIPGREP_SRC_NAME"
fi
if [[ ! -d "$RIPGREP_DIR" ]]; then
echo "Creating ripgrep directory under tools directory"
mkdir -p "$RIPGREP_DIR"
echo "Extracting to $HOME/.local/tools/ripgrep directory"
tar zxvf "$RIPGREP_SRC_NAME" -C "$RIPGREP_DIR" --strip-components 1
fi
sed -i "\:"$RIPGREP_DIR":d" "$HOME/.bashrc"
echo "export PATH=\"$RIPGREP_DIR:\$PATH\"" >> "$HOME/.bashrc"
else
echo "ripgrep is already installed. Skip installing it."
fi