From 73c365eb1ebc1452a8fdd7a10d0eb89f2d1aeaed Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Tue, 21 Mar 2017 11:59:40 -0700 Subject: [PATCH] ENH: Reworking old dotfiles to use dotbot --- .gitmodules | 3 + README.md | 15 ++++ aspell.en.pws | 6 ++ dotbot | 1 + git/gitconfig | 61 ++++++++++++++++ git/gitignore_global | 3 + homebrew-install | 95 +++++++++++++++++++++++++ install | 14 ++++ install.conf.yaml | 15 ++++ psqlrc | 4 ++ tmux.conf | 53 ++++++++++++++ vimrc | 161 +++++++++++++++++++++++++++++++++++++++++++ zsh/zlogin | 11 +++ zsh/zlogout | 3 + zsh/zpreztorc | 141 +++++++++++++++++++++++++++++++++++++ zsh/zprofile | 4 ++ zsh/zshenv | 72 +++++++++++++++++++ zsh/zshrc | 36 ++++++++++ 18 files changed, 698 insertions(+) create mode 100644 .gitmodules create mode 100644 README.md create mode 100644 aspell.en.pws create mode 160000 dotbot create mode 100644 git/gitconfig create mode 100644 git/gitignore_global create mode 100644 homebrew-install create mode 100755 install create mode 100644 install.conf.yaml create mode 100644 psqlrc create mode 100644 tmux.conf create mode 100644 vimrc create mode 100644 zsh/zlogin create mode 100644 zsh/zlogout create mode 100644 zsh/zpreztorc create mode 100644 zsh/zprofile create mode 100644 zsh/zshenv create mode 100644 zsh/zshrc diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..1ce5c11 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "dotbot"] + path = dotbot + url = https://github.com/anishathalye/dotbot diff --git a/README.md b/README.md new file mode 100644 index 0000000..a6e2100 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# Dotfiles + +```bash +$ git clone https://github.com/thermokarst/dotfiles.git ~/.dotfiles +$ cd ~/.dotfiles +$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" +$ ./homebrew-install +$ git clone https://github.com/chriskempson/base16-shell.git ~/.config/base16-shell +$ echo "/usr/local/bin/zsh" | sudo tee -a /etc/shells +$ chsh -s /usr/local/bin/zsh +$ git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto" +$ ./install +$ curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim +$ vim +PlugInstall +``` diff --git a/aspell.en.pws b/aspell.en.pws new file mode 100644 index 0000000..d9fad72 --- /dev/null +++ b/aspell.en.pws @@ -0,0 +1,6 @@ +personal_ws-1.1 en 5 +informatics +microbiome +Microbiome +QIIME +metadata diff --git a/dotbot b/dotbot new file mode 160000 index 0000000..ef558f8 --- /dev/null +++ b/dotbot @@ -0,0 +1 @@ +Subproject commit ef558f85d917c7d2fb52c17db10f0996ef92cb3f diff --git a/git/gitconfig b/git/gitconfig new file mode 100644 index 0000000..809c7a8 --- /dev/null +++ b/git/gitconfig @@ -0,0 +1,61 @@ +[user] + name = Matthew Dillon + email = matthewrdillon@gmail.com +[core] + editor = vim + excludesfile = /Users/matthew/.gitignore_global + pager = diff-so-fancy | less --tabs=4 -RFX +[color] + diff = auto + status = auto + branch = auto + interactive = auto + ui = auto +[gc] + auto = 1 +[merge] + summary=true + tool = vimdiff + conflictstyle = diff3 + prompt = false +[alias] + unstage = reset HEAD + uncommit = reset --soft HEAD^ + # http://stackoverflow.com/a/9074343 + lg1 = log \ + --graph \ + --abbrev-commit \ + --decorate \ + --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' \ + --all + lg2 = log \ + --graph \ + --abbrev-commit \ + --decorate \ + --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' \ + --all + lg = !"git lg1" + # https://gist.github.com/mwhite/6887990 + a = add + ap = add -p + c = commit --verbose + ca = commit -a --verbose + cm = commit -m + cam = commit -a -m + m = commit --amend --verbose + d = diff + ds = diff --stat + dc = diff --cached + s = status -s + co = checkout + cob = checkout -b + # list branches sorted by last modified + b = "!git for-each-ref --sort='-authordate' --format='%(authordate)%09%(objectname:short)%09%(refname)' refs/heads | sed -e 's-refs/heads/--'" + # list aliases + la = "!git config -l | grep alias | cut -c 7-" +[push] + default = upstream +[credential] + helper = osxkeychain +[pull] + rebase = true diff --git a/git/gitignore_global b/git/gitignore_global new file mode 100644 index 0000000..0da0427 --- /dev/null +++ b/git/gitignore_global @@ -0,0 +1,3 @@ +*~ +.DS_Store +.idea diff --git a/homebrew-install b/homebrew-install new file mode 100644 index 0000000..665723e --- /dev/null +++ b/homebrew-install @@ -0,0 +1,95 @@ +#!/usr/bin/env zsh + +taps=( + homebrew/binary + caskroom/cask + caskroom/fonts +) + +packages=( + ag + aspell + blackbox + brew-cask + cmake + cmus + diff-so-fancy + git + gnupg + go + gpg-agent + graphviz + heroku + htop-osx + httpie + hugo + imagemagick + node + openssl + pass + postgresql + python + python3 + reattach-to-user-namespace + tmux + tree + vim + wget + xz + zsh +) + +cask_packages=( + arq + dropbox + font-inconsolata + font-anonymous-pro + gitify + google-chrome + google-drive + java + macdown + pandoc + slack + spectacle + the-unarchiver + vagrant + virtualbox + xquartz +) + +function log() { + echo $* > /dev/stderr +} + +log "brew update" +brew update + +log "brew upgrade" +brew upgrade + +log "tapping" +for name in $taps +do + log "brew tap ${name}" + brew tap $name +done + +log "installing" +for name_and_args in $packages +do + log "brew install ${=name_and_args}" + brew install "${=name_and_args}" +done + +for name_and_args in $cask_packages +do + log "brew cask install ${=name_and_args}" + brew cask install "${=name_and_args}" +done + +log "brew cleanup" +brew cleanup + +log "brew linkapps" +brew linkapps diff --git a/install b/install new file mode 100755 index 0000000..b1baa33 --- /dev/null +++ b/install @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +set -e + +CONFIG="install.conf.yaml" +DOTBOT_DIR="dotbot" + +DOTBOT_BIN="bin/dotbot" +BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +cd "${BASEDIR}" +git submodule update --init --recursive "${DOTBOT_DIR}" + +"${BASEDIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${BASEDIR}" -c "${CONFIG}" "${@}" diff --git a/install.conf.yaml b/install.conf.yaml new file mode 100644 index 0000000..8c4312b --- /dev/null +++ b/install.conf.yaml @@ -0,0 +1,15 @@ +- clean: ['~'] + +- link: + ~/.tmux.conf: tmux.conf + ~/.gitconfig: git/gitconfig + ~/.gitignore_global: git/gitignore_global + ~/.psqlrc: psqlrc + ~/.zpreztorc: zsh/zpreztorc + ~/.zlogin: zsh/zlogin + ~/.zlogout: zsh/zlogout + ~/.zprofile: zsh/zprofile + ~/.zshenv: zsh/zshenv + ~/.zshrc: zsh/zshrc + ~/.aspell.en.pws: aspell.en.pws + ~/.vimrc: vimrc diff --git a/psqlrc b/psqlrc new file mode 100644 index 0000000..6c11a44 --- /dev/null +++ b/psqlrc @@ -0,0 +1,4 @@ +\echo `date +"%Y-%m-%d %H:%M:%S"` +\set PROMPT1 '%M:%[%033[1;31m%]%>%[%033[0m%] %n@%/%R%#%x ' +\pset null '[NULL]' +\pset border 2 diff --git a/tmux.conf b/tmux.conf new file mode 100644 index 0000000..2b51161 --- /dev/null +++ b/tmux.conf @@ -0,0 +1,53 @@ +# Automatic window title +setw -g automatic-rename + +# Fix LSOpenURLsWithRole() error on OS X. Requires reattach-to-user-namespace +set -g default-command "reattach-to-user-namespace -l /usr/local/bin/zsh" + +# remap prefix to Control + a +set -g prefix C-a +unbind C-b +bind C-a last-window + +set -g default-terminal "screen-256color" + +# http://www.unwiredcouch.com/2013/11/15/my-tmux-setup.html +# Force a reload of the config file +unbind r +bind r source-file ~/.tmux.conf + +# Start window numbering at 1 for easier switching +set -g base-index 1 + +# Open new panes & splits in the same directory +bind c new-window -c "#{pane_current_path}" +bind % split-window -h -c "#{pane_current_path}" +bind '"' split-window -c "#{pane_current_path}" + +# hjkl pane traversal +bind h select-pane -L +bind j select-pane -D +bind k select-pane -U +bind l select-pane -R + +set-option -g status-bg colour18 +set-option -g status-fg colour136 +set -g status-interval 0 # Changed for El Capitan issues +set -g status-justify centre +set -g status-left-length 50 +set -g status-right-length 140 +set -g status-left '#[fg=green]#H#[default] session:#S' +set -g status-right '#[fg=white,bg=default]%a %l:%M:%S %p#[default] #[fg=blue]%m-%d-%Y' + +set-option -g renumber-windows on +set -sg escape-time 0 +set-option -g destroy-unattached 'off' + +# Enable mouse control (clickable windows, panes, resizable panes) +set -g mouse on + +bind-key -t vi-copy MouseDragEnd1Pane copy-pipe "pbcopy" +bind-key -t vi-copy v begin-selection +bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy" +unbind -t vi-copy Enter +bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy" diff --git a/vimrc b/vimrc new file mode 100644 index 0000000..c5fa784 --- /dev/null +++ b/vimrc @@ -0,0 +1,161 @@ +call plug#begin() + Plug 'chriskempson/base16-vim' + Plug 'wakatime/vim-wakatime' + Plug 'nvie/vim-flake8' + Plug 'vim-airline/vim-airline' + Plug 'vim-airline/vim-airline-themes' + Plug 'airblade/vim-gitgutter' + Plug 'ntpeters/vim-better-whitespace' +call plug#end() + +set t_Co=256 + +if filereadable(expand("~/.vimrc_background")) + let base16colorspace=256 + source ~/.vimrc_background +endif +set background=dark + +let g:airline_theme='base16' + +" default encoding +set encoding=utf-8 + +" Enable file type detection and do language-dependent indenting. +filetype plugin indent on + +" turn on syntax highlighting +syntax enable +syntax on + +" turn on line numbering +set number + +" make backspace behave as expected +set backspace=indent,eol,start + +" set up whitespace substitutions +set list +set listchars=tab:▸\ ,extends:>,precedes:<,trail:~ + +" highlight current line +set cursorline + +" show matching ({[]}) +set showmatch + +" show a vertical bar on right side of editor +set colorcolumn=80 + +highlight LineNr ctermfg=DarkGrey + +" number of visual spaces per tab +set tabstop=4 + +" number of spaces in tab when editing +set softtabstop=4 + +" tabs are spaces +set expandtab + +" self-explanatory +set autoindent +" +" show airline all the time +set laststatus=2 + +" set up central backups +set backup +set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp +set backupskip=/tmp/*,/private/tmp/* +set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp +set writebackup + +" change the mapleader from \ to , +let mapleader=" " + +" netrw config +let g:netrw_liststyle=0 " thin (change to 3 for tree) +let g:netrw_banner=0 " no banner +let g:netrw_altv=1 " open files on right +let g:netrw_preview=1 " open previews vertically +let g:netrw_list_hide='\.git,\.idea,.*\.swp$,.*\.pyc$,__pycache__,\.DS_Store' + +" http://ivanbrennan.nyc/blog/2014/01/16/rigging-vims-netrw/ +fun! VexOpen(dir) + let g:netrw_browse_split=4 + let vex_width=25 + execute "Vexplore " . a:dir + let t:vex_buf_nr = bufnr("%") + wincmd H + call VexSize(vex_width) +endf + +fun! VexClose() + let cur_win_nr = winnr() + let target_nr = ( cur_win_nr == 1 ? winnr("#") : cur_win_nr ) + 1wincmd w + close + unlet t:vex_buf_nr + execute (target_nr - 1) . "wincmd w" + call NormalizeWidths() +endf + +fun! VexSize(vex_width) + execute "vertical resize" . a:vex_width + set winfixwidth + call NormalizeWidths() +endf + +fun! NormalizeWidths() + let eadir_pref = &eadirection + set eadirection=hor + set equalalways! equalalways! + let &eadirection = eadir_pref +endf + +fun! VexToggle(dir) + if exists("t:vex_buf_nr") + call VexClose() + else + call VexOpen(a:dir) + endif +endf + +noremap :call VexToggle(getcwd()) +noremap ` :call VexToggle("") + +augroup NetrwGroup + autocmd! BufEnter * call NormalizeWidths() +augroup END + +" PEP8 formatting +au BufNewFile,BufRead *.py + \ set tabstop=4 | + \ set softtabstop=4 | + \ set shiftwidth=4 | + \ set textwidth=79 | + \ set expandtab | + \ set autoindent | + \ set fileformat=unix | + +" Everybody else +au BufNewFile,BufRead *.js, *.html, *.css + \ set tabstop=2 | + \ set softtabstop=2 | + \ set shiftwidth=2 | + +" Stop the YAML madness +autocmd FileType yaml setl indentkeys-=<:> + +" show open buffers in airline +let g:airline#extensions#tabline#enabled = 1 + +" show just the filename +let g:airline#extensions#tabline#fnamemod = ':t' + +" cycle to next buffer +nmap l :bnext + +" cycle to previous buffer +nmap h :bprevious diff --git a/zsh/zlogin b/zsh/zlogin new file mode 100644 index 0000000..c59f3da --- /dev/null +++ b/zsh/zlogin @@ -0,0 +1,11 @@ +# +# Executes commands at login post-zshrc. +# +# Execute code that does not affect the current session in the background. +{ + # Compile the completion dump to increase startup speed. + zcompdump="${ZDOTDIR:-$HOME}/.zcompdump" + if [[ -s "$zcompdump" && (! -s "${zcompdump}.zwc" || "$zcompdump" -nt "${zcompdump}.zwc") ]]; then + zcompile "$zcompdump" + fi +} &! diff --git a/zsh/zlogout b/zsh/zlogout new file mode 100644 index 0000000..4871bd1 --- /dev/null +++ b/zsh/zlogout @@ -0,0 +1,3 @@ +# +# Executes commands at logout. + diff --git a/zsh/zpreztorc b/zsh/zpreztorc new file mode 100644 index 0000000..9decea6 --- /dev/null +++ b/zsh/zpreztorc @@ -0,0 +1,141 @@ +# +# Sets Prezto options. +# + +# General +# + +# Set case-sensitivity for completion, history lookup, etc. +# zstyle ':prezto:*:*' case-sensitive 'yes' + +# Color output (auto set to 'no' on dumb terminals). +zstyle ':prezto:*:*' color 'yes' + +# Set the Zsh modules to load (man zshmodules). +# zstyle ':prezto:load' zmodule 'attr' 'stat' + +# Set the Zsh functions to load (man zshcontrib). +# zstyle ':prezto:load' zfunction 'zargs' 'zmv' + +# Set the Prezto modules to load (browse modules). +# The order matters. +zstyle ':prezto:load' pmodule \ + 'environment' \ + 'terminal' \ + 'editor' \ + 'history' \ + 'directory' \ + 'spectrum' \ + 'utility' \ + 'completion' \ + 'git' \ + 'prompt' \ + 'tmux' \ + 'gpg' + +# +# Editor +# + +# Set the key mapping style to 'emacs' or 'vi'. +zstyle ':prezto:module:editor' key-bindings 'vi' + +# Auto convert .... to ../.. +# zstyle ':prezto:module:editor' dot-expansion 'yes' + +# +# Git +# + +# Ignore submodules when they are 'dirty', 'untracked', 'all', or 'none'. +# zstyle ':prezto:module:git:status:ignore' submodules 'all' + +# +# GNU Utility +# + +# Set the command prefix on non-GNU systems. +# zstyle ':prezto:module:gnu-utility' prefix 'g' + +# +# History Substring Search +# + +# Set the query found color. +# zstyle ':prezto:module:history-substring-search:color' found '' + +# Set the query not found color. +# zstyle ':prezto:module:history-substring-search:color' not-found '' + +# Set the search globbing flags. +# zstyle ':prezto:module:history-substring-search' globbing-flags '' + +# +# Pacman +# + +# Set the Pacman frontend. +# zstyle ':prezto:module:pacman' frontend 'yaourt' + +# +# Prompt +# + +# Set the prompt theme to load. +# Setting it to 'random' loads a random theme. +# Auto set to 'off' on dumb terminals. +zstyle ':prezto:module:prompt' theme 'cloud' + +# +# Screen +# + +# Auto start a session when Zsh is launched in a local terminal. +# zstyle ':prezto:module:screen:auto-start' local 'yes' + +# Auto start a session when Zsh is launched in a SSH connection. +# zstyle ':prezto:module:screen:auto-start' remote 'yes' + +# +# SSH +# + +# Set the SSH identities to load into the agent. +# zstyle ':prezto:module:ssh:load' identities 'id_rsa' 'id_rsa2' 'id_github' + +# +# Syntax Highlighting +# + +# Set syntax highlighters. +# By default, only the main highlighter is enabled. +# zstyle ':prezto:module:syntax-highlighting' highlighters \ +# 'main' \ +# 'brackets' \ +# 'pattern' \ +# 'cursor' \ +# 'root' +# +# Set syntax highlighting styles. +# zstyle ':prezto:module:syntax-highlighting' styles \ +# 'builtin' 'bg=blue' \ +# 'command' 'bg=blue' \ +# 'function' 'bg=blue' +# + +# +# Terminal +# + +# Auto set the tab and window titles. +zstyle ':prezto:module:terminal' auto-title 'yes' + +# +# Tmux +# + +# Auto start a session when Zsh is launched in a local terminal. +# zstyle ':prezto:module:tmux:auto-start' local 'yes' + +# Auto start a session when Zsh is launched in a SSH connection. +# zstyle ':prezto:module:tmux:auto-start' remote 'yes' diff --git a/zsh/zprofile b/zsh/zprofile new file mode 100644 index 0000000..bdcd884 --- /dev/null +++ b/zsh/zprofile @@ -0,0 +1,4 @@ +# +# Executes commands at login pre-zshrc. +# + diff --git a/zsh/zshenv b/zsh/zshenv new file mode 100644 index 0000000..19fee6e --- /dev/null +++ b/zsh/zshenv @@ -0,0 +1,72 @@ +# +# Defines environment variables. +# + +# +# Browser +# + +if [[ "$OSTYPE" == darwin* ]]; then + export BROWSER='open' +fi + +# +# Editors +# + +export EDITOR='vim' +export VISUAL='vim' +export PAGER='less' + +# +# Language +# + +if [[ -z "$LANG" ]]; then + export LANG='en_US.UTF-8' +fi + +# +# Paths +# + +typeset -gU cdpath fpath mailpath path + +# Set the the list of directories that cd searches. +# cdpath=( +# $cdpath +# ) + +# Set the list of directories that Zsh searches for programs. +path=( + /usr/local/{bin,sbin} + $path +) + +# +# Less +# + +# Set the default Less options. +# Mouse-wheel scrolling has been disabled by -X (disable screen clearing). +# Remove -X and -F (exit if the content fits on one screen) to enable it. +export LESS='-F -g -i -M -R -S -w -X -z-4' + +# Set the Less input preprocessor. +if (( $+commands[lesspipe.sh] )); then + export LESSOPEN='| /usr/bin/env lesspipe.sh %s 2>&-' +fi + +# +# Temporary Files +# + +if [[ ! -d "$TMPDIR" ]]; then + export TMPDIR="/tmp/$USER" + mkdir -p -m 700 "$TMPDIR" +fi + +TMPPREFIX="${TMPDIR%/}/zsh" +if [[ ! -d "$TMPPREFIX" ]]; then + mkdir -p "$TMPPREFIX" +fi diff --git a/zsh/zshrc b/zsh/zshrc new file mode 100644 index 0000000..5edddb9 --- /dev/null +++ b/zsh/zshrc @@ -0,0 +1,36 @@ +# Matthew Dillon +# matthewrdillon@gmail.com +# +# source Prezto. +if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then + source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" +fi + +# set up local bin dirs +export PATH="$PATH:$HOME/bin:$HOME/.bin" + +# shortcuts to projects +export CDPATH="$CDPATH:$HOME/caporaso/qiime2" +export CDPATH="$CDPATH:$HOME/projects" + +# shortcuts +alias mailserver="sudo python -m smtpd -n -c DebuggingServer localhost:25" +alias mongod="mongod --config /usr/local/etc/mongod.conf" +alias postgres="postgres -D /usr/local/var/postgres" +alias venv="source venv/bin/activate" +alias devenv="deactivate" +alias q="source activate q2dev" +alias i="ipython3" + +# set up golang +export GOPATH="/Users/matthew/go" +export PATH="$PATH:$GOPATH/bin" +export CDPATH="$CDPATH:$GOPATH/src/github.com:$GOPATH/src/code.google.com/p:$GOPATH/src/bitbucket.org" + +# set miniconda3 bin dir last +export PATH="$PATH:$HOME/miniconda3/bin" + +BASE16_SHELL=$HOME/.config/base16-shell/ +[ -n "$PS1" ] && [ -s $BASE16_SHELL/profile_helper.sh ] && eval "$($BASE16_SHELL/profile_helper.sh)" + +alias tmux="TERM=xterm-256color tmux"