aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/bat/install
diff options
context:
space:
mode:
authorToby Vincent <tobyv13@gmail.com>2021-06-26 15:29:40 -0500
committerToby Vincent <tobyv13@gmail.com>2021-06-26 15:29:40 -0500
commit4ebbfb0874c59ff0144ffee47c252b5eed167012 (patch)
treed12b687d4e975321e460ad3394cfea98a62b276e /bat/install
parentf1385c8594e303e0cd11adfec81acbc701f85e86 (diff)
feat: added bat
Diffstat (limited to 'bat/install')
-rwxr-xr-xbat/install46
1 files changed, 46 insertions, 0 deletions
diff --git a/bat/install b/bat/install
new file mode 100755
index 0000000..e3ce8e0
--- /dev/null
+++ b/bat/install
@@ -0,0 +1,46 @@
+#!/usr/bin/env bash
+
+# general installer for sharkdp's rust based applications
+
+USAGE="Usage: ${0##*/} <app>"
+APPS="Apps: bat, hyperfine, hexyl, fd, vivid, pastel, lscolors, diskus"
+
+app=$1
+
+if [[ -z $app || $app == "help" ]]; then
+ echo $USAGE >&2
+ echo $APPS >&2
+ exit 0
+fi
+
+if [[ "$app" == "list" ]]; then
+ echo $USAGE >&2
+ exit 0
+fi
+
+if [ ! "$(which $app)" ]; then
+ current_version=0.0.0
+ echo "$app: not installed"
+else
+ current_version=$($app --version | grep -oE "[0-9\.]+")
+ echo "$app: found $current_version"
+fi
+
+latest_version=$(curl -s "https://github.com/sharkdp/$app/releases/latest" | grep -oE '[0-9]+.[0-9\.]+')
+
+if [ "$2" ]; then
+ latest_version=$2
+fi
+
+if [[ "$current_version" == "$latest_version" ]]; then
+ echo "$app: up-to-date"
+else
+ echo "$app: new version found $latest_version"
+ echo "$app: downloading..."
+
+ arch="$(dpkg --print-architecture)"
+
+ curl -fsSLo ${app}_${arch}.deb "https://github.com/sharkdp/$app/releases/download/v$latest_version/${app}_${latest_version}_${arch}.deb"
+ sudo dpkg -i ${app}_${arch}.deb
+ rm ${app}_${arch}.deb
+fi