add vim-shell
authorAJ ONeal <aj@therootcompany.com>
Mon, 15 Mar 2021 19:55:33 +0000 (19:55 +0000)
committerAJ ONeal <aj@therootcompany.com>
Mon, 22 Mar 2021 05:52:50 +0000 (05:52 +0000)
vim-shell/README.md [new file with mode: 0644]
vim-shell/install.sh [new file with mode: 0644]

diff --git a/vim-shell/README.md b/vim-shell/README.md
new file mode 100644 (file)
index 0000000..cdec66a
--- /dev/null
@@ -0,0 +1,25 @@
+---
+title: vim-shell
+homepage: https://webinstall.dev/vim-spell
+tagline: |
+  vim shell sets the default shell for vim
+---
+
+To update (replacing the current version) run `webi vim-shell`.
+
+## Cheat Sheet
+
+> `set shell=bash`, always
+
+Especially if you use a non-bash-compatible shell, such as [fish](/fish), you
+should set `set shell=bash` as the **first line** in your `~/.vimrc`.
+
+This script does that for you.
+
+### Why set bash as your vim shell?
+
+Any vim plugin that uses shell scripting will assume _bash_ - just because
+that's the way the world is.
+
+Even if you have a mostly-bash-compatible shell, such as _zsh_, it's a good idea
+to set the vim shell to bash, just to avoid any compatibility issues.
diff --git a/vim-shell/install.sh b/vim-shell/install.sh
new file mode 100644 (file)
index 0000000..fe772bb
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+function __init_vim_shell() {
+    set -e
+    set -u
+
+    mkdir -p "$HOME/.vim/plugins"
+    rm -rf "$HOME/.vim/plugins/shell.vim"
+
+    echo ""
+
+    if [ ! -e "$HOME/.vimrc" ]; then
+        touch "$HOME/.vimrc"
+    fi
+
+    if ! grep 'shell=' -r ~/.vimrc > /dev/null 2> /dev/null; then
+        printf '" bash set as default shell (for compatibility) by webinstall.dev/vim-shell\n' >> ~/.vimrc.new.1
+        printf 'set shell=bash\n' >> ~/.vimrc.new.1
+        printf '\n' >> ~/.vimrc.new.1
+        cat ~/.vimrc >> ~/.vimrc.new.1
+        mv ~/.vimrc.new.1 ~/.vimrc
+    fi
+
+    echo ""
+    echo "Vim default shell is set. Edit with 'vim ~/.vimrc'"
+}
+
+__init_vim_shell