Bootstrap vim and tmux
"
"
" Amit Bakshi's vimrc. The first time you have to 'git clone
" https://github.com/gmarik/Vundle.vim ~/.vim/bundle/Vundle.vim'
" Open vim and run :PluginInstall to download the plugins.
"
"set nocompatible " these two always come firsta
"filetype off
"
"" set the runtime path to include Vundle and initialize
"set rtp+=~/.vim/bundle/Vundle.vim
"call vundle#begin()
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
call plug#begin('~/.vim/plugged')
Plug 'tpope/vim-sensible' " sane defaults
" Editing
Plug 'sjl/gundo.vim'
" Plug 'dracula/vim'
" Plug 'Valloric/YouCompleteMe' " cd ~/.vim/bundle/YouCompleteMe && ./install.sh
Plug 'christoomey/vim-tmux-navigator'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-unimpaired'
" Plug 'elzr/vim-json'
" Plug 'xolox/vim-misc'
" Plug 'xolox/vim-notes'
" Plug 'scrooloose/nerdcommenter'
" Plug 'SirVer/ultisnips'
" Plug 'honza/vim-snippets'
" Speed up autocomplete!
Plug 'Konfekt/FastFold'
" Navigation
Plug 'kien/ctrlp.vim'
Plug 'vim-scripts/taglist.vim'
Plug 'majutsushi/tagbar'
" Plug 'scrooloose/nerdtree'
Plug 'Lokaltog/vim-easymotion'
Plug 'ggreer/the_silver_searcher'
" Syntax/programming support
Plug 'vim-syntastic/syntastic'
Plug 'rodjek/vim-puppet'
Plug 'vim-scripts/spec.vim'
Plug 'fatih/vim-go', { 'for': 'golang' }
Plug 'godlygeek/tabular'
Plug 'plasticboy/vim-markdown'
Plug 'PProvost/vim-ps1'
" Plug 'tpope/vim-markdown.git'
Plug 'jtratner/vim-flavored-markdown'
Plug 'markcornick/vim-bats'
Plug 'ekalinin/Dockerfile.vim'
" Plug 'Rip-Rip/clang_complete'
Plug 'hashivim/vim-terraform'
Plug 'hashivim/vim-packer'
Plug 'pearofducks/ansible-vim'
Plug 'GutenYe/json5.vim'
Plug 'hashivim/vim-hashicorp-tools'
Plug 'pboettch/vim-cmake-syntax'
" Colors
" Plug 'altercation/vim-colors-solarized'
Plug 'fatih/molokai'
" Plug 'bling/vim-airline'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Git
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
Plug 'mattn/webapi-vim'
Plug 'mattn/gist-vim'
Plug 'editorconfig/editorconfig-vim'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
" ** All of your Plugs must be added before the following line **
" call vundle#end() " required
call plug#end()
" syntax enable
" filetype plugin indent on
let g:solarized_termcolors = 256
let g:rehash256 = 1 " alternate molokai version
if !has('nvim')
set background=dark " molokai sets this inside their script
endif
silent! colorscheme molokai " solarized
if !has('nvim')
if &term =~ "xterm" || &term =~ "screen"
" set t_RV=^[[c " Some bullshit terminall string holdover from windows
set ttymouse=xterm2 t_Co=256
endif
if has('mouse')
set mouse=a
endif
endif
set encoding=utf-8
set history=10000 " remember more commands and search history
set undolevels=1000 " use many muchos levels of undo
if has("persistent_undo")
set undofile " keep a persistent backup file
set undodir=~/.vim/undo,~/.tmp,~/tmp
endif
set backup
set writebackup
set backupdir=~/.vim/backup
set backspace=eol,start,indent
set incsearch hlsearch ignorecase smartcase showmatch
set expandtab smarttab shiftwidth=4 shiftround softtabstop=4 tabstop=4
set smartindent autoindent copyindent cindent
set lbr tw=140 autoindent
set noerrorbells
set virtualedit=onemore
set scrolloff=10 sidescrolloff=10
set winminheight=0
set noshowcmd title cmdheight=1
set laststatus=2 showmode
set tags=./tags,tags,../tags,../../tags,../../../tags,../../../../tag,~/tags,/usr/src/tags,/usr/include/tags,/usr/local/include/tags,$GOPATH/src/**/tags,$HOME/tags
set path=.;./include;**,/usr/local/include/sys;/usr/include/sys;/usr
set dictionary=/usr/share/dict/words
set viminfo='20,\"80 " read/write a .viminfo file, don't store more
" than 80 lines of registers
set wildmenu " make tab completion for files/buffers act like bash
set wildmode=list:full " show a list when pressing tab and complete
" first full match
set wildignore=*.swp,*.bak,*.pyc,*.class,~*
set ttyfast " always use a fast terminal
set ruler
set title " change the terminal's title
set visualbell t_vb= " don't beep
set noerrorbells " don't beep
set showcmd " show (partial) command in the last line of the screen
" this also shows visual selection info
set modeline " disable mode lines (security measure)
set modelines=2 " OSX's default vimrc sets modeline*S* to 0. Retarded
set nocursorline " underline the current line, for quick orientation
set nowrap
set wrapmargin=0 textwidth=124
set formatoptions+=l " Don't wrap when typing on an existing line
set foldmethod=manual
set foldlevelstart=20
""""""""""""""""""""""""""""""
" Global remappings and leader
""""""""""""""""""""""""""""""
let mapleader=","
let g:mapleader=","
nnoremap ; :
nnoremap j gj " this is so when you go up/down on a wrapped line it
nnoremap k gk " doesn't obey some ancient line number rule
nnoremap / /\v
vnoremap / /\v
nnoremap <leader><space> :noh<cr>
nnoremap <tab> %
vnoremap <tab> %
" FIXME: Doesn't seem to work in vim on EL6/7
" if !has("nvim")
" if v:version > 703
" set cryptmethod=blowfish2
" endif
" endif
" Cursor shape change depending on the mode like in gvim. Only in tmux.
" if !empty($TMUX)
" let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
" let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
" inoremap <special> <Esc> <Esc>h
" don't blink the cursor
" set guicursor+=i:blinkwait0
" endif
""""""""""""""""""""""""""""""
" PLUGINS
""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""
" Gist
""""""""""""""""""""""""""""""
" If you want to show your private gists with ":Gist -l":
let g:gist_show_privates = 1
let g:gist_post_private = 1
let g:gist_post_anonymous = 1
let g:gist_get_multiplefile = 1
" let g:gist_list_vsplit = 1
" Only :w! updates a gist.
let g:gist_update_on_write = 2
""""""""""""""""""""""""""""""
" Tagbar
""""""""""""""""""""""""""""""
nnoremap <leader>l :TagbarToggle<CR>
" let Tlist_Ctags_Cmd = '/usr/local/bin/ctags'
let Tlist_Display_Prototype=1
let Tlist_Display_Tag_Scope=0
let Tlist_Use_Right_Window=1
let Tlist_Auto_Highlight_Tag = 1
let Tlist_Auto_Update = 1
let Tlist_Exit_OnlyWindow = 1
let Tlist_File_Fold_Auto_Close = 1
let Tlist_Highlight_Tag_On_BufEnter = 1
let Tlist_Use_SingleClick = 1
" Override how taglist does javascript
let g:tlist_javascript_settings = 'javascript;f:function;c:class;m:method;p:property;v:global'
let g:ctags_statusline=1
" }}
" let g:tagbar_left = 1
let g:tagbar_usearrows = 1
let g:tagbar_type_go = {
\ 'ctagstype' : 'go',
\ 'kinds' : [
\ 'p:package',
\ 'i:imports:1',
\ 'c:constants',
\ 'v:variables',
\ 't:types',
\ 'n:interfaces',
\ 'w:fields',
\ 'e:embedded',
\ 'm:methods',
\ 'r:constructor',
\ 'f:functions'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 't' : 'ctype',
\ 'n' : 'ntype'
\ },
\ 'scope2kind' : {
\ 'ctype' : 't',
\ 'ntype' : 'n'
\ },
\ 'ctagsbin' : 'gotags',
\ 'ctagsargs' : '-sort -silent'
\ }
""""""""""""""""""""""""""""""
" syntastic
""""""""""""""""""""""""""""""
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 0
let g:syntastic_check_on_wq = 0
""""""""""""""""""""""""""""""
" YouCompleteMe
""""""""""""""""""""""""""""""
"b:ycm_largefile=1
"b:ycm_largefile=1
" let g:ycm_min_num_of_chars_for_completion=12
let g:ycm_global_ycm_extra_conf = '~/.vim/.ycm_extra_conf.py'
let g:ycm_extra_conf_globlist = ['!~/xcalar/.ycm_extra_conf.py']
""""""""""""""""""""""""""""""
" ailirline
""""""""""""""""""""""""""""""
" You need a special bitmap font for this mode.
" let g:airline_powerline_fonts = 1
" let g:Powerline_symbols = "fancy"
let g:bufferline_echo = 0
let g:airline_theme = 'powerlineish'
let g:airline#extensions#branch#enabled = 1
let g:airline#extensions#syntastic#enabled = 1
" let g:rehash256 = 1
"
" https://github.com/bling/vim-airline/wiki/FAQ
" if !exists('g:airline_symbols')
" let g:airline_symbols = {}
" endif
" let g:airline_symbols.space = "\ua0"
""""""""""""""""""""""""""""""
" EasyMotion
""""""""""""""""""""""""""""""
let g:EasyMotion_do_mapping = 0 " Disable default mappings
" let g:EasyMotion_use_upper = 1
" let g:EasyMotion_keys = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ;'
let g:EasyMotion_keys = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
" let g:EasyMotion_inc_highlight = 0
let g:EasyMotion_do_shade = 1
let g:EasyMotion_smartcase = 1
" let g:EasyMotion_move_highlight = 1
" Bidirectional: nmap <Leader>w <Plug>(easymotion-bd-w)
nmap <Leader>w <Plug>(easymotion-w)
nmap s <Plug>(easymotion-s2)
nmap t <Plug>(easymotion-t2)
" JK motions: Line motions
map <Leader>j <Plug>(easymotion-j)
map <Leader>k <Plug>(easymotion-k)
" Replace default search? Nope.
" map / <Plug>(easymotion-sn)
" omap / <Plug>(easymotion-tn)
" These `n` & `N` mappings are options. You do not have to map `n` & `N` to
" EasyMotion. Without these mappings, `n` & `N` works fine. (These mappings
" just provide different highlight method and have some other features )
"
" map n <Plug>(easymotion-next)
" map N <Plug>(easymotion-prev)
""""""""""""""""""""""""""""""
" UltiSnips
""""""""""""""""""""""""""""""
let g:UltiSnipsExpandTrigger="<c-i>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"
""""""""""""""""""""""""""""""
" grep/ag/ctrl-p
""""""""""""""""""""""""""""""
" The Silver Searcher
if executable('ag')
" Use ag over grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
" ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
" bind \ (backward slash) to grep shortcut
command -nargs=+ -complete=file -bar Ag silent! grep! <args>|cwindow|redraw!
nnoremap \ :Ag<SPACE>
endif
" bind K to grep word under cursor
nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR>
""""""""""""""""""""""""""""""
" Ansible
""""""""""""""""""""""""""""""
au BufRead,BufNewFile */ansible/*.yml set filetype=yaml.ansible
au BufRead,BufNewFile */playbooks/*.yml set filetype=yaml.ansible
au BufRead,BufNewFile */roles/**/*.yml set filetype=yaml.ansible
let g:ansible_unindent_after_newline = 1
let g:ansible_extra_syntaxes = "sh.vim ruby.vim"
let g:ansible_attribute_highlight = "ob"
let g:ansible_name_highlight = 'd'
""""""""""""""""""""""""""""""
" KEYBOARD
""""""""""""""""""""""""""""""
" Move between windows easier
map <C-J> <C-W>j<C-W>_
map <C-K> <C-W>k<C-W>_
map <C-L> <C-W>l<C-W>_
map <C-H> <C-W>h<C-W>_
map <C-K> <C-W>k<C-W>_
" Wrapped lines goes down/up to next row, rather than next line in file.
nnoremap j gj
nnoremap k gk
" Better 'n' next highlight
" nnoremap <silent> n n:call HLNext(0.4)<cr>
" nnoremap <silent> N n:call HLNext(0.4)<cr>
function! HLNext (blinktime)
set invcursorline
redraw
exec 'sleep ' . float2nr(a:blinktime * 1000) . 'm'
set invcursorline
redraw
endfunction
" Turn off highlighting in insert mode
autocmd InsertEnter * :setlocal nohlsearch
autocmd InsertLeave * :setlocal hlsearch
""""""""""""""""""""""""""""""
" Special highlighting stuff
""""""""""""""""""""""""""""""
highlight DiffAdd term=reverse cterm=bold ctermbg=green ctermfg=white
highlight DiffChange term=reverse cterm=bold ctermbg=cyan ctermfg=black
highlight DiffText term=reverse cterm=bold ctermbg=gray ctermfg=black
highlight DiffDelete term=reverse cterm=bold ctermbg=red ctermfg=black
" Mark 81st column in red only when text is present
" via: Damian Conway, 'More Instantly Better Vim'
highlight ColorColumn ctermbg=magenta
call matchadd('ColorColumn', '\%81v', 100)
""""""""""""""""""""""""""""""
" Filetype triggers
""""""""""""""""""""""""""""""
autocmd FileType go,sh,markdown,puppet,python,make,c,cpp,java,php,ruby autocmd BufWritePre <buffer> :%s/\s\+$//e
" Save a backup file with the date in it
augroup backuprename
au!
au BufWritePre * let &bex = '~' . strftime("%Y%m%d-%H%M%S") . '~'
augroup end
autocmd BufNewFile,BufReadPost *.md set filetype=markdown
autocmd FileType ruby setlocal expandtab tabstop=2 shiftwidth=2 softtabstop=2
autocmd FileType yaml setlocal expandtab tabstop=2 shiftwidth=2 softtabstop=2
autocmd FileType puppet setlocal tabstop=2 expandtab shiftwidth=2 softtabstop=2
" augroup markdown
" au!
" au BufNewFile,BufRead *.md,*.markdown setlocal filetype=ghmarkdown
" augroup end
" au VimEnter * NERDTreeToggle
" nmap <F3> :NERDTreeToggle<CR>
" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
" Remove trailing whitespace
if has("autocmd")
autocmd BufWritePre * :%s/\s\+$//e
endif
" Golang
"
"
au FileType go nmap <leader>r <Plug>(go-run)
au FileType go nmap <leader>b <Plug>(go-build)
au FileType go nmap <leader>t <Plug>(go-test)
au FileType go nmap <leader>c <Plug>(go-coverage)
au FileType go nmap <Leader>gv <Plug>(go-doc-vertical)
au FileType go nmap <Leader>gb <Plug>(go-doc-browser)
au FileType go nmap <Leader>s <Plug>(go-implements)
au FileType go nmap <Leader>i <Plug>(go-info)
au FileType go nmap <Leader>e <Plug>(go-rename)
let g:go_auto_type_info = 1
let g:go_auto_sameids = 1
let g:go_fmt_experimental = 1
let g:go_fmt_command = "goimports"
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
""""""""""""""""""""""""""""""
" Local customizations
""""""""""""""""""""""""""""""
if filereadable(expand("\~/.vimrc.local"))
source \~/.vimrc.local
endif
# ` is an interesting key for a prefix
# set-option -g prefix `
#
# ChangeLog:
# 05/19/2017 Remove utf-8 option
# 06/01/2017 Add allow-rename off
set-option -g prefix C-a
unbind-key C-b
set-option -g default-terminal "screen-256color"
## set-option -g mouse-select-pane on
set-option -g status-keys vi
set-option -g bell-action any
set-option -g set-titles on
set-option -g set-titles-string '#H:#S.#I.#P #W #T' # window number,program name,active (or not)
set-option -g visual-bell off
bind-key C-a last-window
bind-key ` last-window
bind-key a send-prefix
# we might need ` at some point, allow switching
# we can also send the prefix char with `-a
bind-key F11 set-option -g prefix C-a
bind-key F12 set-option -g prefix `
# 0 is too far from ` ;)
set -g base-index 1
setw -g mode-keys vi
#setw -g mode-mouse on
setw -g monitor-activity on
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'y' copy-selection
bind e previous-window
bind f next-window
bind E swap-window -t -1
bind F swap-window -t +1
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# window splitting
unbind %
bind | split-window -h -c '#{pane_current_path}'
unbind '"'
bind - split-window -v -c '#{pane_current_path}'
## new-window should go to home dir
# unbind 'c'
# bind c new-window -c '#{pane_current_path}'
# screen style
# bind S split-window -v
unbind ","
bind-key '"' command-prompt -I '#W' "rename-window '%%'"
#set-option -g status-utf8 on
set-option -g status-justify left
set-option -g status-bg black
set-option -g status-fg white
set-option -g status-left-length 40
set-option -g status-right-length 80
set-option -g pane-active-border-fg green
set-option -g pane-active-border-bg black
set-option -g pane-border-fg white
set-option -g pane-border-bg black
set-option -g message-fg black
set-option -g message-bg green
#setw -g mode-bg black
# don't wait for an escape sequence after hitting
# Esc. fixes insert mode exit lag in vim
set -sg escape-time 0
# Don't let tmux rename your windows
set-option -g allow-rename off
setw -g window-status-bg black
setw -g window-status-current-fg green
setw -g window-status-bell-attr default
setw -g window-status-bell-fg red
#setw -g window-status-content-attr default
#setw -g window-status-content-fg yellow
setw -g window-status-activity-attr default
setw -g window-status-activity-fg yellow
set -g status-left '#[fg=red]#H#[fg=green]:#[fg=white]#S #[fg=green]][#[default]'
set -g status-interval 5
#set -g status-right '#[fg=green]][#[fg=white] #(tmux-mem-cpu-load 5 4) #[fg=green]][ #[fg=yellow]%H:%M#[default]'
set -g status-right "#S #[fg=green,bg=black]#(tmux-mem-cpu-load --interval 5 -g 5)#[default]"
is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"'
bind -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
bind -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
bind -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
bind -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
bind -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l"
set -g history-limit 1000000000
bind r source-file ~/.tmux.conf
$include /etc/inputrc
set editing-mode vi
set keymap vi-insert
"\C-l": clear-screen
set keymap vi
#set completion-ignore-case on
#set show-all-if-ambiguous on
#set page-completions off
set match-hidden-files off
set expand-tilde off
set completion-query-items 200
set mark-symlinked-directories on
# Bash4 only? See https://github.com/mathiasbynens/dotfiles/blob/master/.inputrc
set skip-completed-text on
"\e[B": history-search-forward
"\e[A": history-search-backward
#set print-completion-horizontally on
set convert-meta on
set input-meta off
set output-meta off
set bell-style none
#set keymap vi-insert
$if editing-mode=vi
"\C-l": clear-screen
#"\C-p": dynamic-complete-history
"\C-p": history-search-backward
"\C-n": menu-complete
$endif
#tab: complete
#set completion-ignore-case on
#set blink-matching-paren on
#"\e[1~": beginning-of-line
#"\e[4~": end-of-line
#!/usr/bin/env bash
#
# install: curl -fsSL https://gist.githubusercontent.com/ambakshi/51c994271a216016edef/raw/bootstrap.sh | bash -e
# fork: https://gist.github.com/ambakshi/51c994271a216016edef
# short url: curl -fsSL http://bit.ly/devbootstrap | bash -e
#
# ChangeLog:
# 12/21/2016 - Add Arch support
# 05/19/2017 - Add .gdbinit
# 05/28/2018 - Add amazon linux support
# Amit Bakshi
#
_osid() {
(
unset ELVERSION UBVERSION VERSTRING VERSION_ID ID PRETTY_NAME VERSION
if [[ "$OSTYPE" =~ darwin ]]; then
VERSTRING="$OSTYPE"
elif [[ "$OSTYPE" =~ freebsd ]]; then
VERSTRING="$OSTYPE"
elif [ -f /etc/os-release ]; then
. /etc/os-release
case "$ID" in
antergos)
VERSTRING="arch"
;;
rhel | ol | centos)
ELVERSION="$(echo $VERSION_ID | cut -d'.' -f1)"
;;
ubuntu)
UBVERSION="$(echo $VERSION_ID | cut -d'.' -f1)"
VERSTRING="ub${UBVERSION}"
;;
amzn)
if [[ "$CPE_NAME" =~ ^cpe:/o:amazon:linux:20 ]]; then
ELVERSION=6
VERSTRING=amzn1
else
ELVERSION=7
VERSTRING=amzn2
fi
;;
*)
echo >&2 "Unknown OS version: $PRETTY_NAME ($VERSION)"
;;
esac
fi
if [ -z "$VERSTRING" ] && [ -e /etc/redhat-release ]; then
RELEASE="$(rpm -q $(rpm -qf /etc/redhat-release) --queryformat '%{VERSION}')"
case "$RELEASE" in
6Server) VERSTRING="rhel6" ;;
7Server) VERSTRING="rhel7" ;;
6) VERSTRING="el6" ;;
7) VERSTRING="el7" ;;
*)
echo >&2 "Unknown version of EL: $RELEASE"
echo >&2 "Please set VERSTRING to rhel6, el6, rhel7 or el7 manually before running this script"
exit 1
;;
esac
ELVERSION="${VERSTRING%Server}"
fi
if [ -z "$VERSTRING" ]; then
cat >&2 /etc/*-release
echo >&2 "Unknown OS version"
uname -a >&2
exit 1
fi
[ $# -eq 0 ] && set -- -f
for cmd in "$@"; do
case "$cmd" in
-f | --full) echo "$VERSTRING" ;;
-s | --split) echo "$VERSTRING" | sed -E -e 's/([a-z]+)([0-9\.]+)/\1 \2/g' ;;
-p | --package)
case "$VERSTRING" in
ub*) echo "deb" ;;
el* | rhel*) echo "rpm" ;;
el*) echo "rpm" ;;
amzn*) echo "rpm" ;;
esac
;;
-*)
echo >&2 "Unknown option $cmd"
exit 1
;;
esac
done
)
}
have_pkg() {
local pkg=
if [[ $OSID_NAME =~ ^ub ]]; then
for pkg in "$@"; do
dpkg -l $pkg &>/dev/null || return 1
done
return 0
elif [[ $OSID_NAME =~ el(6|7)$ ]] || [[ $OSID_NAME =~ ^amzn ]]; then
for pkg in "$@"; do
rpm -q $pkg &>/dev/null || return 1
done
return 0
fi
return 1
}
install_pkg() {
have_pkg "$@" && return 0
if [[ $OSID_NAME =~ ^ub ]]; then
sudo DEBIAN_FRONTEND=noninteractive apt-get install -yqq "$@"
elif [[ $OSID_NAME =~ el(6|7)$ ]] || [[ $OSID =~ ^amzn ]]; then
sudo yum install -y -q "$@"
elif [[ $OSID_NAME =~ ^freebsd ]]; then
pkg install -y git tmux curl
elif [[ $OSID_NAME =~ ^darwin ]]; then
local pkg=
for pkg in "$@"; do brew install $pkg; done
elif [[ $OSID_NAME =~ arch ]]; then
sudo pacman -S --noconfirm "$@"
else
return 1
fi
}
install_setup() {
echo >&2 "installing setup requirements ..."
if [[ $OSID_NAME =~ ^darwin ]]; then
command -v brew || /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update
elif [[ $OSID_NAME =~ ^freebsd ]]; then
mkdir -p ${XDG_CONFIG_HOME:=$HOME/.config}
pkg install -y git tmux curl
elif [[ $OSID_NAME =~ ^ub ]]; then
mkdir -p ${XDG_CONFIG_HOME:=$HOME/.config}
sudo apt-get update -qq
install_pkg curl software-properties-common git
elif [[ $OSID_NAME =~ ^el ]] || [[ $OSID_NAME =~ ^amzn ]]; then
mkdir -p ${XDG_CONFIG_HOME:=$HOME/.config}
install_pkg sudo
elif [[ $OSID_NAME =~ rhel ]]; then
sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-${ELVERSION}.noarch.rpm curl git
fi
if [[ $OSID_NAME =~ arch ]]; then
sudo pacman -S --noconfirm git curl
else
sudo yum -y install epel-release curl git
fi
}
install_neovim() {
mkdir -p ~/.vim/{backup,plugged,undo,autoload,tmp/bundle}
if ! command -v nvim >/dev/null; then
echo >&2 "installing neovim ..."
if [[ $OSID_NAME =~ ^darwin ]]; then
install_pkg neovim/neovim/neovim
elif [[ $OSID_NAME =~ ^freebsd ]]; then
pkg install -y neovim
elif [[ $OSID_NAME =~ ^ub ]]; then
sudo add-apt-repository -y ppa:neovim-ppa/stable
if [[ $OSID_VERSION =~ 14 ]]; then
sudo add-apt-repository -y ppa:pi-rho/dev
addpkgs="tmux=2.0-1~ppa1~t"
else
addpkgs="tmux"
fi
sudo apt-get update -qq
sudo apt-get install -qqy neovim python-dev python-pip python3-dev python3-pip $addpkgs
sudo update-alternatives --install /usr/bin/vi vi /usr/bin/nvim 60
sudo update-alternatives --skip-auto --config vi
sudo update-alternatives --install /usr/bin/vim vim /usr/bin/nvim 60
sudo update-alternatives --skip-auto --config vim
sudo update-alternatives --install /usr/bin/editor editor /usr/bin/nvim 60
sudo update-alternatives --skip-auto --config editor
sudo pip install -U neovim || true
sudo pip2 install -U neovim || true
sudo pip3 install -U neovim || true
elif [[ $OSID_NAME =~ arch ]]; then
pacman -S --noconfirm tmux neovim
elif [[ $OSID_NAME =~ ^el ]] && [[ $OSID_VERSION -eq 7 ]]; then
sudo curl -o /etc/yum.repos.d/dperson-neovim-epel-7.repo https://copr.fedorainfracloud.org/coprs/dperson/neovim/repo/epel-7/dperson-neovim-epel-7.repo
sudo yum -y install neovim tmux
else
echo >&2 "Don't know how to install neovim on ${OSID_NAME}${OSID_VERSION}"
return 1
fi
fi
ln -sfn $HOME/.vim $XDG_CONFIG_HOME/nvim
ln -sfn $HOME/.vimrc $XDG_CONFIG_HOME/nvim/init.vim
}
install_golang() {
if command -v go >/dev/null; then
return 0
fi
local version="${1:-1.10.2}"
if ! sudo mkdir -p /usr/local/go${version}; then
return 1
fi
GOURL="https://dl.google.com/go/go${version}.linux-amd64.tar.gz"
curl -fL "$GOURL" | sudo tar zxf - -C /usr/local/go${version} --strip-components=1
sudo ln -sfn go${version} /usr/local/go
for cmd in go godoc gofmt; do sudo ln -sfn ../go/bin/${cmd} /usr/local/bin/${cmd}; done
}
install_golang_tools() {
export GOPATH=$HOME/go
go get mvdan.cc/sh/cmd/shfmt
go get github.com/direnv/direnv
go get github.com/minio/mc
for pkg in $(ls $GOPATH/bin/*); do
sudo cp ${pkg} /usr/local/bin/
done
}
_VER=($(_osid -s))
OSID_NAME="${_VER[0]}"
OSID_VERSION="${_VER[1]}"
unset _VER
# setup some basics (curl, epel, etc)
install_setup
# neovim
install_neovim
# golang
install_golang
install_golang_tools
curl -fsSL https://gist.githubusercontent.com/ambakshi/51c994271a216016edef/raw/tmuxconf >~/.tmux.conf
curl -fsSL https://gist.githubusercontent.com/ambakshi/51c994271a216016edef/raw/inputrc >~/.inputrc
curl -fsSL https://gist.githubusercontent.com/ambakshi/51c994271a216016edef/raw/bash_aliases >~/.bash_aliases
curl -fsSL https://gist.github.com/ambakshi/d111202b21041db55a80/raw >>~/.gitconfig
curl -fsSL https://gist.githubusercontent.com/CocoaBeans/1879270/raw/c6972d5c32e38e9f35a3968c629b51973bd9d016/gdbinit >~/.gdbinit
VIMRC=$(readlink -f $HOME/.vimrc || echo $HOME/.vimrc)
mkdir -p ~/.vim/{backup,plugged,undo,autoload,tmp/bundle}
curl -fsSL https://gist.githubusercontent.com/ambakshi/51c994271a216016edef/raw/vimrc >$VIMRC
if ! which ctags &>/dev/null; then
sed -i.bak "s#^Plug 'vim-scripts/taglist.vim'#\" Plug 'vim-scripts/taglist.vim'#g" $VIMRC
echo >&2 "No ctags found. Commenting out taglist.vim plugin from ~/.vimrc"
fi
curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
mkdir -p ~/bin && curl -fsSL https://raw.githubusercontent.com/git/git/fd99e2bda0ca6a361ef03c04d6d7fdc7a9c40b78/contrib/diff-highlight/diff-highlight >~/bin/diff-highlight && chmod +x ~/bin/diff-highlight
## Get rid of YouCompleteMe plugin if you can't build it.
#if ! which cmake &>/dev/null; then
# sed -i.bak "s#^Plugin 'Valloric/YouCompleteMe'#\" Plugin 'Valloric/YouCompleteMe'#g" ~/.vimrc
# echo >&2 "No cmake found. Commenting out YouCompleteMe plugin form ~/.vimrc"
#fi
#if [ -r /dev/tty ]; then
# bash -c '</dev/tty vim "$@"' vim -T dumb '+PluginInstall' '+qall!' || true
#else
if ! [[ "$OSTYPE" =~ ^freebsd ]]; then
if command -v nvim &>/dev/null; then
nvim --headless -c ':PlugInstall' -c 'qall' || true
fi
fi
#fi
#(cd ~/.vim/bundle/vim-airline/autoload/airline/themes && wget https://raw.githubusercontent.com/vim-airline/vim-airline-themes/master/autoload/airline/themes/powerlineish.vim)
##[ -e ~/.vim/bundle/YouCompleteMe ] && cd ~/.vim/bundle/YouCompleteMe && git submodule update --init && ./install.sh || true
echo >&2 "Logout and back in or source ~/.bashrc"
#!/bin/bash
if [[ $UID -ne 0 ]]; then
if ! type -t __git_ps1 >/dev/null 2>&1 && test -e /usr/share/git-core/contrib/completion/git-prompt.sh; then
. /usr/share/git-core/contrib/completion/git-prompt.sh
fi
if type -t __git_ps1 >/dev/null 2>&1; then
PS1='[\[\033[32m\]\u@\h\[\033[00m\] \[\033[36m\]\W\[\033[31m\]$(__git_ps1)\[\033[00m\]] \$ '
else
PS1='[\[\033[32m\]\u@\h\[\033[00m\] \[\033[36m\]\W\[\033[31m\]\[\033[00m\]] \$ '
fi
else
PS1='\[\e[31m\]\h:\w#\[\e[m\] '
fi
alias c=clear
alias cd..='cd ..'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias d=docker
alias dc=docker-compose
alias drm='docker ps -aq | xargs -r docker rm'
alias drmi='docker images --filter=dangling=true -q | xargs -r docker rmi'
alias di='docker images'
alias dps='docker ps'
alias egrep='egrep --color=auto'
alias ff='find . -type f | grep -E'
alias gf='git ls-files | egrep'
alias gs='git status --short'
alias gst='gs -uno'
alias gg='git grep'
alias gd='git diff'
alias gdc='git diff --cached'
alias gru='git remote update'
alias g='git'
alias ltr='ls -ltr'
alias cp='cp -i'
alias mv='mv -i'
alias rm='rm -I'
# For creating a new session
tnew_session(){
# To avoid 'unset $TMUX to force' error
TMUX= tmux new-session -d -s $1
tmux switch-client -t $1
}
# Aliases
alias tnews='tnew_session'
alias tls='tmux list-session'
alias tlw='tmux list-window'
alias tsw='tmux switch -t '
alias tlc='tmux list-command'
alias tat='tmux attach -t'
alias trs='tmux rename-session -t'
alias tks='tmux kill-session -t'
export HISTSIZE=100000000
export HISTFILESIZE=200000000
export HISTCONTROL=ignoreboth:erasedups
export HISTFILE=$HOME/.bash_forever_history
export HISTTIMEFORMAT='%FT%T%z%t'
shopt -s histappend
shopt -s checkwinsize
set -o braceexpand
if ! echo "$PATH" | grep -q "$HOME/bin"; then
PATH="$PATH:$HOME/bin"
export PATH
fi
if command -v go &>/dev/null; then
PATH="$PATH:${GOPATH:-$HOME/go}/bin"
export PATH
fi
set -o vi
[ -f ~/.fzf.bash ] && source ~/.fzf.bash || true