Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
A script I use for local provisioning of my bash profile in vagrant, does a bunch of stuff for the prompt and for vim
#!/bin/bash
function cinfo() {
COLOR='\033[01;33m' # bold yellow
RESET='\033[00;00m' # normal white
MESSAGE=${@:-"${RESET}Error: No message passed"}
echo -e "${COLOR}${MESSAGE}${RESET}"
}
##
cinfo "Local Provisioning detected"
#A couple of tools that are not on my base box
#yum install vim wget git lynx tig puppet-lint bash-completion -y
apt-get install vim wget git lynx tig bash-completion -y
#Bash profile
cat <<'BASH_PROF' > ${HOME}/.bash_profile # some folks will scream ".bashrc" meh.
# git CLI autocompletion
if [ -f ${HOME}/.git-completion.sh ]; then
source ${HOME}/.git-completion.sh
fi
# git prompt config (detects when you're in a git repo and does lotz of _very_ useful stuff like showing the current branch).
# A must for git users
if [ -f ${HOME}/.git-prompt.sh ];then
source ${HOME}/.git-prompt.sh
fi
alias ls='ls -G'
alias ll='ls -lhG --color'
set -o vi
PS1='\[\e[1m\]________________________________________________________________________________\n\[\[\e[37;30m\]| \w @ \h (\u) $(__git_ps1 "\e[0;34m\]git {%s}") \n| => \[\e[0m\]'
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
export HISTCONTROL=erasedups
export HISTSIZE=10000
export HISTTIMEFORMAT="%F %T "
export TERM='xterm-256color'
shopt -s histappend
alias vi='vim'
# I use this with iterm2 to show the host in the window title
export PROMPT_COMMAND='echo -ne "\033]0;${HOSTNAME%%.*}: ${PWD/#$HOME/${HOME}}\007"'
# get some git colors
git config --global color.ui auto
git config --global color.diff auto
BASH_PROF
#git autocomplete and prompt scripts
if [ ! -f ${HOME}/.git-prompt.sh ]; then
wget -O ${HOME}/.git-prompt.sh https://raw.github.com/git/git/master/contrib/completion/git-prompt.sh
fi
if [ ! -f ${HOME}/.git-completion.sh ]; then
wget -O ${HOME}/.git-completion.sh https://raw.github.com/git/git/master/contrib/completion/git-completion.bash
fi
#Vim stuff (vimrc and plugins)
cat << 'VIMRC' >${HOME}/.vimrc
execute pathogen#infect()
syntax on
filetype plugin indent on
colorscheme default
let g:indent_guides_enable_on_vim_startup = 1
set ts=2 sw=2 et
autocmd FileType python setlocal shiftwidth=2 tabstop=2
let g:Powerline_symbols = 'fancy'
let g:indent_guides_auto_colors=0
let g:indent_guides_guide_size=1
autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd guibg=red ctermbg=grey
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg=red ctermbg=black
autocmd FileType python setlocal shiftwidth=2 tabstop=2
set laststatus=2
map <F4> :NERDTreeToggle<CR>
map <F5> :NERDTreeFind<CR>
nnoremap <F6> :set nonumber!<CR>
nnoremap <F7> :GundoToggle<CR>
nnoremap <F8> :set nocursorcolumn!<CR>
nnoremap <F8> :set nohlsearch!<CR>
set cursorline
set number
let &colorcolumn=join(range(81,999),",")
highlight ColorColumn ctermbg=black
" highlighting
" show trailing spaces as errors
:autocmd Syntax * syn match Error /\s\+$\| \+\ze\t/ containedin=ALL display
" show tabs as errors
:autocmd Syntax * syn match Error /\t/ containedin=ALL display
"folding settings
set foldmethod=indent "fold based on indent
set foldnestmax=10 "deepest fold is 10 levels
set nofoldenable "dont fold by default
set foldlevel=1
"Undo tree
set undofile " Save undo's after file closes
set undodir=$HOME/.vim/undo " where to save undo histories
set undolevels=1000 " How many undos
set undoreload=10000 " number of lines to save for undo
"Save files when loosing focus (leave window)
:au FocusLost * silent! wa
"Unbind arrows
inoremap <Up> <NOP>
inoremap <Down> <NOP>
inoremap <Left> <NOP>
inoremap <Right> <NOP>
noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>
"No escape!
:imap jj <Esc>
" No esc delay
set timeoutlen=1000
set ttimeoutlen=0
VIMRC
#vim pathogen https://github.com/tpope/vim-pathogen
if [ ! -d ${HOME}/.vim/autoload ];then
mkdir -p ${HOME}/.vim/autoload ${HOME}/.vim/bundle
cd ${HOME}/.vim/autoload/
wget --no-check-certificate https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim
fi
#vim powerline
if [ ! -d ${HOME}/.vim/bundle/vim-powerline ];then
cd ${HOME}/.vim/bundle
git clone https://github.com/Lokaltog/vim-powerline
fi
#NERDTree
if [ ! -d ${HOME}/.vim/bundle/nerdtree ];then
cd ${HOME}/.vim/bundle
git clone https://github.com/scrooloose/nerdtree.git
fi
#Vim Json syntax
if [ ! -d ${HOME}/.vim/bundle/vim-json ];then
cd ${HOME}/.vim/bundle
git clone https://github.com/elzr/vim-json.git
fi
#vim indent guides
if [ ! -d ${HOME}/.vim/bundle/vim-indent-guides ];then
cd ${HOME}/.vim/bundle
git clone https://github.com/nathanaelkane/vim-indent-guides.git
fi
#Vim-fugitive
if [ ! -d ${HOME}/.vim/bundle/vim-fugitive ];then
cd ${HOME}/.vim/bundle
git clone https://github.com/tpope/vim-fugitive.git
fi
#Vim Syntastic
if [ ! -d ${HOME}/.vim/bundle/syntastic ];then
cd ${HOME}/.vim/bundle
git clone https://github.com/scrooloose/syntastic.git
fi
#Vim Ansible
if [ ! -d ${HOME}/.vim/bundle/vim-ansible-yaml ];then
cd ${HOME}/.vim/bundle
git clone https://github.com/chase/vim-ansible-yaml.git
fi
# Gundo
if [ ! -d ${HOME}/.vim/bundle/gundo ];then
cd ${HOME}/.vim/bundle
git clone https://github.com/sjl/gundo.vim.git
fi
# Persistent undo
if [ ! -d ${HOME}/.vim/undo ]; then
mkdir -p $HOME/.vim/undo
fi
chown -R `whoami`:`id -gn` ${HOME}
Owner

jaimegago commented May 29, 2014

For VIM powerline fancy icons to work a patched font need to be used by the application, I'm using this one https://gist.github.com/baopham/1838072

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment