Skip to content

Instantly share code, notes, and snippets.

@dwelch2344
Last active October 11, 2015 21:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dwelch2344/3924889 to your computer and use it in GitHub Desktop.
Save dwelch2344/3924889 to your computer and use it in GitHub Desktop.
Environment Configs
# case insensitive and recursive by default
-r
# follow symlinks
# --follow
# Smart Case
--smart-case
# Set pager to more (much better than piping)
--pager=$PAGER
# handle smarty templates as PHP files
#--type-add=php=.tpl
--type-set=smarty=.tpl
# Handle .less files
--type-add=css=.less
# Handle include files
--type-add=php=.inc
# ignore clover files
--type-set=clover=.grf,.ctl2
--noclover
PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
PATH=$PATH\:/opt/subversion/bin
export PATH
ZSH=$HOME/.oh-my-zsh
ZSH_THEME="dwelch"
# CASE_SENSITIVE="true"
DISABLE_AUTO_UPDATE="true"
COMPLETION_WAITING_DOTS="true"
# 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)
plugins=(git)
source $ZSH/oh-my-zsh.sh
set -o vi
function git_prompt_info() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_PREFIX$(current_branch)$ZSH_THEME_GIT_PROMPT_SUFFIX"
}
function get_pwd() {
print -D $PWD
}
function battery_charge() {
if [ -e ~/bin/batcharge.py ]
then
echo `python ~/bin/batcharge.py`
else
echo ''
fi
}
function put_spacing() {
local git=$(git_prompt_info)
if [ ${#git} != 0 ]; then
((git=${#git} - 10))
else
git=0
fi
local bat=$(battery_charge)
if [ ${#bat} != 0 ]; then
((bat = ${#bat} - 18))
else
bat=0
fi
local termwidth
(( termwidth = ${COLUMNS} - 3 - ${#HOST} - ${#$(get_pwd)} - ${bat} - ${git} ))
local spacing=""
for i in {1..$termwidth}; do
spacing="${spacing} "
done
echo $spacing
}
function precmd() {
print -rP '
$fg[cyan]%m: $fg[yellow]$(get_pwd)$(put_spacing)$(git_prompt_info) $(battery_charge)'
}
PROMPT='%{$reset_color%}→ '
ZSH_THEME_GIT_PROMPT_PREFIX="[git:"
ZSH_THEME_GIT_PROMPT_SUFFIX="]$reset_color"
ZSH_THEME_GIT_PROMPT_DIRTY="$fg[red]+"
ZSH_THEME_GIT_PROMPT_CLEAN="$fg[green]"
syntax enable " Syntax highlighting is the shiz
colorscheme desert " Give me a nice color scheme.
set nowrap " Don't wrap by default. That's icky.
set ai " Auto Indent
" Highlight my todos *NOT WORKING* why?
syn match myTodo "\<\l\{2\}TODO\>"
hi def link myTodo Todo
" Searching
set hlsearch " Hilight the found searches
set incsearch " Incremental Searching
set ignorecase " ignore case in searching
set smartcase " Smart case (case insensitive when until an uppercase letter is typed)
set fileformat=unix
set wildmode=list:longest " Autocomplete like you would expect
set ruler " show the ruler
set number " show line numbers
set tabstop=4 " tabs are 4 spaces
set noexpandtab " tabs are tabs
set shiftwidth=4 " shifting moves 4 spaces
" Use filetype plugins, e.g. for PHP
filetype plugin on
" Turn On Spell Checking for specific filetypes
setlocal spell spelllang=en_us
set nospell
autocmd FileType html,text,txt,smarty set spell
" Set Filetypes
au BufNewFile,BufRead *.less set filetype=css
au BufNewFile,BufRead *.txt set filetype=text
" Seriously, filetype is unix...
autocmd BufRead * silent! set ff=unix
" No toolbar
set guioptions-=T
" Autocomplete php functions
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
" Text expansion
/* */<esc>v3k<kwwv3lrder: 1px solid skyblue; padding: 10px; margin 10px;'>");
{* *}<esc>2kbvwh_r} 1px solid skyblue; padding: 10px; margin 10px;'>
error_log(__METHOD__.'::'.__LINE__ . ' ' . $var);<esc>2bvwh
/* */<esc>vk<k3wvwh$this, true)dbel block */
ab scss {literal}<style><cr>#asdf{<cr><cr>}<cr></style>{/literal}<esc>kki
}<esc>v<v2k<k6wvwhesponseMessage::getInstance()->addError($e->getMessage());
}<esc>k5wvwhte_Lib_ResponseMessage::getInstance()->addError($e->getMessage());
" Quick regex to add quotes around HTML attributes
cabbrev quotize %s/\([^&^?]\)\(\<[[:alnum:]-]\{-}\)=\([[:alnum:]-#%]\+\)/\1\2="\3"/g
" Remember where my cursor was last time I was in this file
set viminfo='10,\"1000,:20,%,n~/.viminfo
au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif
"Change paste without overriding the default buffer. (cp{motion})
nmap <silent> cp :set opfunc=ChangePaste<CR>g@
function! ChangePaste(type, ...)
silent exe "normal! `[v`]\"_c"
silent exe "normal! p"
endfunction
"Backspace disables highlighting
noremap <BS> :noh<CR>
noremap <leader>T :CommandTBuffer<CR>
noremap <leader><BS> :CommandTFlush<CR>
" View Documentation
"noremap <silent> gd :!lynx http://php.net/<cword><CR>
noremap <silent> gd :!open dash://<cword><CR>
" CD into /Volumes/build by default
if isdirectory('/Volumes/build/dropship.com')
cd /Volumes/build/dropship.com
endif
" Point the taglist plugin to the ctags executable
let Tlist_Ctags_Cmd = '/usr/bin/ctags'
" Creates non-existing parent directories on save.
augroup BWCCreateDir
au!
autocmd BufWritePre * if expand("<afile>")!~#'^\w\+:/' && !isdirectory(expand("%:h")) | execute "silent! !mkdir -p ".shellescape(expand('%:h'), 1) | redraw! | endif
augroup END
" Auto source this file when written.
:au! BufWritePost $MYVIMRC source $MYVIMRC
curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh
@dwelch2344
Copy link
Author

Also see https://gist.github.com/3179443 for a more in-depth ZSH instruction

@dwelch2344
Copy link
Author

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