Skip to content

Instantly share code, notes, and snippets.

@jeffiar
Last active August 3, 2020 23:16
Show Gist options
  • Save jeffiar/f438869d3f860c82ab8dbed05203a535 to your computer and use it in GitHub Desktop.
Save jeffiar/f438869d3f860c82ab8dbed05203a535 to your computer and use it in GitHub Desktop.
dotfiles
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
HISTCONTROL=ignoreboth
HISTSIZE=
HISTFILESIZE=
shopt -s histappend
PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
PROMPT_DIRTRIM=3
export OMP_NUM_THREADS=4
export HUGSFLAGS="-Evi"
export LD_LIBRARY_PATH="{LD_LIBRARY_PATH}:/usr/local/cuda-6.5/lib:/usr/local/lib"
export CUDA_ROOT="/usr/local/cuda-6.5"
export CUDA_HOME="/usr/local/cuda-6.5"
export ANDROID_HOME="/usr/local/android-sdk/"
export PATH="$PATH:~/bin:/usr/local/cuda-6.5/bin:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools"
export EDITOR="vim"
alias ls='ls --color=auto'
alias ll='ls --color=auto -alh'
alias tmux='TERM=xterm-256color tmux'
Tab: menu-complete
"\e[Z": menu-complete-backward
"\e\\": possible-completions
"\C-p": history-search-backward
"\e[A": history-search-backward
"\C-n": history-search-forward
"\e[B": history-search-forward
set colored-stats on
" jeffjar's more_vimrc
" Further useful vim functions
"
" Run on a side tmux pane, if exists
function! RunSide(command)
let bash_cmd = "if [ $(tmux list-panes | wc -l) = 2 ] ; "
\."then tmux send-keys -t right "
\."\"".a:command."\""
\." C-m; fi"
execute "silent !".bash_cmd
redraw!
endfunction
" Make, show errors, run tests if no errors
function! MakeAndTest()
call RunSide("PS1='';clear")
silent make
redir => bufferlist
ls
redir END
if bufferlist !~ "Quickfix"
call RunSide("./test")
endif
redraw!
endfunction
augroup group
autocmd!
" put cursor at last place where file was open
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
autocmd QuickFixCmdPre * :write
autocmd QuickFixCmdPost * :cw
autocmd FileType c,cpp
\ nnoremap <CR> :call MakeAndTest()<CR>
autocmd FileType c,cpp nnoremap <leader>g :cn<cr>
augroup END
bind r source-file ~/.tmux.conf \; display "reloaded .tmux.conf"
set -g default-terminal "screen-256color"
set -g base-index 1
set -g mode-keys vi
# change prefix to better one
set -g prefix C-space
#Mouse works as expected
# setw -g mode-mouse on
# set -g mouse-select-pane on
# set -g mouse-resize-pane on
# set -g mouse-select-window on
# easy-to-remember split pane commands
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %
# moving between panes with vim movement keys
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# WOEID=2498941 # Stanford
WOEID=2388327 # Cupertino
WEATHER="curl -G --data-urlencode 'q=select item.condition from weather.forecast where woeid = $WOEID' -d 'format=json' https://query.yahooapis.com/v1/public/yql | cut -d'\"' -f32,36 | sed 's/\\\"/° /g'"
CPU_PERCENT="top -bn2 -d0.03 -p1 | grep Cpu | tail -n 1 | awk '{printf \"%2.0f\",$2+$4+$6}'"
# set the fancy statusline powerline thing
set -g status-interval 2
set -g status-justify "left"
set -g status "on"
set -g status-left-style "none"
set -g message-command-style "fg=colour7,bg=colour0"
set -g status-right-style "none"
set -g pane-active-border-style "fg=colour6"
set -g status-style "none,bg=colour8"
set -g message-style "fg=colour7,bg=colour0"
set -g pane-border-style "fg=colour0"
set -g status-right-length "100"
set -g status-left-length "100"
setw -g window-status-activity-style "none"
setw -g window-status-separator ""
setw -g window-status-style "none,fg=colour7,bg=colour8"
set -g status-left "#[fg=colour0,bg=colour6] #S #[fg=colour6,bg=colour8,nobold,nounderscore,noitalics]"
set -g status-right "#[fg=colour0,bg=colour8,nobold,nounderscore,noitalics]#[fg=colour7,bg=colour0] %Y-%m-%d  %H:%M #[fg=colour0,bg=colour0,nobold,nounderscore,noitalics]#[fg=colour7,bg=colour0] #($CPU_PERCENT)% #h "
setw -g window-status-format "#[fg=colour7,bg=colour8] #I #[fg=colour7,bg=colour8] #W "
setw -g window-status-current-format "#[fg=colour8,bg=colour0,nobold,nounderscore,noitalics]#[fg=colour7,bg=colour0] #I #[fg=colour7,bg=colour0] #W #[fg=colour0,bg=colour8,nobold,nounderscore,noitalics]"
" jeffjar's .vimrc
" PLUGIN MANAGER =========================================
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim' " itself
Plugin 'tpope/vim-commentary' " commenting with gc
Plugin 'Raimondi/delimitMate' " automatic () completion
Plugin 'itchyny/lightline.vim' " light cool-looking status line
Plugin 'lervag/vimtex' "for latex
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-repeat'
Plugin 'tpope/vim-fugitive'
Plugin 'vim-pandoc/vim-pandoc-syntax'
Plugin 'peterbjorgensen/sved' " synctex
Plugin 'arcticicestudio/nord-vim'
Plugin 'altercation/vim-colors-solarized'
Plugin 'junegunn/goyo.vim'
call vundle#end()
" BASIC SETTINGS ========================================
set cindent tabstop=4 softtabstop=4 expandtab shiftwidth=4
filetype plugin indent on
syntax on
set backspace=indent,eol,start
set history=999
set mouse=a
set incsearch
set wildmode=list:full
set noswapfile
set gdefault " No need to :s/foo/bar/g
color nord
" tmux sets $TERM so vim knows it can use 256 colors, other terminals might not.
if empty($TMUX)
set t_Co=256
endif
" GVIM SETTINGS =================================
if has('gui_running')
set guifont=Fira\ Code\ Medium\ 14
set guioptions-=r " No right scroll bar
set guioptions-=L " No left scroll bar
set guioptions-=T " No toolbar
set guioptions-=m " No menu
color nord
let g:tex_flavor='xelatex'
" let g:vimtex_view_general_viewer = '"C:\Program Files (x86)\SumatraPDF\SumatraPDF.exe"'
endif
" MORE SETTINGS ========================================
" Line cursor in insert mode; Block otherwise.
let &t_SI = "\e[6 q"
let &t_EI = "\e[2 q"
set tabstop=4
set laststatus=2 " always display status line
set ruler " show cursor position on status line
set showcmd " Show keystrokes being entered onto the screen
set noshowmode " Since we use powerline, no need to show `--INSERT--`
set nowarn " no [file not changed] shit
set noequalalways " window size doesn't change when resizing things
set diffopt+=vertical " vimdiff runs a vertical split
set lazyredraw " no redraw during macros for faster stuff
set number " show line number on left
set relativenumber " Relative line numbers so we can do stuff like `4j` easier
set virtualedit+=block " In visual block mode, we're not restricted to text
set display=lastline " If last line is too long, don't cut it off and put @'s
set linebreak " Break lines at word boundaries, and ...
set showbreak=... " next line begins with ... to clear it's a continuation
" Settings for netrw, vim's built-in plugin for browsing directories
let g:netrw_banner = 0 " Don't show their banner cuz it takes up space
let g:netrw_liststyle = 3 " Display directories as trees, it's pretty
let g:netrw_sizestyle = "h" " Show 1M instead of 1024 when displaying filesize
let g:netrw_browsex_viewer= "xdg-open" " gx opens files in default viewer
" KEY MAPPINGS ===========================
" Escape key is far away, remap to kj. Cancel insert with C-c, just like in bash.
inoremap kj <ESC>
inoremap <C-c> <ESC>u
nnoremap U <C-R>
nnoremap <up> 5<C-Y>
nnoremap <down> 5<C-E>
" We don't want too 'hop' wrapped too-long lines when we press j/k.
" We also want to maintain default j/k functionality.
noremap j gj
noremap k gk
noremap <M-j> j
noremap <M-k> k
" End-of-line ($) and beginning-of-line (^) are too far away.
noremap H g^
noremap L g$
onoremap H ^
onoremap L $
" Switch windows with CTRL-<direction> to save some keypresses.
nnoremap <C-j> <C-w>j
nnoremap <C-h> <C-w>h
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" 'qq' starts recording macro, 'q' stops, 'Q' plays the macro.
" We can play macro (Q) or repeat (.) on a visual selection of lines too.
nnoremap Q @q
vnoremap Q :normal Q<CR>
vnoremap . :normal .<CR>
" Just like in bash, press C-p to search through past commands matching prefix.
cnoremap <C-p> <UP>
cnoremap <C-n> <down>
" Our leader is backslash. Here we set some basic leader-key mappings.
let mapleader="\\"
nnoremap <space> :
nnoremap <leader>w :w<cr>
nnoremap <leader>\ :set hlsearch!<cr>
nnoremap <leader>ev :e $MYVIMRC<cr>
nnoremap <leader>sv :so $MYVIMRC<cr>
nnoremap <leader>ya mxggVG"+y'x
nnoremap <leader>] :bp<cr>
nnoremap <leader>[ :bn<cr>
nnoremap <leader>r :set wrap!<cr>
nnoremap <leader>v :set paste!<cr>
" Yank/paste to the system clipboard with \y or \p
noremap <Leader>P "+P
noremap <Leader>p "+p
noremap <Leader>y "+y
" Open up the directory browser on the left side in a new buffer.
nnoremap <Leader>d :25Lex<cr>
" Comment out lines with \c (commentary plugin)
map <Leader>c gc
imap <tab><tab> <plug>delimitMateS-Tab
" Quickfix window open/close
nnoremap <Leader>= :copen<cr>
nnoremap <Leader>- :cclose<cr>
" FILETYPE SETTINGS ============================
" These should really be functions but whatever
augroup pandoc_syntax
au BufNewFile,BufFilePre,BufRead *.md set filetype=markdown.pandoc
augroup END
augroup filetypedetect
autocmd BufRead,BufNewFile *mutt-* setfiletype mail
autocmd BufRead,BufNewFile *mutt-* setlocal fo=wtqc
autocmd BufRead,BufNewFile *mutt-* setlocal nojs
autocmd BufRead,BufNewFile *mutt-* setlocal nosmartindent
autocmd BufRead,BufNewFile *mutt-* match ErrorMsg '\s\+$'
" autocmd BufRead,BufNewFile *mutt-* set background=light
" autocmd BufRead,BufNewFile *mutt-* color solarized
augroup END
augroup texmappings
autocmd Filetype tex nmap <Leader>se VS\equation*<CR>
autocmd Filetype tex nmap <Leader>sa VS\align*<CR>
autocmd Filetype tex vmap <Leader>sc S}i\cancel<esc>
autocmd Filetype tex vmap <Leader>su S}i\underbrace<esc>l%a_{}<esc>
autocmd Filetype tex nmap <Leader>k I\includegraphics[width=0.5\textwidth]{<esc>Ea}<esc>h:silent exec '!kolourpaint %:h/<cfile>'<cr>:redraw!<cr>
" autocmd Filetype tex setlocal fo=watqc
augroup END
" PLUGIN SETTINGS ==============================
" When we type {<cr>, we want the {} to open up like we expect.
let delimitMate_expand_cr = 1
" We have a patched font, so make the status line look pretty
let g:lightline = {
\ 'colorscheme' : 'nord',
\ 'separator': { 'left': '', 'right': '' },
\ 'subseparator': { 'left': '', 'right': '' }
\ }
" let g:pandoc#syntax#conceal#urls = 1
nnoremap <leader>z :Goyo<CR>
let g:vimtex_quickfix_latexlog = {'default' : 0}
" let g:vimtex_quickfix_latexlog = {
" \ 'overfull' : 0,
" \ 'underfull' : 0,
" \ 'packages' : {
" \ 'default' : 0,
" \ },
" \}
let g:vimtex_view_general_options = '--unique file:@pdf\#src:@line@tex'
let g:vimtex_view_general_options_latexmk = '--unique'
nnoremap <F4> :call SVED_Sync()<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment