2 # homepage: https://github.com/BurntSushi/ripgrep
3 # tagline: a modern drop-in grep replacement
6 # `rg` is a drop-in replacement for `grep`, that respects `.gitignore` and `.ignore`, has all of the sensible default options you want (colors, numbers, etc) turned on by default, is written in Rust, and simply outperforms grep in every imaginable way. R.I.P. grep.
10 # rg <search-term> # searches recursively, ignoing .git, node_modules, etc
14 # rg 'function doStuff'
24 # Use the script's first argument or the supplied WEBI_VERSION or ''
25 WEBI_VERSION=${1:-${WEBI_VERSION:-}}
27 # Set a temporary directory, if not already set
28 WEBI_TMP=${WEBI_TMP:-"$(mktemp -d -t webinstall-ripgrep.XXXXXXXX)"}
34 # The WEBI bootstrap will define these
35 # but each script should be testable in its own right
37 if [ -z "${WEBI_PKG_URL}" ]; then
38 release_tab="${WEBI_HOST}/api/releases/ripgrep@${WEBI_VERSION:-}.csv?os=$(uname -s)&arch=$(uname -m)&ext=tar&limit=1"
39 WEBI_CSV=$(curl -fsSL "$release_tab" -H "User-Agent: $(uname -a)")
40 WEBI_CHANNEL=$(echo $WEBI_TAB | cut -d ',' -f 3)
41 if [ "error" == "$WEBI_CHANNEL" ]; then
42 echo "could not find release for ripgrep v${WEBI_VERSION}"
45 WEBI_VERSION=$(echo $WEBI_TAB | cut -d ',' -f 1)
46 WEBI_PKG_URL=$(echo $WEBI_TAB | cut -d ',' -f 9)
47 WEBI_PKG_FILE="$WEBI_TMP/$(echo $WEBI_PKG_URL | sed s:.*/::)"
54 new_rg="${HOME}/.local/bin/rg"
56 # Test for existing version
58 cur_rg="$(command -v rg)"
60 if [ -n "$cur_rg" ]; then
61 cur_ver=$(rg --version | head -n 1 | cut -d ' ' -f 2)
62 if [ "$cur_ver" == "$WEBI_VERSION" ]; then
63 echo "ripgrep v$WEBI_VERSION already installed at $cur_rg"
65 elif [ "$cur_rg" != "$new_rg" ]; then
66 echo "WARN: possible conflict with ripgrep v$WEBI_VERSION at $cur_rg"
70 # TODO move download to the webi bootstrap
71 echo Downloading ripgrep v"${WEBI_VERSION}" from "${WEBI_PKG_URL}"
72 curl -fsSL "${WEBI_PKG_URL}" -o "${WEBI_PKG_FILE}"
73 pushd "${WEBI_TMP}" 2>&1 >/dev/null
74 echo Installing ripgrep v${WEBI_VERSION} as "$new_rg"
75 tar xf "${WEBI_PKG_FILE}"
77 mv ./ripgrep-*/rg "${HOME}/.local/bin/"
84 # TODO get better output from pathman / output the path to add as return to webi bootstrap
85 pathman add "$HOME/.local/bin/"