Skip to content

Instantly share code, notes, and snippets.

@barberj
Last active May 2, 2016 02:22
Show Gist options
  • Save barberj/490af4e6d7baaff1bd56 to your computer and use it in GitHub Desktop.
Save barberj/490af4e6d7baaff1bd56 to your computer and use it in GitHub Desktop.
Dotfiles ~2015
--ignore-dir=tmp
echo 'Loading Darwin Resource Configuration'
function toggleHiddenFiles {
showall="$(defaults read com.apple.Finder AppleShowAllFiles)"
if [ "$showall" = "YES" ]; then
command \defaults write com.apple.Finder AppleShowAllFiles NO
else
command \defaults write com.apple.Finder AppleShowAllFiles YES
fi
command \killall Finder
}
function toggleSystemAudio {
# https://discussions.apple.com/thread/3632556?start=15&tstart=0
# http://commandlinemac.blogspot.com/2008/12/nvram.html
# http://idolinux.blogspot.com/2008/08/bash-script-error-handling.html
audio="$(sudo nvram SystemAudioVolume 2>&1)"
if [[ "$audio" =~ "Error" ]]; then
echo "Turning system volume on"
sudo nvram SystemAudioVolume="%db"
else
if [[ "$audio" =~ "%00" ]]; then
echo "Turning system volume on"
sudo nvram -d SystemAudioVolume
#sudo nvram SystemAudioVolume="%db"
else
echo "Turning system volume off"
sudo nvram SystemAudioVolume="%00"
fi
fi
}
eval "$(boot2docker shellinit)"
docker_rm () {
docker rm $(docker ps -aq)
}
docker_stop() {
docker stop $(docker ps -aq)
}
module Kernel
def prod
ActiveRecord::Base.establish_connection(:production)
end
def dev
ActiveRecord::Base.establish_connection(:development)
end
def staging
ActiveRecord::Base.establish_connection(:staging)
end
end
# remap prefix to Control + a
unbind C-b
set -g prefix C-a
bind C-a send-prefix
# vi mode
set-window-option -g mode-keys vi
unbind-key j
bind-key j select-pane -D
unbind-key k
bind-key k select-pane -U
unbind-key h
bind-key h select-pane -L
unbind-key l
bind-key l select-pane -R
# create new
unbind c
bind c new-window -c '#{pane_current_path}'
# split horizontally
unbind %
unbind |
bind | split-window -h -c '#{pane_current_path}'
# split vertically
#unbind "
bind S split-window -v -c '#{pane_current_path}'
# force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf
# leader a shift [ ( to move panes around)
# leader a esc 1|2 (evenly space)
# http://stackoverflow.com/questions/15439294/tmux-switch-the-split-style-of-two-adjacent-panes
call pathogen#infect()
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
"
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
" http://vimdoc.sourceforge.net/htmldoc/options.html
" tab is 4 spaces
set ts=2
" tabs expanded to spaces
set expandtab
" Number of spaces to use for each step of (auto)indent.
set sw=2
" show line numbers on side
set number
" Show the line and column number of the cursor position in bottom right corner
set ruler
" Ignore Case when searching
set ignorecase
" If you take time to put case into search, lets honor by searching for case
" match
set smartcase
" set the file format for line endings
" set ffs=unix
"colorscheme murphy
"colorscheme desert
hi Comment ctermfg=blue
" no error bells, no beep or flash
set noeb vb t_vb=
" Toggle line numbers and fold column for easy copying:
nnoremap <F2> :set nonumber!<CR>:set foldcolumn=0<CR>
let g:pydiction_location = '~/.vim/bundle/pydiction-1.2/plugin/complete-dict'
" enable loading the plugin files, (filetype plugin indent on) enable loading the indent file
let g:syntastic_scss_checkers = ['scss_lint']
filetype plugin on
" no backup files
set nobackup
" no backup file while editing
set nowritebackup
" no swap files
set noswapfile
" NERDTree
" i am never gonna edit compiled files, don't show me them
let NERDTreeIgnore=['\.pyc']
let NERDTreeShowHidden=1
"To define a mapping which uses the "mapleader" variable, the special string
"<Leader>" can be used. It is replaced with the string value of "mapleader".
"If "mapleader" is not set or empty, a backslash is used instead.
"Example:
" :map <Leader>A oanother line <Esc>
" Works like:
" :map \A oanother line <Esc>
" But after:
" :let mapleader = ","
" It works like:
" :map ,A oanother line <Esc>
"
" Note that the value of "mapleader" is used at the moment the
" mapping is
" defined. Changing "mapleader" after that has no effect for
" already defined mappings.
" open
map <leader>n :NERDTreeToggle<CR>
" strip extra space off the end of lines
autocmd FileType python autocmd BufWritePre <buffer> :%s/\s\+$//e
autocmd FileType python setlocal tabstop=4 shiftwidth=4 softtabstop=4
" https://github.com/sontek/dotfiles/blob/master/_vimrc
" ctrl-jklm changes to that split
map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-l> <c-w>l
map <c-h> <c-w>h
set list lcs=trail:·
" http://vimcasts.org/episodes/tidying-whitespace/
function! Preserve(command)
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" Do the business:
execute a:command
" Clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction
nnoremap <leader>strip :call Preserve("%s/\\s\\+$//e")<CR>
export PATH="./bin:/opt/boxen/rbenv/shims:bin:/opt/boxen/rbenv/bin:/opt/boxen/ruby-build/bin:node_modules/.bin:/opt/boxen/nodenv/shims:/opt/boxen/nodenv/bin:/opt/boxen/bin:/opt/boxen/homebrew/bin:/opt/boxen/homebrew/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin"
fpath=(/usr/local/share/zsh-completions $fpath)
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
export AWSSH_BASTION_HOST=omni1.salesloft.com
export AWSSH_USERNAME=justinbarber
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="robbyrussell"
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"
# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git bundler docker)
source $ZSH/oh-my-zsh.sh
source ~/.darwinrc
source ~/.dockerrc
source ~/src/awssh/setup.zsh
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
export EDITOR='vim'
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# ssh
# export SSH_KEY_PATH="~/.ssh/dsa_id"
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
alias git="hub"
alias git_prune="git remote prune origin;git gc --prune=now"
alias be="bundle exec"
alias restart_memcache="pkill memcached"
alias restart_caches="redis-cli flushall;restart_memcache"
alias enable_twilio="ngrok http 10099"
alias jslint="jshint app --extra-ext=.es6 --config=.es6hintrc"
# http://www.thegeekstuff.com/2009/01/how-to-backup-and-restore-postgres-database-using-pg_dump-and-psql/
alias dev_dump="pg_dump melody_development -f development.psql"
alias dev_load="psql -d melody_development -f development.psql"
alias gong-hit="curl -XPOST http://gongloft.herokuapp.com/queue/d3ab47bbc526fef11ddf807420810a9fe4c1bd4f"
fix_ws () {
LC_ALL=C && find . -name "*rb" -type f -print0 | xargs -0 sed -i '' -E "s/[[:space:]]+$//"
}
#ulimit -n 4096
[ -f /opt/boxen/env.sh ] && source /opt/boxen/env.sh
ssh_jump () {
ssh-agent
ssh-add ~/.ssh/id_rsa
ssh -A ec2-user@54.175.120.47
}
barberian_raid () {
curl -Sso /usr/local/bin/pillage https://gist.githubusercontent.com/barberj/9f7f1834a89ad6c3abc6/raw/barberian_raid.sh && \
chmod +x /usr/local/bin/pillage && \
pillage && \
rm /usr/local/bin/pillage
}
sandt () {
apm disable ex-mode vim-mode
}
me () {
apm enable ex-mode vim-mode
}
pointalism () {
curl -Sso ~/.irbrc https://gist.githubusercontent.com/barberj/490af4e6d7baaff1bd56/raw/.irbrc && \
curl -Sso ~/.darwinrc https://gist.githubusercontent.com/barberj/490af4e6d7baaff1bd56/raw/.darwinrc && \
curl -Sso ~/.vimrc https://gist.githubusercontent.com/barberj/490af4e6d7baaff1bd56/raw/.vimrc && \
curl -Sso ~/.tmux.conf https://gist.githubusercontent.com/barberj/490af4e6d7baaff1bd56/raw/.tmux.conf && \
curl -Sso ~/.ackrc https://gist.githubusercontent.com/barberj/490af4e6d7baaff1bd56/raw/.ackrc && \
curl -Sso ~/.zshrc https://gist.githubusercontent.com/barberj/490af4e6d7baaff1bd56/raw/.zshrc
}
pathogen_mutate () {
curl -Sso /usr/local/bin/mutate https://gist.githubusercontent.com/barberj/a56f02eb72c40f6bdbe1/raw/pathogen_mutate.sh && \
chmod +x /usr/local/bin/mutate
}
disable_ipv6 () {
networksetup -setv6off Wi-Fi
}
enable_ipv6 () {
networksetup -setv6automatic Wi-Fi
}
export NVM_DIR="/Users/barberj/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
autoload -U add-zsh-hook
load-nvmrc() {
if [[ -f .nvmrc && -r .nvmrc ]]; then
nvm use
fi
}
add-zsh-hook chpwd load-nvmrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment