aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Singleton <matt@xcolour.net>2022-02-18 12:29:23 -0600
committerMatt Singleton <matt@xcolour.net>2022-02-18 12:29:23 -0600
commit0b7cfa2c81da8cc1a435620eabdd772a25de0f1f (patch)
treed7a4dfc01c4c0b14b0da3f10ab321629128f7262
parentcf4d6829dfa3a67146ef899808b03fa08af10302 (diff)
check for required binaries and support wget or curl
-rwxr-xr-xdeploy.sh26
1 files changed, 21 insertions, 5 deletions
diff --git a/deploy.sh b/deploy.sh
index c89e7aa..17fd382 100755
--- a/deploy.sh
+++ b/deploy.sh
@@ -1,9 +1,25 @@
#!/bin/bash
-set -euo pipefail
+set -eo pipefail
mkdir -p dotfiles-backup
+if command -v unzip > /dev/null; then
+ UNZIPCMD="unzip"
+fi
+if command -v vim > /dev/null; then
+ VIMCMD="vim"
+fi
+if command -v wget > /dev/null; then
+ DLCMD="wget -O"
+elif command -v curl > /dev/null; then
+ DLCMD="curl -o"
+fi
+if [ -z "$UNZIPCMD" ] || [ -z "$VIMCMD" ] || [ -z "$DLCMD" ]; then
+ echo "requires 'unzip', 'vim', and either 'wget' or 'curl'"
+ exit 1
+fi
+
# XDG layout
xcache="${XDG_CACHE_HOME:-${HOME}/.cache}"
xdata="${XDG_DATA_HOME:-${HOME}/.local/share}"
@@ -54,9 +70,9 @@ cd ..
# install vim-plug
if [ ! -e "$HOME/.vim/autoload/plug.vim" ]; then
mkdir -p "$HOME/.vim/autoload"
- curl -o "$HOME/.vim/autoload/plug.vim" \
+ $DLCMD "$HOME/.vim/autoload/plug.vim" \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
- vim +PlugInstall +qall
+ $VIMCMD +PlugInstall +qall
fi
# create local files
@@ -84,8 +100,8 @@ function get_font {
local font_dir="$HOME/.local/share/fonts/$font_name"
mkdir -p "$font_dir"
if [ ! -d "$font_dir" ] || [ -z "$(ls -A "$font_dir" 2> /dev/null)" ]; then
- curl -o "$font_dir/font.zip" "$font_url"
- unzip "$font_dir/font.zip" "$@" -d "$font_dir"
+ $DLCMD "$font_dir/font.zip" "$font_url"
+ $UNZIPCMD "$font_dir/font.zip" "$@" -d "$font_dir"
rm "$font_dir/font.zip"
new_font=1
fi