Improve autoinstall
This commit is contained in:
parent
b5764c0376
commit
57cd02890a
8 changed files with 92 additions and 187 deletions
62
.bin/autoinstall
Executable file
62
.bin/autoinstall
Executable file
|
@ -0,0 +1,62 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
_autoinstall_all () {
|
||||
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
|
||||
|
||||
if [ -x "$(command -v envsubst)" ]
|
||||
then
|
||||
wakatime_cfg="$WAKATIME_HOME/.wakatime.cfg"
|
||||
wakatime_tpl="$wakatime_cfg.tpl"
|
||||
envsubst < "$wakatime_tpl" > "$wakatime_cfg"
|
||||
fi
|
||||
|
||||
_autoinstall_file \
|
||||
"https://raw.githubusercontent.com/qw3rtman/git-fire/master/git-fire" \
|
||||
"$HOME/.local/bin/git-fire"
|
||||
|
||||
}
|
||||
|
||||
_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 -sSo "$2" "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
case $1 in
|
||||
all) _autoinstall_all ;;
|
||||
git) _autoinstall_git "$2" "$3" ;;
|
||||
file) _autoinstall_file "$2" "$3" ;;
|
||||
*) echo "'$1' is not valid" ;;
|
||||
esac
|
Loading…
Add table
Add a link
Reference in a new issue