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'
25 # Use the script's first argument or the supplied WEBI_VERSION or ''
26 WEBI_VERSION=${1:-${WEBI_VERSION:-}}
28 # Set a temporary directory, if not already set
29 WEBI_TMP=${WEBI_TMP:-"$(mktemp -d -t webinstall-ripgrep.XXXXXXXX)"}
35 # The WEBI bootstrap will define these
36 # but each script should be testable in its own right
38 if [ -z "${WEBI_PKG_URL}" ]; then
39 release_tab="${WEBI_HOST}/api/releases/ripgrep@${WEBI_VERSION:-}.csv?os=$(uname -s)&arch=$(uname -m)&ext=tar&limit=1"
40 WEBI_CSV=$(curl -fsSL "$release_tab" -H "User-Agent: $(uname -a)")
41 WEBI_CHANNEL=$(echo $WEBI_TAB | cut -d ',' -f 3)
42 if [ "error" == "$WEBI_CHANNEL" ]; then
43 echo "could not find release for ripgrep v${WEBI_VERSION}"
46 WEBI_VERSION=$(echo $WEBI_TAB | cut -d ',' -f 1)
47 WEBI_PKG_URL=$(echo $WEBI_TAB | cut -d ',' -f 9)
48 WEBI_PKG_FILE="$WEBI_TMP/$(echo $WEBI_PKG_URL | sed s:.*/::)"
55 new_rg="${HOME}/.local/bin/rg"
57 # Test for existing version
59 cur_rg="$(command -v rg)"
61 if [ -n "$cur_rg" ]; then
62 cur_ver=$(rg --version | head -n 1 | cut -d ' ' -f 2)
63 if [ "$cur_ver" == "$WEBI_VERSION" ]; then
64 echo "ripgrep v$WEBI_VERSION already installed at $cur_rg"
66 elif [ "$cur_rg" != "$new_rg" ]; then
67 echo "WARN: possible conflict with ripgrep v$WEBI_VERSION at $cur_rg"
71 # TODO move download to the webi bootstrap
72 echo Downloading ripgrep v"${WEBI_VERSION}" from "${WEBI_PKG_URL}"
73 curl -fsSL "${WEBI_PKG_URL}" -o "${WEBI_PKG_FILE}"
74 pushd "${WEBI_TMP}" 2>&1 >/dev/null
75 echo Installing ripgrep v${WEBI_VERSION} as "$new_rg"
76 tar xf "${WEBI_PKG_FILE}"
78 mv ./ripgrep-*/rg "${HOME}/.local/bin/"
85 # TODO get better output from pathman / output the path to add as return to webi bootstrap
86 pathman add "$HOME/.local/bin/"