.dotfiles/.bin/autoinstall
2022-11-13 23:22:21 +01:00

109 lines
2.6 KiB
Bash
Executable file

#!/usr/bin/env sh
_autoinstall_base () {
plug_path="$HOME/.config/vim/autoload/plug.vim"
if [ ! -f "$plug_path" ]
then
_autoinstall_file "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" "$plug_path"
[ -x "$(command -v vim)" ] && yes | vim +'PlugInstall --sync' +qa --not-a-term
fi
nvim_dir="$HOME/.config/nvim"
if [ ! -d "$nvim_dir" ]
then
_autoinstall_git "https://github.com/AstroNvim/AstroNvim" "$nvim_dir"
[ -x "$(command -v nvim)" ] && nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync'
fi
if [ ! -x "$(command -v starship)" ]
then
mkdir -p "$HOME/.local/bin"
curl -sS "https://starship.rs/install.sh" | BIN_DIR="$HOME/.local/bin" FORCE=1 sh
fi
_autoinstall_env "$WAKATIME_HOME/.wakatime.cfg"
cp -n "$HOME/.ssh/authorized_keys.default" "$HOME/.ssh/authorized_keys"
_autoinstall_file \
"https://raw.githubusercontent.com/qw3rtman/git-fire/master/git-fire" \
"$HOME/.local/bin/git-fire"
}
_autoinstall_graphical () {
_autoinstall_file \
"https://raw.githubusercontent.com/dracula/alacritty/master/dracula.yml" \
"$HOME/.config/alacritty/dracula.yml"
_autoinstall_file \
"https://raw.githubusercontent.com/dracula/duckduckgo/master/monkeyscript.user.js" \
"$HOME/.local/share/qutebrowser/greasemonkey/ddg-dracula.user.js"
_autoinstall_git \
"https://github.com/dracula/qutebrowser.git" \
"$HOME/.config/qutebrowser/dracula"
_autoinstall_git \
"https://github.com/dracula/gtk.git" \
"$HOME/.themes/Dracula"
_autoinstall_archive \
"https://github.com/dracula/gtk/releases/download/v3.0/Dracula-cursors.tar.xz" \
"$HOME/.icons/Dracula-cursors.tar.xz"
}
_autoinstall_all () {
_autoinstall_base
_autoinstall_graphical
}
_autoinstall_git () {
if [ ! -d "$2" ]
then
echo "Installing repo $1 to $2"
mkdir -p "$2"
git clone "$1" "$2" >/dev/null 2>&1
fi
}
_autoinstall_file () {
if [ ! -f "$2" ]
then
echo "Installing file $1 to $2"
file_path=$(dirname "$2")
mkdir -p "$file_path"
cd "$file_path" || exit
curl -fsSLo "$2" "$1"
fi
}
_autoinstall_archive () {
if [ ! -f "$2" ]
then
echo "Installing archive $1 to $2"
file_path=$(dirname "$2")
mkdir -p "$file_path"
cd "$file_path" || exit
curl -fsSLo "$2" "$1"
tar xaf "$2"
fi
}
_autoinstall_env () {
if [ -x "$(command -v envsubst)" ]
then
envsubst < "$1.tpl" > "$1"
fi
}
case $1 in
all) _autoinstall_all ;;
base) _autoinstall_base ;;
graphical) _autoinstall_graphical ;;
git) _autoinstall_git "$2" "$3" ;;
file) _autoinstall_file "$2" "$3" ;;
archive) _autoinstall_archive "$2" "$3" ;;
env) _autoinstall_env "$2" ;;
*) echo "'$1' is not valid" ;;
esac