Last active
September 5, 2019 06:37
-
-
Save jeebak/705718dfda924474b89b3a5848095f40 to your computer and use it in GitHub Desktop.
Test Drive Vim / Emacs Distributions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# ----------------------------------------------------------------------------- | |
# This is a stoopid simple wrapper script to conveniently test drive different | |
# vim/emacs distributions w/out messing up your own vim/emacs environment. | |
# It accomplishes this by "installing" them in their own isolated "$HOME" | |
# environment (under their own "$HOME/.cache/test-drive-vimacs/$DISTRO" | |
# folder.) We save and export the real "$HOME" value as "$REAL_HOME" making it | |
# available during the editing session, in case its needed. | |
# Inspired by "2.15 Try Spacemacs without modifying my existing Emacs configuration?" | |
# http://spacemacs.org/doc/FAQ.html#try-spacemacs-without-modifying-my-existing-emacs-configuration | |
# The trade-off is that more disk space is being used, (most likely) due to | |
# duplicated plugins. | |
# du -hs .cache/test-drive-vimacs/* [~] | |
# 100M .cache/test-drive-vimacs/doom-emacs | |
# 25M .cache/test-drive-vimacs/dot_emacs | |
# 24M .cache/test-drive-vimacs/dotemacs | |
# 46M .cache/test-drive-vimacs/emacsrocks | |
# 19M .cache/test-drive-vimacs/emacs-from-scratch | |
# 68M .cache/test-drive-vimacs/emacs-live | |
# 12M .cache/test-drive-vimacs/ergoemacs | |
# 505M .cache/test-drive-vimacs/evervim | |
# 33M .cache/test-drive-vimacs/frontmacs | |
# 1.5M .cache/test-drive-vimacs/minimal-plug-vim | |
# 334M .cache/test-drive-vimacs/rafi-vim | |
# 96M .cache/test-drive-vimacs/redguardtoo-emacs | |
# 38M .cache/test-drive-vimacs/space-vim | |
# 115M .cache/test-drive-vimacs/spacemacs | |
# 101M .cache/test-drive-vimacs/spacevim | |
# 300M .cache/test-drive-vimacs/webvim | |
# The vim based distributions selected for this script were just some results | |
# from a Google search that seemed relatively modern and still maintained. | |
# The emacs based distributions are from: | |
# - https://github.com/emacs-tw/awesome-emacs | |
# - https://github.com/caisah/emacs.dz | |
# - https://www.emacswiki.org/emacs/StarterKits | |
# Most of these are "evil" (vi layer) based, with these exception: | |
# - emacs-live | |
# - emacsrocks | |
# - ergoemacs | |
# - frontmacs | |
# Install this script somewhere in your $PATH that's writable, for example, I | |
# use $HOME/.local/bin. Just run it, and it'll create the necessary symlinks | |
# and do all/most(?) of the setup. | |
# ----------------------------------------------------------------------------- | |
# basename: "${var##*/}" | |
# dirname: "${var%/*}" | |
BASE_DIR="$(cd "${0%/*}" || exit; pwd -P)" | |
REAL_ME="$(realpath "$0")" | |
REAL_ME="${REAL_ME##*/}" | |
DISTRO="${0##*/}" | |
EDITOR="vim" | |
# ----------------------------------------------------------------------------- | |
# Each of these prep-* functions contain the installation/setup steps from | |
# each distributions' websites. | |
set-emacs-clone() { | |
CLONE="$TARGET/${1:-.emacs.d}" | |
} | |
set-vim-clone() { | |
CLONE="$TARGET/${1:-.vim}" | |
} | |
update-clone() { | |
if [[ "$UPDATE" == true && -n "$CLONE" ]]; then | |
pushd "$CLONE" | |
git pull | |
git submodule init | |
git submodule update | |
popd | |
fi | |
} | |
prep-doom-emacs() { | |
set-emacs-clone | |
if [[ ! -d "$CLONE" ]]; then | |
command git clone https://github.com/hlissner/doom-emacs "$CLONE" | |
pushd "$CLONE" | |
./bin/doom quickstart | |
popd | |
fi | |
update-clone | |
EDITOR="emacs" | |
} | |
prep-dot_emacs() { | |
set-emacs-clone | |
if [[ ! -d "$CLONE" ]]; then | |
command git clone https://github.com/chrismccord/dot_emacs.git "$CLONE" | |
pushd "$CLONE" | |
sh install.sh | |
if [[ ! -e "$CLONE/vendor/osx-clipboard-mode/osx-clipboard.el" ]]; then | |
curl -fLo "$CLONE/vendor/osx-clipboard-mode/osx-clipboard.el" --create-dirs \ | |
https://raw.githubusercontent.com/chrismccord/osx-clipboard-mode/master/osx-clipboard.el | |
fi | |
popd | |
fi | |
export PATH="$HOME/.cask/bin:$PATH" | |
update-clone | |
EDITOR="emacs" | |
} | |
prep-dotemacs() { | |
set-emacs-clone | |
if [[ ! -d "$CLONE" ]]; then | |
command git clone https://github.com/bling/dotemacs.git "$CLONE" | |
fi | |
update-clone | |
EDITOR="emacs" | |
} | |
prep-emacs-from-scratch() { | |
set-emacs-clone | |
# https://blog.jft.rocks/emacs/emacs-from-scratch.html | |
# https://gist.github.com/huytd/6b785bdaeb595401d69adc7797e5c22c | |
local base_url="https://gist.githubusercontent.com/huytd/6b785bdaeb595401d69adc7797e5c22c/raw/f1c1eef7b998e9271951d63242f61b54e204c3dc" | |
local file | |
if [[ ! -d "$CLONE" ]]; then | |
mkdir -p "$CLONE" | |
for file in customized.org-mode.theme.el init.el; do | |
curl -o "$CLONE/$file" "$base_url/$file" | |
done | |
fi | |
update-clone | |
EDITOR="emacs" | |
} | |
prep-emacs-live() { | |
set-emacs-clone | |
if [[ ! -d "$CLONE" ]]; then | |
command git clone https://github.com/overtone/emacs-live "$CLONE" | |
fi | |
update-clone | |
EDITOR="emacs" | |
} | |
prep-emacsrocks() { | |
set-emacs-clone | |
if [[ ! -d "$CLONE" ]]; then | |
command git clone --recursive git://github.com/magnars/.emacs.d.git "$CLONE" | |
fi | |
update-clone | |
EDITOR="emacs" | |
} | |
prep-ergoemacs() { | |
set-emacs-clone | |
if [[ ! -d "$CLONE" ]]; then | |
mkdir -p "$CLONE" | |
pushd "$CLONE" | |
command git clone https://github.com/ergoemacs/ergoemacs-mode.git | |
cat <<EOT >> init.el | |
;; http://ergoemacs.github.io/ | |
(add-to-list 'load-path "~/.emacs.d/ergoemacs-mode") | |
(require 'ergoemacs-mode) | |
(setq ergoemacs-theme nil) ;; Uses Standard Ergoemacs keyboard theme | |
(setq ergoemacs-keyboard-layout "us") ;; Assumes QWERTY keyboard layout | |
(ergoemacs-mode 1) | |
EOT | |
popd | |
fi | |
update-clone | |
EDITOR="emacs" | |
} | |
prep-evervim() { | |
set-vim-clone .EverVim | |
if [[ ! -d "$CLONE" ]]; then | |
command git clone https://github.com/LER0ever/EverVim "$CLONE" | |
pushd "$CLONE" | |
sh Boot-EverVim.sh | |
popd | |
fi | |
update-clone | |
} | |
prep-frontmacs() { | |
set-emacs-clone | |
if [[ ! -d "$CLONE" ]]; then | |
mkdir -p "$CLONE" | |
pushd "$CLONE" | |
curl -O https://raw.githubusercontent.com/thefrontside/frontmacs/master/scripts/init-frontmacs.el | |
cat <<EOT >> init.el | |
;; boot frontmacs | |
(load (expand-file-name "init-frontmacs.el" user-emacs-directory)) | |
EOT | |
popd | |
fi | |
update-clone | |
EDITOR="emacs" | |
} | |
prep-minimal-plug-vim() { | |
if [[ ! -e "$TARGET/.vimrc" ]]; then | |
curl -fLo "$TARGET/.vimrc" --create-dirs \ | |
https://raw.githubusercontent.com/mhinz/vim-galore/master/static/minimal-vimrc.vim | |
mkdir -p "$HOME/.vim/files/"{backup,info,swap,undo} | |
cat <<EOT >> "$TARGET/.vimrc" | |
" Setup Plug | |
if empty(glob('~/.vim/autoload/plug.vim')) | |
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs | |
\\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
autocmd VimEnter * PlugInstall --sync | source \$MYVIMRC | |
endif | |
" Specify a directory for plugins | |
" - For Neovim: ~/.local/share/nvim/plugged | |
" - Avoid using standard Vim directory names like 'plugin' | |
call plug#begin('~/.vim/plugged') | |
" Make sure you use single quotes | |
Plug 'cocopon/iceberg.vim' "{{{ | |
" :antarctica: Dark blue color scheme for Vim and Neovim https://cocopon.github.io/iceberg.vim/ | |
"}}} | |
" Initialize plugin system | |
call plug#end() | |
try | |
colorscheme iceberg | |
catch /^Vim\%((\a\+)\)\=:E185/ | |
" deal with it | |
endtry | |
EOT | |
vim +PlugInstall +qall | |
fi | |
update-clone | |
} | |
prep-rafi-vim() { | |
set-vim-clone .config/nvim | |
if [[ ! -d "$CLONE" ]]; then | |
command git clone https://github.com/rafi/vim-config "$CLONE" | |
pushd "$TARGET" | |
ln -nfs .config/nvim .vim | |
popd | |
pushd "$CLONE" | |
./venv.sh | |
make test | |
make | |
popd | |
fi | |
update-clone | |
} | |
prep-redguardtoo-emacs() { | |
set-emacs-clone | |
if [[ ! -d "$CLONE" ]]; then | |
command git clone https://github.com/redguardtoo/emacs.d.git "$CLONE" | |
fi | |
EDITOR="emacs" | |
update-clone | |
} | |
prep-spacemacs() { | |
set-emacs-clone | |
if [[ ! -d "$CLONE" ]]; then | |
command git clone [email protected]:syl20bnr/spacemacs.git "$CLONE" | |
fi | |
EDITOR="emacs" | |
update-clone | |
} | |
prep-space-vim() { | |
set-vim-clone .space-vim | |
if [[ ! -d "$CLONE" ]]; then | |
command git clone https://github.com/liuchengxu/space-vim.git "$CLONE" | |
pushd "$CLONE" | |
make vim neovim | |
popd | |
fi | |
update-clone | |
} | |
prep-spacevim() { | |
set-vim-clone .SpaceVim | |
if [[ ! -d "$CLONE" ]]; then | |
command git clone https://github.com/SpaceVim/SpaceVim.git "$CLONE" | |
pushd "$TARGET" | |
ln -nfs .SpaceVim .vim | |
popd | |
fi | |
update-clone | |
} | |
prep-webvim() { | |
set-vim-clone | |
if [[ ! -d "$CLONE" ]]; then | |
command git clone https://github.com/krampstudio/webvim.git "$CLONE" | |
pushd "$TARGET" | |
ln -s .vim/.vimrc .vimrc | |
ln -s .vim/.tern-project .tern-project | |
popd | |
fi | |
update-clone | |
} | |
# ----------------------------------------------------------------------------- | |
# Create symlinks, if they don't exist. | |
pushd "$BASE_DIR" > /dev/null 2>&1 | |
while read -r -u3 line; do | |
[[ ! -e "$line" ]] && ln -nfsv "$REAL_ME" "$line" | |
done 3< <(grep -E -o '^prep-[^(]*' "$BASE_DIR/$REAL_ME" | sed 's/prep-//') | |
popd > /dev/null 2>&1 | |
# ----------------------------------------------------------------------------- | |
# Validate | |
if [[ "$(type -t "prep-${DISTRO}")" != "function" ]]; then | |
cat <<EOT | |
Invoke as one of these: | |
$(grep -E -o '^prep-[^(]*' "$BASE_DIR/$REAL_ME" | sed 's/prep-//;s/^/ /') | |
EOT | |
exit | |
fi | |
# ----------------------------------------------------------------------------- | |
TARGET="${XDG_CACHE_HOME:-$HOME/.cache}/test-drive-vimacs" | |
# Ensure that our cache folder exists | |
[[ ! -d "$TARGET" ]] && mkdir -p "$TARGET" | |
# ----------------------------------------------------------------------------- | |
TARGET="$TARGET/$DISTRO" | |
export REAL_HOME="$HOME" # Export this to make it available w/in the session | |
export HOME="$TARGET" | |
"prep-${DISTRO}" | |
# ----------------------------------------------------------------------------- | |
exec "$EDITOR" "$@" | |
# ----------------------------------------------------------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# ----------------------------------------------------------------------------- | |
# This is a stoopid simple wrapper script to conveniently test drive different | |
# zsh distributions w/out messing up your own zsh environment. | |
# It accomplishes this by "installing" them in their own isolated "$HOME" | |
# environment (under their own "$HOME/.cache/test-drive-zsh/$DISTRO" | |
# folder.) We save and export the real "$HOME" value as "$REAL_HOME" making it | |
# available during the editing session, in case its needed. | |
# Inspired by "2.15 Try Spacemacs without modifying my existing Emacs configuration?" | |
# http://spacemacs.org/doc/FAQ.html#try-spacemacs-without-modifying-my-existing-emacs-configuration | |
# The trade-off is that more disk space is being used, (most likely) due to | |
# duplicated plugins. | |
# du -hs .cache/test-drive-zsh/* | |
# 19M .cache/test-drive-zsh/zplug | |
# Install this script somewhere in your $PATH that's writable, for example, I | |
# use $HOME/.local/bin. Just run it, and it'll create the necessary symlinks | |
# and do all/most(?) of the setup. | |
# ----------------------------------------------------------------------------- | |
# basename: "${var##*/}" | |
# dirname: "${var%/*}" | |
BASE_DIR="$(cd "${0%/*}" || exit; pwd -P)" | |
REAL_ME="$(realpath "$0")" | |
REAL_ME="${REAL_ME##*/}" | |
DISTRO="${0##*/}" | |
SHELL="zsh" | |
# ----------------------------------------------------------------------------- | |
# Each of these prep-* functions contain the installation/setup steps from | |
# each distributions' websites. | |
prep-zsh-zplug() { | |
export ZPLUG_HOME="$TARGET/.cache/zplug" | |
if [[ ! -d "$ZPLUG_HOME" ]]; then | |
[[ -d "$TARGET" ]] || mkdir -p "$TARGET" | |
pushd "$TARGET" | |
cat <<EOT > .zshrc | |
# https://github.com/zplug/zplug | |
export ZPLUG_HOME="\$HOME/.cache/zplug" | |
if [[ ! -d "\$ZPLUG_HOME" ]]; then | |
command git clone https://github.com/zplug/zplug "\$ZPLUG_HOME" | |
fi | |
source "\$ZPLUG_HOME/init.zsh" | |
zplug denysdovhan/spaceship-prompt, use:spaceship.zsh, from:github, as:theme | |
# This seems to hang | |
# To manage zplug itself like other packages, write the following in your .zshrc. | |
# zplug 'zplug/zplug', hook-build:'zplug --self-manage' | |
# Install plugins if there are plugins that have not been installed | |
if ! zplug check --verbose; then | |
zplug install | |
fi | |
# Then, source plugins and add commands to \$PATH | |
zplug load --verbose | |
EOT | |
popd | |
fi | |
} | |
# ----------------------------------------------------------------------------- | |
# Create symlinks, if they don't exist. | |
pushd "$BASE_DIR" > /dev/null 2>&1 | |
while read -r -u3 line; do | |
[[ ! -e "$line" ]] && ln -nfsv "$REAL_ME" "$line" | |
done 3< <(grep -E -o '^prep-[^(]*' "$BASE_DIR/$REAL_ME" | sed 's/prep-//') | |
popd > /dev/null 2>&1 | |
# ----------------------------------------------------------------------------- | |
# Validate | |
if [[ "$(type -t "prep-${DISTRO}")" != "function" ]]; then | |
cat <<EOT | |
Invoke as one of these: | |
$(grep -E -o '^prep-[^(]*' "$BASE_DIR/$REAL_ME" | sed 's/prep-//;s/^/ /') | |
EOT | |
exit | |
fi | |
# ----------------------------------------------------------------------------- | |
TARGET="${XDG_CACHE_HOME:-$HOME/.cache}/test-drive-zsh" | |
# Ensure that our cache folder exists | |
[[ ! -d "$TARGET" ]] && mkdir -p "$TARGET" | |
# ----------------------------------------------------------------------------- | |
TARGET="$TARGET/$DISTRO" | |
export REAL_HOME="$HOME" # Export this to make it available w/in the session | |
export HOME="$TARGET" | |
"prep-${DISTRO}" | |
# ----------------------------------------------------------------------------- | |
exec "$SHELL" "$@" | |
# ----------------------------------------------------------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment