Skip to content

Instantly share code, notes, and snippets.

@dbb
Created August 22, 2011 17:06
Show Gist options
  • Save dbb/1162918 to your computer and use it in GitHub Desktop.
Save dbb/1162918 to your computer and use it in GitHub Desktop.
macstuff
" dbbolton's .vimrc
"
" don't use vi settings
set nocompatible
" diff options
set diffopt=vertical,iwhite,filler
set noscrollbind
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
\ | wincmd p | diffthis
" diable auto-commenting
set formatoptions=lnq
autocmd FileType * set formatoptions=lnq
autocmd FileType * set formatoptions-=c formatoptions-=r formatoptions-=o
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
" break long lines in plain text files
" use gqq
"set textwidth=78
" copy indentation from preceding line
"set autoindent
" what backsapce can delete in i mode
set backspace=eol,start,indent
" keep x commands/search patterns
set history=20
set hlsearch " highlight search results
set mouse=a " mouse support"
" show line numbers relative to current line
"set relativenumber
set number
" create .un~ file
"set undofile
" ruler with clock
" set rulerformat=%55(%{strftime('%a\ %b\ %e\ %I:%M\ %p')}\ %5l,%-6(%c%V%)\ %P%)
" status bar etc ------------------------------------------------------------
set ruler " show line and column of cursor
set showcmd
set showmode
set ls=2 " always show status bar
"set statusline=\ %F%m%r%h\ %w\ \ CWD:\ %r%{CurDir()}%h\ \ \ Line:\ %l/%L:%c
set statusline=%<%1*───\ %5*%f%1*%(\ ───\ %4*%h%1*%)%(\ ───\ %4*%m%1*%)%(\ ───\ %4*%r%1*%)\ ───%=───\ %2*%b(0x%B)%1*\ ───\ %3*%l,%c%V%1*\ ───\ %5*%P%1*\ ───%0*
set showcmd " show partially entered commands
set showmode " display INSERT when in i mode
set whichwrap=h,l,~,[,],<,>
set wildmode=list:longest,full
set wrap
" allow pasting in the console
"set paste
syntax on
" force a file's syntax highlighting type
au BufNewFile,BufRead .vimperatorrc setf vim
au BufNewFile,BufRead *.md set filetype=md
au BufNewFile,BufRead *.cf set filetype=configfile
" extra bindings ------------------------------------------------------------
let mapleader = ","
let g:mapleader = ","
nmap <leader>a A
nmap <leader>c 0i#<Esc>
nmap <leader>d :close<CR>
nmap <leader>e :colo
nmap <leader>h iprint <<'EOF';<Esc>^
nmap <leader>o iopen(my $, "<", "");<Esc>^f$a
nmap <leader>r @:
nmap <leader>s ddpk
nmap <leader>t :source ~/.vim/scripts/tidydiff.vim
nmap <leader>v "+gP<CR>
nmap <leader>w :w!<CR>
nmap <leader>I ^i <Esc>i
nmap <leader>$ f$li
nmap <leader>@ f@li
nmap <leader>; A;<Esc>^
nmap <leader># i#!/usr/bin/env perl<CR>use strict;
\<CR>use warnings;<CR>use 5.010;<cr><esc>:set filetype=perl<ENTER>i<CR>
" maps that override default commands
nmap t :tabnew
"map <leader>e :e! ~/.vimrc<cr>
autocmd! bufwritepost vimrc source ~/.vimrc
" ---------------------------------------------------------------------------
" tabs
set expandtab
set shiftwidth=4
set tabstop=4
set smarttab
set list " make tabs visible
set listchars=tab:>-,trail:-
" the other kind of tabs
nmap <leader>n :tabnext<cr>
nmap <leader>p :tabprevious<cr>
" Smart way to move btw. windows
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
function! CurDir()
let curdir = substitute(getcwd(), '/home/dbb/', "~/", "g")
return curdir
endfunction
if $TERM == 'rxvt-unicode'
colorscheme lucius88
else
colorscheme desert
endif
" turn filetype back on
filetype on
filetype plugin on
filetype indent on
function! SetExecutableBit()
let fname = expand("%:p")
checktime
execute "au FileChangedShell " . fname . " :echo"
silent !chmod a+x %
checktime
execute "au! FileChangedShell " . fname
endfunction
command! Xbit call SetExecutableBit()
set formatoptions=lnq
# applications
alias jd='java -jar '"$HOME"'/downloads/JDownloader/JDownloader.jar'
alias n='fceux --xscale 3 --yscale 3'
alias v='vim'
alias we='weechat-curses'
alias x='startx'
# archives
alias tx='tar xf'
alias bx='tar xjf'
alias bz='tar cjf' # OUT IN
# colors
#eval "`dircolors -b`"
alias ls='ls -G'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
# cp and scp
alias cpr='cp -r'
alias scpr='scp -r'
# games
alias ng1='mednafen '"$HOME"'/games/nes/Ninja_Gaiden_1.nes'
alias ng2='mednafen '"$HOME"'/games/nes/Ninja_Gaiden_2.nes'
alias ng3='mednafen '"$HOME"'/games/nes/Ninja_Gaiden_3.nes'
alias sc='mednafen '"$HOME"'/games/nes/Super_C.nes'
# git
alias gp='git push -u origin master'
alias gc='git commit -m'
# ls
alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'
# chmod
alias cx='chmod u+x'
# debian
alias afs='apt-file search --regexp'
alias aps='aptitude search'
alias apsh='aptitude show'
alias apsrc='apt-get source'
alias apv='apt-cache policy'
alias apdg='su -c "aptitude update && aptitude safe-upgrade"'
alias apud='su -c "aptitude update"'
alias apug='su -c "aptitude safe-upgrade"'
alias update='su -c "aptitude update"'
alias upgrade='su -c "aptitude safe-upgrade"'
alias di='su -c "dpkg -i ./*.deb"'
alias quikdeb='/usr/bin/time -p dpkg-buildpackage -rfakeroot -us -uc'
# cd shortcuts
alias up='cd ..'
alias back='cd -'
# files
alias gtk='vim '"$HOME"'/.gtkrc.mine'
alias ob-as='vim '"$HOME"'/.config/openbox/autostart.sh'
alias ob-rc='vim '"$HOME"'/.config/openbox/rc.xml'
alias sz='source "'"$HOME"'/.zshrc"'
alias va='vim '"$HOME"'/.zaliases ; source '"$HOME"'/.zaliases'
alias vz='vim '"$HOME"'/.zshrc ; source '"$HOME"'/.zshrc'
alias xdef='vim '"$HOME"'/.Xdefaults ; xrdb -load '"$HOME"'/.Xdefaults'
alias xconf='su -c "vim /etc/X11/xorg.conf"'
# find
alias fh='find . -maxdepth 1 -iname'
alias fd='find . -iname'
# grep
alias igrep='egrep -i'
alias ngrep='egrep -in'
# heredocs
alias hdoc='cat << EOF >'
# make
alias mi='su -c "make install"'
# misc
alias clear-hosts='rm -v '"$HOME"'/.ssh/known_hosts'
alias duh='du -hs'
#alias kiw='kill '"$(pidof firefox-bin)"
alias gov='su root -c "'"$HOME"'/bin/cpu-gov"'
alias q='exit'
alias :q='exit'
alias quit='exit'
alias temp='sensors'
alias xsr='xsetroot -solid "#303030"'
# net
alias png='ping -c2'
alias pingr='ping -c 2 192.168.1.1'
alias pingc='ping -c 2 comcast.com'
alias pingv='ping -c 2 verizon.net'
alias sr='ssh reddevil'
# octave
alias oct='octave --silent'
alias o='octave --silent --eval'
# perl
# ps
alias pse='ps -e'
# ROOT OPERATIONS ###############################
alias mntvid='su root -c "mount /dev/disk/by-label/VIDEOS /mnt/VIDEOS"'
alias net-if='su root -c "vim /etc/network/interfaces"'
alias netif='su root -c "vim /etc/network/interfaces"'
alias s='su --login root'
alias shn='su -c "shutdown -h now"'
alias srn='su -c "shutdown -r now"'
alias wrs='su -c "ifdown wlan0 ; sleep 2s ; ifup wlan0"'
# rm
alias rf='rm -fr'
# time
alias sw='/usr/bin/time -f "\n----\n\nElapsed time: %E\n" cat'
alias t='/usr/bin/time -p'
# translation
alias deen='tw translate.google.com.de-en'
alias esen='tw translate.google.com.es-en'
alias fren='tw translate.google.com.fr-en'
alias ende='tw translate.google.com.en-de'
alias enes='tw translate.google.com.en-es'
alias enfr='tw translate.google.com.en-fr'
# web
alias websync='rsync -e ssh -av --exclude=".*" ~/web/dbbolton.us dbbolton@graffias.dreamhost.com:~/'
alias demus='rsync -e ssh -av --exclude=".*" ~/web/demus.co dbbolton@graffias.dreamhost.com:~/'
alias dbbo='rsync -e ssh -av --exclude=".*" ~/web/dbbo.co dbbolton@graffias.dreamhost.com:~/'
# zsh stuff
alias sa='source '"$HOME"'/.zaliases'
alias rh='rehash'
alias za='vim '"$HOME"'/.zaliases ; source '"$HOME"'/.zaliases'
# debian
export DEBEMAIL="dan@dbbo.us"
export DEBFULLNAME="Daniel Bolton"
# directories
export CDPATH=".:~:~/src"
# files
export HISTFILE="$HOME/.zhistory"
# grep
#export GREP_OPTIONS='--perl-regexp'
# history
export HISTSIZE=1000
export SAVEHIST=1000
# less
which lesspipe >/dev/null && eval "$(lesspipe)"
export LESS='-GRJx4P?f[%f]:[STDIN].?pB - [%pB\%]:\.\.\..'
# mail
export EMAIL='dan@dbbo.us'
export MAIL='/var/spool/mail/dbb'
# make
#export CFLAGS="-march=core2 -O3 -pipe -m64 -mfpmath=sse -msse -msse2 -mssse3"
export CFLAGS='-march=core2 -O2 -pipe'
export CXXFLAGS="${CFLAGS}"
export CONCURRENCY_LEVEL='2'
export MAKEFLAGS='-j 2'
# path
typeset -U path
for dir in ~/bin ~/games ~/perl/bin ; do
if [[ -z ${path[(r)$dir]} ]]; then
path=($dir $path)
fi
done
# perlbrew
export PERLBREW_ROOT="$HOME/perl"
# programs
export EDITOR='vim'
export PAGER='less'
export VISUAL='vim'
# characters that are not part of a word
export WORDCHARS=${WORDCHARS//[-]}
# dbbolton's zshrc
umask 022
# options
bindkey -v
setopt append_history
setopt auto_list
setopt correct
setopt extended_glob
setopt glob_dots
setopt nullglob
setopt equals
#setopt glob_subst
setopt extended_history
setopt hist_ignore_dups
setopt hist_save_no_dups
setopt inc_append_history
setopt interactive_comments
setopt list_packed
setopt magic_equal_subst
setopt nonomatch
# completion
autoload -U compinit
compinit
which dircolors >/dev/null && eval "$(dircolors -b)"
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*:descriptions' format '%U%B%d%b%u'
zstyle ':completion:*:warnings' format '%BNo matches for: %d%b'
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}'
zstyle ':completion:*' menu select
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zsh/cache
# setopt correctall
setopt complete_in_word
setopt list_ambiguous
# keys ######################################################################
autoload zkbd
bindkey -M vicmd '^R' redo
bindkey -M vicmd 'u' undo
bindkey -M vicmd 'ga' what-cursor-position
bindkey -M vicmd 'q' push-line
bindkey '^xp' history-beginning-search-forward
bindkey '^xn' history-beginning-search-backward
bindkey '^X^I' expand-or-complete-prefix
bindkey '^X^H' expand-history
bindkey '^o' accept-and-infer-next-history
#############################################################################
function precmd {
local TERMWIDTH
(( TERMWIDTH = ${COLUMNS} - 1 ))
PR_FILLBAR=""
PR_PWDLEN=""
local promptsize=${#${(%):---(%n@%m:%l)---()--}}
local pwdsize=${#${(%):-%~}}
local filesize=${#${(%):-$FILECOUNT}}
if [[ "$promptsize + $pwdsize" -gt $TERMWIDTH ]]; then
((PR_PWDLEN=$TERMWIDTH - $promptsize))
else
PR_FILLBAR="\${(l.(($TERMWIDTH - ($promptsize + $pwdsize + $filesize + 5)))..${PR_HBAR}.)}"
fi
# note: the 5 is for extra characters added: two double-quotes, a comma,
# a space, and an L
}
preexec () {
if [[ "$TERM" == "screen" ]]; then
local CMD=${1[(wr)^(*=*|sudo|-*)]}
echo -n "\ek$CMD\e\\"
fi
}
setcolors () {
autoload colors zsh/terminfo
if [[ "$terminfo[colors]" -ge 8 ]]; then
colors
fi
for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE BLACK; do
eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
(( count = $count + 1 ))
done
PR_NO_COLOR="%{$terminfo[sgr0]%}"
}
setcolors
setprompt () {
setopt prompt_subst
case $TERM in
xterm*)
PR_TITLEBAR=$'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\a%}'
;;
screen)
PR_TITLEBAR=$'%{\e_screen \005 (\005t) | %(!.-=[ROOT]=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\e\\%}'
;;
rxvt-unicode*)
PR_TITLEBAR=$'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\a%}'
;;
*)
PR_TITLEBAR=$'%n@%m:%~'
;;
esac
if [[ "$TERM" == "screen" ]]; then
PR_STITLE=$'%{\ekzsh\e\\%}'
else
PR_STITLE=''
fi
# a smaller prompt
PROMPT='$PR_BLUE%n$PR_NO_COLOR: ${PR_YELLOW}%c$PR_RED » $PR_NO_COLOR'
}
setprompt
source "$HOME/.zaliases"
source "$HOME/.zshenv"
source "$HOME/.zfunctions"
#!/bin/sh
# this is for downloading my configs when i'm on a mac at the library
curl -LO http://dactyl.googlecode.com/files/pentadactyl-1.0b7.2.xpi
curl -LO https://gist.github.com/raw/1162918/cb8d8b8f362765940f4e1ba7a02849678146a189/.vimrc
curl -LO https://gist.github.com/raw/1162918/b465b2f40b79a1164a780c49d7d9ca0cb8f08437/.zaliases
curl -LO https://gist.github.com/raw/1162918/4b53b89e2539bc421cf41154eb8815f64540df75/.zshrc
curl -LO https://gist.github.com/raw/1162918/01250c1b9553f33be860be8bfb3b1f1dcaa1ed26/.zshenv
curl -Lo ~/.zfunctions https://github.com/dbb/githome/raw/master/.zfunctions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment