Skip to content

Instantly share code, notes, and snippets.

@yrgoldteeth
Created October 25, 2013 17:18
Show Gist options
  • Save yrgoldteeth/7158334 to your computer and use it in GitHub Desktop.
Save yrgoldteeth/7158334 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# This is my setup for Vim. This will install the janus set of plugins
# as well as create my specific vim customizations
# Ensure required packages are installed.
REQUIRED_PACKAGES="bash vim git curl"
for package in $REQUIRED_PACKAGES
do
command -v $package >/dev/null && continue || { echo "Package: $package is required, please install it"; exit 1; }
done
# Cat the text of my .vimrc.after file
function vimrcafter()
{
cat<<EOF
" control-j to tab next, control-k to tab previous
map <C-J> :tabn<CR>
map <C-K> :tabp<CR>
" make j/k work on wrapped lines.
nnoremap j gj
nnoremap k gk
" KILL ALL TRAILING WHITESPACE WITH FIRE
nnoremap <silent> <F5> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR>
EOF
}
# Cat the text of my .gvimrc.after file
function gvimrcafter()
{
cat<<EOF
set guioptions-=T
set guioptions-=m
set guioptions-=r
set guioptions-=e
set guifont=Inconsolata:h14
set vb
colorscheme Mustang
EOF
}
# curl down the janus bash install file and send it to the pager.
# run bash on install file if confirmed, rm install file
function handle_install()
{
JANUS_FILE=$HOME/janus_install
curl -Lo- https://bit.ly/janus-bootstrap > $JANUS_FILE || { echo "Failed to curl file"; exit 1; }
$PAGER $JANUS_FILE || { echo "Pager quit with error code"; exit 1; }
echo "Do you wish to install this program?"
select yn in "Yes" "No"; do
case $yn in
Yes ) bash $JANUS_FILE; rm $JANUS_FILE; break;;
No ) rm $JANUS_FILE; break;;
esac
done
}
# Download and install Janus
if [ ! -d $HOME/.vim/janus ]
then
echo "Installing Janus"
handle_install
fi
# Create .vimrc.after
if [ ! -f $HOME/.vimrc.after ]
then
echo "Creating $HOME/.vimrc.after"
vimrcafter > $HOME/.vimrc.after
fi
# Create .vimrc.before
if [ ! -f $HOME/.vimrc.before ]
then
echo "Creating $HOME/.vimrc.before"
echo "call janus#disable_plugin('nerdtree')" > $HOME/.vimrc.before
fi
# Create .gvimrc.after
if [ ! -f $HOME/.gvimrc.after ]
then
echo "Creating $HOME/.gvimrc.after"
gvimrcafter > $HOME/.gvimrc.after
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment