.dotfiles/.bin/autoinstall

117 lines
2.9 KiB
Text
Raw Normal View History

2022-10-17 19:37:38 +00:00
#!/usr/bin/env sh
2022-10-22 00:13:06 +00:00
_autoinstall_base () {
2023-01-29 00:57:35 +00:00
_autoinstall_file "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" \
"$HOME/.config/vim/autoload/plug.vim" \
&& [ -x "$(command -v vim)" ] && yes | vim +'PlugInstall --sync' +qa --not-a-term
2023-04-02 17:27:03 +00:00
_autoinstall_git "https://github.com/wbthomason/packer.nvim" \
"$HOME/.local/share/nvim/site/pack/packer/start/packer.nvim" \
&& [ -x "$(command -v nvim)" ] && nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync'
2023-01-29 00:57:35 +00:00
[ ! -x "$(command -v starship)" ] \
&& curl -sS "https://starship.rs/install.sh" | BIN_DIR="$HOME/.local/bin" FORCE=1 sh
2022-10-17 19:37:38 +00:00
_autoinstall_file \
"https://raw.githubusercontent.com/qw3rtman/git-fire/master/git-fire" \
"$HOME/.local/bin/git-fire"
2022-12-20 00:09:47 +00:00
return 0
2022-10-22 00:13:06 +00:00
}
2022-10-17 19:37:38 +00:00
2022-10-22 00:13:06 +00:00
_autoinstall_graphical () {
2022-10-17 19:56:22 +00:00
_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"
2022-10-21 22:58:24 +00:00
_autoinstall_git \
"https://github.com/dracula/gtk.git" \
"$HOME/.themes/Dracula"
2022-10-21 23:39:28 +00:00
_autoinstall_archive \
"https://github.com/dracula/gtk/releases/download/v3.0/Dracula-cursors.tar.xz" \
"$HOME/.icons/Dracula-cursors.tar.xz"
2022-12-20 00:09:47 +00:00
_autoinstall_archive \
"$(curl -fsSL 'https://data.services.jetbrains.com/products?code=TBA&release.type=release&fields=releases' | jq -r '.[0].releases[0].downloads.linux.link')" \
"$HOME/.local/bin/jetbrains-toolbox.tar.gz" \
&& mv -f "$HOME/.local/bin/jetbrains-toolbox-"*"/jetbrains-toolbox" "$HOME/.local/bin/" \
&& rm -rf "$HOME/.local/bin/jetbrains-toolbox-"*
return 0
2022-10-17 19:37:38 +00:00
}
2022-10-22 00:13:06 +00:00
_autoinstall_all () {
_autoinstall_base
_autoinstall_graphical
2022-12-20 00:09:47 +00:00
return 0
2022-10-22 00:13:06 +00:00
}
2022-10-17 19:37:38 +00:00
_autoinstall_git () {
if [ ! -d "$2" ]
then
echo "Installing repo $1 to $2"
mkdir -p "$2"
2023-04-02 17:27:03 +00:00
git clone --depth=1 "$1" "$2" >/dev/null 2>&1
2022-12-20 00:09:47 +00:00
return 0
2022-10-17 19:37:38 +00:00
fi
2022-12-20 00:09:47 +00:00
return 1
2022-10-17 19:37:38 +00:00
}
_autoinstall_file () {
if [ ! -f "$2" ]
then
echo "Installing file $1 to $2"
file_path=$(dirname "$2")
mkdir -p "$file_path"
cd "$file_path" || exit
2022-11-13 22:22:21 +00:00
curl -fsSLo "$2" "$1"
2022-12-20 00:09:47 +00:00
return 0
2022-10-21 23:39:28 +00:00
fi
2022-12-20 00:09:47 +00:00
return 1
2022-10-21 23:39:28 +00:00
}
_autoinstall_archive () {
if [ ! -f "$2" ]
then
echo "Installing archive $1 to $2"
file_path=$(dirname "$2")
mkdir -p "$file_path"
cd "$file_path" || exit
2022-11-13 22:22:21 +00:00
curl -fsSLo "$2" "$1"
2022-10-21 23:39:28 +00:00
tar xaf "$2"
2022-12-20 00:09:47 +00:00
return 0
2022-10-17 19:37:38 +00:00
fi
2022-12-20 00:09:47 +00:00
return 1
2022-10-17 19:37:38 +00:00
}
2022-10-22 23:52:04 +00:00
_autoinstall_env () {
if [ -x "$(command -v envsubst)" ]
then
envsubst < "$1.tpl" > "$1"
2022-12-20 00:09:47 +00:00
return 0
2022-10-22 23:52:04 +00:00
fi
2022-12-20 00:09:47 +00:00
return 1
2022-10-22 23:52:04 +00:00
}
2022-12-20 00:09:47 +00:00
action="${1:-base}"
case $action in
2022-10-17 19:37:38 +00:00
all) _autoinstall_all ;;
2022-10-22 00:13:06 +00:00
base) _autoinstall_base ;;
graphical) _autoinstall_graphical ;;
2022-10-17 19:37:38 +00:00
git) _autoinstall_git "$2" "$3" ;;
file) _autoinstall_file "$2" "$3" ;;
2022-10-21 23:39:28 +00:00
archive) _autoinstall_archive "$2" "$3" ;;
2022-10-22 23:52:04 +00:00
env) _autoinstall_env "$2" ;;
2022-12-20 00:09:47 +00:00
*) echo "'$action' is not a valid action." ;;
2022-10-17 19:37:38 +00:00
esac