Skip to content

Instantly share code, notes, and snippets.

@johnrlive
Last active April 6, 2022 02:30
Show Gist options
  • Save johnrlive/33484aca4ae337146d45baa723e52f29 to your computer and use it in GitHub Desktop.
Save johnrlive/33484aca4ae337146d45baa723e52f29 to your computer and use it in GitHub Desktop.
Basic .vimrc config for DevOps
#V1 test
###### Aliases ######
## TMUX ALIASES ##
alias t="tmux"
alias tl="tmux ls"
alias tk="tmux kill-session -t"
alias tn="tmux new -s"
alias tat="tmux attach-session -t"
## PYTHON ALIASES
alias pip="pip3"
## Docker Aliases ##
alias d="docker"
alias dc="docker container"
## Kubectl Aliases ##
alias kc="kubectl"
alias kccc="kubectl config current-context"
alias kcgc="kubectl config get-clusters"
## MISC ALIASES ##
# Setup PCAT - must 'pip install pygments'
# https://gist.github.com/BretFisher/5f688dde0122399efdca5a9d26100437
alias pcat='pygmentize -f terminal256 -O style=native -g'
alias sb="source ~/.bash_profile"
alias vb="vim ~/.bash_profile"
alias todo="vim ~/code/todo.txt"
######/ Aliases ######
# aliases
[[ -f ~/.aliases.private ]] && source ~/.aliases.private
#V1
# tmux plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-pain-control'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @plugin 'tmux-plugins/tmux-copycat'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'tmux-plugins/tmux-open'
set -g @continuum-boot 'on'
set -g @continuum-boot-options 'iterm,fullscreen'
# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
bind a last-window
# Copy and paste fix
# brew install reattach-to-user-namespace
set-option -g default-command "reattach-to-user-namespace -l bash"
# split panes using \ and -
#bind \ split-window -h
#bind - split-window -v
#unbind '"'
#unbind %
# reload config file (change file location to your the tmux.conf you want to use)
bind r source-file ~/.tmux.conf
# switch panes using Alt-arrow without prefix
#bind -n M-Left select-pane -L
#bind -n M-Right select-pane -R
#bind -n M-Up select-pane -U
#bind -n M-Down select-pane -D
### MOUSE CONTROL ###
# Enable mouse control (clickable windows, panes, resizable panes) (tmux < 2.1)
#set -g mouse-select-window on
#set -g mouse-select-pane on
#set -g mouse-resize-pane on
# Enable mouse mode (tmux 2.1 and above)
set -g mouse on
###/ MOUSE CONTROL ###
# don't rename windows automatically
set-option -g allow-rename off
######################
### DESIGN CHANGES ###
######################
# loud or quiet?
set -g visual-activity off
set -g visual-bell on
set -g visual-silence off
setw -g monitor-activity off
set -g bell-action none
# modes
setw -g clock-mode-colour colour5
setw -g mode-style 'fg=colour1 bg=colour18 bold'
# panes
set -g pane-border-style 'fg=colour19 bg=colour0'
set -g pane-active-border-style 'bg=colour0 fg=colour9'
# statusbar
set -g status-position bottom
set -g status-justify left
set -g status-style 'bg=colour18 fg=colour137 dim'
set -g status-left ''
set -g status-right '#[fg=colour233,bg=colour19] %d/%m #[fg=colour233,bg=colour8] %H:%M:%S '
set -g status-right-length 50
set -g status-left-length 20
setw -g window-status-current-style 'fg=colour1 bg=colour19 bold'
setw -g window-status-current-format ' #I#[fg=colour249]:#[fg=colour255]#W#[fg=colour249]#F '
setw -g window-status-style 'fg=colour9 bg=colour18'
setw -g window-status-format ' #I#[fg=colour237]:#[fg=colour250]#W#[fg=colour244]#F '
setw -g window-status-bell-style 'fg=colour255 bg=colour1 bold'
# messages
set -g message-style 'fg=colour232 bg=colour16 bold'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run -b '~/.tmux/plugins/tpm/tpm'
"V1
" http://owen.cymru/fzf-ripgrep-navigate-with-bash-faster-than-ever-before/
let g:rg_command = '
\ rg --column --line-number --no-heading --fixed-strings --ignore-case --no-ignore --hidden --follow --color "always"
\ -g "*.{js,json,php,md,styl,jade,html,config,py,cpp,c,go,hs,rb,conf}"
\ -g "!{.git,node_modules,vendor}/*" '
command! -bang -nargs=* F call fzf#vim#grep(g:rg_command .shellescape(<q-args>), 1, <bang>0)
" Install vim plug - https://github.com/junegunn/vim-plug
call plug#begin('~/.vim/plugged')
" Declare the list of plugins.
Plug 'tpope/vim-sensible'
Plug 'scrooloose/nerdtree'
Plug 'pearofducks/ansible-vim'
Plug 'gioele/vim-autoswap'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'ConradIrwin/vim-bracketed-paste'
Plug 'tpope/vim-surround'
Plug 'jiangmiao/auto-pairs'
Plug 'ervandew/supertab'
Plug 'vim-syntastic/syntastic'
Plug 'python/black'
call plug#end()
" -- Ctrl + P
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_working_path_mode = 'ra'
let g:ctrlp_switch_buffer = 'et'
" -- Syntastic Settings
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 = 1
let g:syntastic_check_on_wq = 0
" -- NerdTREE Settings
" How can I open a NERDTree automatically when vim starts up if no files were specified?
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
" How can I open NERDTree automatically when vim starts up on opening a directory?
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif
" How can I close vim if the only window left open is a NERDTree?
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" Toggle NerdTree with 'return' key
map <return> :NERDTreeToggle<CR>
" Move to NerdTree to the right
"let g:NERDTreeWinPos = "right"
" --HardTime Settings --
let g:hardtime_default_on = 1
" --Key Mappings --
" no need for <SHIFT> colon
nnoremap ; :
""""""""""""""""""""""""""""""""""""""""""
" remap ctrl+w to use <ctrl>+j/k/h/l to switch the right direction just like you use the j/k/h/l to move the cursor
""""""""""""""""""""""""""""""""""""""""""
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" To enable mouse uncomment line below
"set mouse=a
set clipboard=unnamed
"set paste
" Use CtrlP with RG
if executable('rg')
let g:ctrlp_user_command = 'rg %s --files --hidden --color=never --glob ""'
endif
" fix: backspace issue in vim
set bs=2
" enable syntax highlighting
syntax enable
" show line numbers
set number
" don't copy line numbers
set mouse+=a
" set tabs to have 4 spaces
set ts=4
" indent when moving to the next line while writing code
set autoindent
" expand tabs into spaces
set expandtab
" when using the >> or << commands, shift lines by 4 spaces
set shiftwidth=4
" show a visual line under the cursor's current line
set cursorline
" show the matching part of the pair for [] {} and ()
set showmatch
" enable all Python syntax highlighting features
let python_highlight_all = 1
#!/bin/bash
git clone https://gist.github.com/johnrlive/33484aca4ae337146d45baa723e52f29 ~/.dotfiles
ln -sf ~/.dotfiles/.tmux.conf ~/.tmux.conf
ln -sf ~/.dotfiles/.vimrc ~/.vimrc
ln -sf ~/.dotfiles/.aliases ~/.aliases
echo '[[ -f ~/.aliases ]] && source ~/.aliases' >> ~/.bash_profile
echo "dotfiles setup complete"
@johnrlive
Copy link
Author

How to install vim-plug

curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

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