Skip to content

Instantly share code, notes, and snippets.

@bds
Last active January 14, 2021 19:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bds/978bff530f20f05e633d to your computer and use it in GitHub Desktop.
Save bds/978bff530f20f05e633d to your computer and use it in GitHub Desktop.
dotfiles
# Cult of Vi
set -o vi
export VISUAL=vim
export EDITOR="$VISUAL"
# Colors!
alias ls='ls -G'
# History
export HISTFILE=~/.bash_history
export HISTFILESIZE=500000
export HISTSIZE=500000
shopt -s histappend
unset PROMPT_COMMAND
export PROMPT_COMMAND="history -n;history -w;history -c;history -r;$PROMPT_COMMAND"
# Git aliases
alias gs='git status'
alias gd='git diff'
alias gds='git diff --staged'
alias glo='git log --oneline'
# Git auto-complete
source $HOME/src/git-auto-complete/git-completion.bash
# Git branch in prompt.
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="@laptop:\W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "
[commit]
verbose = true
IRB.conf[:ECHO] = false
# * Pane Management
bind Down resize-pane -D 5
bind Up resize-pane -U 5
bind Left resize-pane -L 5
bind Right resize-pane -R 5
bind j select-pane -D
bind k select-pane -U
bind l select-pane -L
bind h select-pane -R
# * Pane colours
#set -g window-style 'fg=default,bg=colour254'
set -g window-style 'fg=default,bg=default'
set -g window-active-style 'fg=default,bg=colour231'
# set -g pane-active-border-fg blue
# * Plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-cpu'
set -g @resurrect-strategy-vim 'session'
set -g @plugin 'tmux-plugins/tmux-resurrect'
# * CPU info
set -g @cpu_low_fg_color "#[fg=default]"
set -g @cpu_medium_fg_color "#[fg=colour202]"
set -g @cpu_high_fg_color "#[fg=colour231]"
set -g @cpu_low_bg_color "#[bg=default]"
set -g @cpu_medium_bg_color "#[bg=default]"
set -g @cpu_high_bg_color "#[bg=red]"
# * Status bar
set -g status-bg colour0
set -g status-fg colour244
set -g status-right '#{cpu_bg_color} #{cpu_fg_color} CPU: #{cpu_icon} #{cpu_percentage} | %a %h-%d %H:%M '
# set -g status-fg colour172
# set -g status-bg colour235
# set -g status-bg colour235
# set -g status-fg colour136
# set -g status-fg colour141
# select-pane -t:.1 -P 'fg=default,bg=default'
# Must be at bottom of file
run '~/.tmux/plugins/tpm/tpm'
# * Notes
# set is equivalent to set-option
# setw -> set-window-option
# bind -> bind-key
# unbind -> unbind-key
# display -> display-message
# run -> run-shell
# if -> if-shell
#
# tmux-plugins/tmux-resurrect
# prefix + Ctrl-s - save
# prefix + Ctrl-r - restore
set nocompatible " We are using Vim
filetype off
syntax on
" * PLUGINS
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'Shougo/neocomplete.vim'
Plugin 'scrooloose/nerdTree'
Plugin 'szw/vim-maximizer'
Plugin 'godlygeek/tabular'
Plugin 'thoughtbot/vim-rspec'
Plugin 'benmills/vimux'
Plugin 'tpope/vim-obsession'
Plugin 'rhysd/vim-crystal'
Plugin 'hashivim/vim-terraform'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" CODE HIGHLIGHTING
let g:markdown_fenced_languages = ['css', 'javascript', 'js=javascript', 'json=javascript', 'ruby', 'xml', 'html', 'yaml']
" Filesytem
"
" > On some machines Vim is preconfigured with the backupcopy option set to
" > auto. This could potentially cause problems with the system's file
" > watching mechanism. Switching this option to yes will make sure a copy of
" > the file is made and the original one overwritten on save.
"
" -- https://webpack.js.org/configuration/watch/#vim
set backupcopy=yes
" * LINE NUMBERS
set nu
" * TABS AND SPACES
"
set softtabstop=2
set tabstop=2
set shiftwidth=2
set expandtab
" RSpec.vim mappings
let g:rspec_command = 'call VimuxRunCommand("clear; ./bin/dk rspec {spec}\n")'
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
" RUBY TESTS
" let g:rt='./bin/dk rspec %'
" let g:rta='./bin/dk rspec -t ~type:feature'
map <Leader>rb :call VimuxRunCommand("clear; ./bin/dk rspec " . bufname("%"))<CR>
map <leader>ra :call VimuxRunCommand("clear; ./bin/dk rspec -t ~type:feature")<CR>
" map <leader>tr :w<CR>\|:exec '!'.g:tr<CR>
" map <leader>tra :w<CR>\|:exec '!'.g:tra<CR>
" JS TESTS
let g:tj='./bin/dk npm run test -- ./spec/components/%:t'
let g:tdj='./bin/dk npm run test-debug -- ./spec/components/%:t'
let g:tij='./bin/dk npm run test-inspect -- ./spec/components/%:t'
let g:tja='./bin/dk npm run test'
map <Leader>tj :call VimuxRunCommand("clear; ./bin/dk npm run test -- ./spec/components/" . expand("%:t"))<CR>
map <leader>tdj :w<CR>\|:exec '!'.g:tdj<CR>
map <leader>tij :w<CR>\|:exec '!'.g:tij<CR>
map <leader>tja :w<CR>\|:exec '!'.g:tja<CR>
" ALL TESTS
let g:ta='./bin/dk-tests'
map <leader>ta :w<CR>\|:exec '!'.g:ta<CR>
" * AUTOCOMPLETE
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" Use neocomplete.
let g:neocomplete#enable_at_startup = 1
" Use smartcase.
let g:neocomplete#enable_smart_case = 1
" Set minimum syntax keyword length.
let g:neocomplete#sources#syntax#min_keyword_length = 3
let g:neocomplete#lock_buffer_name_pattern = '\*ku\*'
set completeopt+=longest
" Navigate popup with Vim keys
inoremap <expr> <c-j> pumvisible() ? ("\<C-n>") : "\<c-j>"
inoremap <expr> <c-k> pumvisible() ? ("\<C-p>") : "\<c-k>"
if has("autocmd")
" Enable omni completion.
autocmd FileType ruby set omnifunc=rubycomplete#Complete
autocmd FileType ruby let g:rubycomplete_buffer_loading=1
autocmd FileType ruby let g:rubycomplete_classes_in_global=1
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd BufNewFile,BufRead *.thor set syntax=ruby
autocmd BufNewFile,BufRead *.cr set syntax=crystal
autocmd BufNewFile,BufRead *tf set filetype=terraform
endif
" Reset to default highlighting
" hi clear
hi Pmenu ctermfg=darkred ctermbg=white
hi PmenuSel ctermfg=black ctermbg=brown
" * RULER
highlight ColorColumn ctermbg=7
set colorcolumn=80
set ruler
" * TABLINE
" set tabline+=%L
" set tabline=%{ObsessionStatus()}
" hi TabLineFill ctermfg=none ctermbg=DarkGreen
" hi TabLine ctermfg=Blue ctermbg=Yellow
" hi TabLineSel ctermfg=Red ctermbg=Yellow
" hi Title ctermfg=LightBlue ctermbg=Magenta
hi TabLineFill ctermfg=none ctermbg=none
hi TabLine ctermfg=none ctermbg=gray
hi TabLineSel ctermfg=none ctermbg=none
hi Title ctermfg=none ctermbg=none
" * TITLE
" set title titlestring=
" * STATUS LINE
set statusline=
set statusline+=%{ObsessionStatus()}
set statusline+=%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P
set statusline+=\ %{&fileencoding?&fileencoding:&encoding}
set statusline+=\[%{&fileformat}\]
set statusline+=[ASCII=\%03.3b]\ [HEX=\%02.2B]
hi StatusLine ctermfg=0 ctermbg=3 cterm=bold " Window highlighting
hi StatusLineNC ctermfg=white ctermbg=4 cterm=none
" * CODE FOLDING
"
hi Folded ctermfg=darkblue ctermbg=none cterm=none " Code folding highlight
"hi Folded ctermfg=gray ctermbg=black cterm=none " Code folding highlight
set foldmethod=indent
set foldnestmax=10
set nofoldenable
set foldlevel=1
" * COMMENTS
"
hi Comment ctermfg=gray
" * BRACKET MATCHING
set showmatch
" * HISTORY
"
set history=5000
" * NERDTree
"
map <C-n> :NERDTreeToggle<CR>
hi Directory ctermfg=darkcyan
hi NonText ctermfg=lightgray
hi SpecialKey ctermfg=brown
" * NOTES
"
" Color test
" :runtime syntax/colortest.vim
" Install Vundle plugins
" vim +PluginInstall +qall or :PluginInstall
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment