<repo_name>c24t/minimal-dotfiles<file_sep>/zshrc
ZSHRC=$HOME/.zshrc

export ALIASES=$HOME/.aliases
export AUTO_ALIASES=$ALIASES/auto

PYTHONRC=$HOME/.pythonrc

export EDITOR=vim

autoload -Uz compinit && compinit
autoload -U promptinit && promptinit
autoload -U colors && colors

# Lines configured by zsh-newuser-install
HISTFILE=$HOME/.history
HISTSIZE=10000
SAVEHIST=1000000
setopt autocd extendedglob
unsetopt beep
bindkey -v
# End of lines configured by zsh-newuser-install

# source ~/.aliases/**/*
for file in $(find $ALIASES -follow); do source $file; done

# edit this file, and source it
alias vizsh="vim $ZSHRC && source $ZSHRC"

# add an alias
aaa () {
	echo "alias $1=\"$2\"" >> $AUTO_ALIASES
	source $AUTO_ALIASES 
	which $1
}


######### setopts ##############################################################

setopt INC_APPEND_HISTORY
setopt EXTENDED_HISTORY
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_SPACE
setopt HIST_REDUCE_BLANKS

setopt ALWAYS_TO_END
setopt AUTO_NAME_DIRS
setopt AUTO_PUSHD
setopt NO_BEEP

setopt HIST_FIND_NO_DUPS
setopt EXTENDED_HISTORY
setopt HIST_EXPIRE_DUPS_FIRST # gets slow with a big history
setopt HIST_VERIFY

# clear rprompt on new commands, thank god for this
setopt transientrprompt


######### bindkeys #############################################################

bindkey -M viins '^?' backward-delete-char
bindkey -M viins '^H' backward-delete-char

bindkey "^[[A" history-beginning-search-backward
bindkey "^[[B" history-beginning-search-forward

# :nmap <Space> i
bindkey -M vicmd ' ' vi-insert

export LESS="-iFRX"

bindkey "^R" history-incremental-search-backward
bindkey "^T" push-line-or-edit

# `man zshcompsys`
# The following lines were added by compinstall
zstyle ':completion:*' completer _expand _complete _ignored _match _approximate
zstyle ':completion:*' completions 1
zstyle ':completion:*' format 'completing %d'
zstyle ':completion:*' glob 1
zstyle ':completion:*' group-name ''
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
zstyle ':completion:*' matcher-list '' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} r:|[._-]=** r:|=** l:|=*'
zstyle ':completion:*' match-original both
zstyle ':completion:*' max-errors 3
zstyle ':completion:*' prompt '%e%e%e'
zstyle ':completion:*' substitute 1
#zstyle :compinstall filename '$HOME/compinstalled'
# End of lines added by compinstall

source $PYTHONRC

# vim:ft=zsh:noet:sw=2 ts=2
<file_sep>/script/uniq.py
#! /usr/bin/env python

import fileinput
import sys

if __name__ == "__main__":
    lines = set()
    for line in fileinput.input():
        if line not in lines:
            sys.stdout.write(line)
        lines.add(line)
<file_sep>/aliases/essentials
alias ls="ls --color=auto"
alias ll="ls -GFlh"
alias l="ll"
alias la="ls -lah"
alias lll="la"
alias t="tree"

alias g="grep"
alias psa="ps aux"
alias rmrf="rm -rf"
alias pull="git pull"
alias pul=pull
alias push="git push"

# dates
alias longstardate="date +%Y%m.%d.%H%M"
alias shortdate="date +%d%b"
alias epoch="date +%s"

# tmux
alias tl="tmux ls"
alias tt="tmux attach -t"

# findfile, findfilefollow
ff () { find . -type f -iname "*$1*" | grep -i "$1" }
fff () { find . -type f -iname "*$1*" -follow | grep -i "$1"}

fd () { find . -type d -iname "*$1*" | grep -i "$1" }
fdf () { find . -type d -iname "*$1*" -follow | grep -i "$1"}

# grepall, grepallfollow
ga () {find . -type f -print0 | xargs -0 egrep "$1" | echo "balls"}
gaa () {find . -type f -follow -print0 | xargs -0 egrep "$1"}

# grepall select by suffix
gas () {find . -type f -name "*.$2" -print0 | xargs -0 egrep -n "$1" --color=auto}
gaas () {find . -type f -follow -name "*.$2" -print0 | xargs -0 egrep -n "$1" --color=auto}

# `ps aux` cut -- get the pid
psac () {awk '{print $2}'}

alias s="screen -A -fa -U -D -R"
alias sls="screen -ls"

mcd () { mkdir -p $1 && cd $1 }

# dir stack management
alias d="dirs -lp"
alias pd="popd -q"
alias cdd="cd -P"

# git
alias gg="git grep"
alias gbh="git rev-parse --short HEAD"
alias gbhh="git rev-parse --short HEAD\^"
alias gbhhh="git rev-parse --short HEAD\^\^"
alias stash="git stash"
alias glg="git lg"
alias gbn="git symbolic-ref HEAD --short"
alias gg="git grep"

# archeology
hf () {
	< $HISTFILE | grep -i $1 | cut -d ';' -f 2- | ~/script/uniq.py | grep -i --color=auto $1
}

alias vialiases="( cd $ALIASES && vim essentials ) && source $ZSHRC"

# vim:ft=zsh:noet:sw=2 ts=2
<file_sep>/setup.zsh
#! /usr/bin/env zsh

sudo chsh -s $(which zsh) $USER

# go install coreutils if this line fails on OSX
dotdir=$(readlink -f $(pwd))
backupdir=dotfiles.$(date +%s).backup

function dotrelink () {
  if [[ -a $2 ]]; then
    mv -v $2 $backupdir;
  fi
  ln -svf $dotdir/$1 $2
}

(
  cd $HOME
  mkdir $backupdir

  mkdir -p .vim/swap/
  mkdir -p .vim/undo/

  dotrelink zshrc .zshrc
  dotrelink vimrc .vimrc
  dotrelink pythonrc .pythonrc
  dotrelink screenrc .screenrc
  dotrelink tmuxrc .tmux.conf
  dotrelink inputrc .inputrc
  mkdir -p .aliases

  mkdir -p script
  dotrelink script/uniq.py script/uniq.py

  mkdir -p .vim/autoload
  mkdir -p .vim/bundle
  dotrelink vim-pathogen/autoload/pathogen.vim .vim/autoload/pathogen.vim

  dotrelink vim-plugins/vim-fugitive .vim/bundle/vim-fugitive
  dotrelink vim-plugins/vim-surround .vim/bundle/vim-surround
  dotrelink vim-plugins/vim-commentary .vim/bundle/vim-commentary
  dotrelink vim-plugins/vim-unimpaired .vim/bundle/vim-unimpaired

  dotrelink aliases/essentials .aliases/essentials
  dotrelink aliases/auto .aliases/auto

  source .zshrc
)
