refactor: finish moving ssh-* scripts to own installers
[webi-installers/.git] / _vim-example / install.sh
1 #!/bin/bash
2
3 function __init_vim_example() {
4     set -e
5     set -u
6
7     mkdir -p "$HOME/.vim/pack/plugins/start"
8     rm -rf "$HOME/.vim/pack/plugins/start/example.vim"
9     git clone --depth=1 https://github.com/CHANGEME/example.git "$HOME/.vim/pack/plugins/start/example"
10
11     if [ ! -f "$HOME/.vimrc" ]; then
12         touch "$HOME/.vimrc"
13     fi
14
15     mkdir -p ~/.vim/plugins
16     if ! [ -f "$HOME/.vim/plugins/example.vim" ]; then
17         WEBI_HOST=${WEBI_HOST:-"https://webinstall.dev"}
18         curl -fsSL -o ~/.vim/plugins/example.vim "$WEBI_HOST/packages/vim-example/example.vim"
19     fi
20
21     if ! grep 'source.*plugins.example.vim' -r ~/.vimrc > /dev/null 2> /dev/null; then
22         set +e
23         mkdir -p ~/.vim/plugins
24         printf '\n" example: reasonable defaults from webinstall.dev/vim-example\n' >> ~/.vimrc
25         printf 'source ~/.vim/plugins/example.vim\n' >> ~/.vimrc
26         set -e
27         echo ""
28         echo "add ~/.vim/plugins/example.vim"
29         echo "updated ~/.vimrc with 'source ~/.vim/plugins/example.vim'"
30     fi
31
32     echo ""
33     echo "vim-example enabled with reasonable defaults"
34
35 }
36
37 __init_vim_example