chore(style): add shebang, set bash strict mode, create function
[webi-installers/.git] / vim-shell / install.sh
1 #!/bin/bash
2
3 function __init_vim_shell() {
4     set -e
5     set -u
6
7     mkdir -p "$HOME/.vim/plugins"
8     rm -rf "$HOME/.vim/plugins/shell.vim"
9
10     echo ""
11
12     if [ ! -e "$HOME/.vimrc" ]; then
13         touch "$HOME/.vimrc"
14     fi
15
16     if ! grep 'shell=' -r ~/.vimrc > /dev/null 2> /dev/null; then
17         printf '" bash set as default shell (for compatibility) by webinstall.dev/vim-shell\n' >> ~/.vimrc.new.1
18         printf 'set shell=bash\n' >> ~/.vimrc.new.1
19         printf '\n' >> ~/.vimrc.new.1
20         cat ~/.vimrc >> ~/.vimrc.new.1
21         mv ~/.vimrc.new.1 ~/.vimrc
22     fi
23
24     echo ""
25     echo "Vim default shell is set. Edit with 'vim ~/.vimrc'"
26 }
27
28 __init_vim_shell