local black=$'%{\e[0;30m%}'
local BLACK=$'%{\e[1;30m%}'
local red=$'%{\e[0;31m%}'
local RED=$'%{\e[1;31m%}'
local green=$'%{\e[0;32m%}'
local GREEN=$'%{\e[1;32m%}'
local yellow=$'%{\e[0;33m%}'
local YELLOW=$'%{\e[1;33m%}'
local blue=$'%{\e[0;34m%}'
local BLUE=$'%{\e[1;34m%}'
local purple=$'%{\e[0;35m%}'
local PURPLE=$'%{\e[1;35m%}'
local cyan=$'%{\e[0;36m%}'
local CYAN=$'%{\e[1;36m%}'
local WHITE=$'%{\e[1;37m%}'
local white=$'%{\e[0;37m%}'
local NC=$'%{\e[0m%}' # no color
bindkey "^[[2~" yank # Insert
bindkey "^[[3~" delete-char # Del
bindkey "^[[5~" up-line-or-history # PageUp
bindkey "^[[6~" down-line-or-history # PageDown
bindkey "^e" expand-cmd-path # C-e for expanding path of typed command.
bindkey "^r" history-incremental-search-backward
bindkey "^[[A" up-line-or-search # Up arrow for back-history-search.
bindkey "^[[B" down-line-or-search # Down arrow for fwd-history-search.
bindkey " " magic-space # Do history expansion on space.
bindkey "^[[H" beginning-of-line # Pos1
bindkey "^[[F" end-of-line # End
bindkey "\e[1~" beginning-of-line
bindkey "\e[4~" end-of-line
case "$TERM" in
linux|screen|screen.linux)
bindkey "^[[1~" beginning-of-line # Pos1
bindkey "^[[4~" end-of-line # End
;;
*xterm*|(dt|k)term|xterm-color)
bindkey "^[[H" beginning-of-line # Pos1
bindkey "^[[F" end-of-line # End
bindkey "^[[7~" beginning-of-line # Pos1
bindkey "^[[8~" end-of-line # End
;;
rxvt|Eterm|rxvt-unicode)
bindkey "^[[7~" beginning-of-line # Pos1
bindkey "^[[8~" end-of-line # End
;;
esac
export LC_ALL="en_US.UTF-8"
setopt nobeep # i hate beeps
#setopt noautomenu # don't cycle completions
setopt autocd # change to dirs without cd
setopt autopushd # automatically append dirs to the push/pop list
setopt pushdignoredups # and don't duplicate them
setopt cdablevars # avoid the need for an explicit $
setopt checkjobs # warn me about bg processes when exiting
setopt nohup # and don't kill them, either
setopt listpacked # compact completion lists
setopt listtypes # show types in completion
setopt completeinword # not just at the end
setopt alwaystoend # when complete from middle, move cursor
setopt correct # spelling correction
setopt nopromptcr # dont add \r which overwrites cmd output with no \n
setopt histverify # when using ! cmds, confirm first
setopt interactivecomments # escape commands so i can use them later
#setopt recexact # recognise exact, ambiguous matches
setopt printexitvalue # alert me if something's failed
setopt glob # globbing support
setopt extendedglob # blah blah
setopt nonomatch # pass through any unrecognized patterns to the command
#setopt menucomplete # auto insert first match
setopt extendedglob
setopt inc_appendhistory
setopt hist_ignore_space
setopt hist_ignore_all_dups
HISTFILE=~/.history
HISTSIZE=4000
SAVEHIST=$HISTSIZE
# Completition
compctl -b bindkey
compctl -v export
compctl -o setopt
compctl -v unset
compctl -o unsetopt
compctl -v vared
compctl -c which
compctl -c sudo
WORDCHARS="*"
compctl -f -x 'S[1][2][3][4][5][6][7][8][9]' -k '(1 2 3 4 5 6 7 8 9)' \
- 'R[[1-9nlo]|[1-9](|[a-z]),^*]' -K 'match-man' \
- 's[-M],c[-1,-M]' -g '*(-/)' \
- 's[-P],c[-1,-P]' -c \
- 's[-S],s[-1,-S]' -k '( )' \
- 's[-]' -k '(a d f h k t M P)' \
- 'p[1,-1]' -c + -K 'match-man' \
-- man
zstyle ':completion:*:(all-|)files' ignored-patterns '(|*/)CVS'
zstyle ':completion:*:cd:*' ignored-patterns '(*/)#CVS'
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
autoload colors && colors
LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.svgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01'
export LS_COLORS
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*:processes' command 'ps -o "pid comm" -u `whoami`'
zstyle ':completion:*:processes' sort false
zstyle ':completion:*:*:kill:*:processes' list-colors "=(#b) #([0-9]#)*=$color[cyan]=$color[red]"
autoload -U compinit
compinit
alias screen='screen -U'
#RPROMPT="%(?,%{$GREEN%}OK%{$NC%},%{$RED%}FAIL%{$NC%}) | `date +"%H:%M:%S %d.%m.%Y"`"
if [ `whoami` == "root" ]
then
PROMPT="$RED%m:$BLUE%~# $NC"
else
if [ "$(uname -s)" = "Darwin" ]
then
PROMPT="$GREEN%n@%m:$BLUE%~$ $NC"
else
COLORS="3 4 5 6 7 8 11 12 13 14 15 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 36 37 38 39 40 41 42 43 44 45 48 49 50 51 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 84 85 86 87 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 114 115 116 117 121 122 123 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228"
id=$(($(echo $HOST | cksum | cut -d' ' -f1) % $(echo $COLORS | wc -w) + 1))
color_n=$(echo "$COLORS" | awk "{print \$$id}")
color=$'%{\e[38;5;${color_n}m%}'
PROMPT="$color%n@%m:$BLUE%~$ $NC"
fi
fi
setopt prompt_subst
autoload -Uz vcs_info
zstyle ':vcs_info:*' actionformats \
'%F{2}%s[%F{4}%b:%a%F{2}]%f'
zstyle ':vcs_info:*' formats \
'%F{2}%s[%F{4}%b%F{2}]%f'
zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%F{2}[%F{4}%b%F{2}:%F{4}%r%F{2}]%f'
zstyle ':vcs_info:*' enable git cvs svn
# or use pre_cmd, see man zshcontrib
vcs_info_wrapper() {
vcs_info
if [ -n "$vcs_info_msg_0_" ]; then
echo "%{$fg[grey]%}${vcs_info_msg_0_}%{$reset_color%}$del"
fi
}
RPROMPT=$'$(vcs_info_wrapper)'
PATH="/usr/local/bin:/usr/local/sbin:${HOME}/bin:/opt/cmake/bin:$PATH"
alias ls='ls -G'
function m()
{
threads=0
echo $@ | grep '\-j' >/dev/null && threads=1
if [ $threads -eq 1 ]
then
make $@
else
make -j$(get_thread_count) $@
fi
code=$?
if [ $(uname -s) == "Darwin" ]
then
afplay /System/Library/Sounds/Tink.aiff
else
echo '\a'
fi
return $code
}
function cd()
{
if [ -z $1 ]
then
chdir "$HOME"
return
elif [ -f $1 ]
then
chdir $(dirname $1) > /dev/null
else
chdir $@ > /dev/null
fi
}
if [ "$(uname -s)" == "Darwin" ]
then
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home
function add()
{
brew install $@
rehash
}
alias ls='ls -G'
alias del='brew uninstall'
alias ss='brew search'
alias dmesg='sudo dmesg'
alias vi='~/bin/mvim -v'
alias vim='~/bin/mvim -v'
alias mvim='~/bin/mvim --remote-tab-silent'
alias netstat='lsof -i -P -n'
alias locate='mdfind -name'
alias svim='sudo -E ~/bin/mvim -v'
function dud
{
echo "Calculating file sizes..."
du -d 0 . * | sort -n | awk '{ split( "K M G" , v ); s=1; while( $1>1024 ){ $1/=1024; s++ } print int($1) v[s] "\t" $2 }'
}
export LESSOPEN="| /usr/local/opt/source-highlight/bin/src-hilite-lesspipe.sh %s"
else
alias ls='ls --color=auto'
alias svim='sudo -E vim'
export LESSOPEN="| /usr/share/source-highlight/src-hilite-lesspipe.sh %s"
if [ "$(cat /etc/issue | head -n 1| awk '{print $1}')" = "CentOS" ]
then
function add()
{
sudo yum install $@
rehash
}
alias del='sudo yum remove'
alias ss='sudo yum search'
else
function add()
{
sudo aptitude install $@
rehash
}
alias del='sudo aptitude remove'
alias ss='sudo aptitude search'
fi
fi
export LESS='-R -n'
export EDITOR="vim"
alias s='sudo su'
alias dc='cd'
alias grep="grep -I"
alias ....='cd ../..'
alias ...='cd ../..'
unar () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via >extract<" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
export LESS_TERMCAP_mb=$'\E[01;31m'
export LESS_TERMCAP_md=$'\E[01;31m'
export LESS_TERMCAP_me=$'\E[0m'
export LESS_TERMCAP_se=$'\E[0m'
export LESS_TERMCAP_so=$'\E[01;44;33m'
export LESS_TERMCAP_ue=$'\E[0m'
export LESS_TERMCAP_us=$'\E[01;32m'
which rbenv >/dev/null 2>/dev/null && eval "$(rbenv init -)"
function cdp
{
path="."
i=0
while [ $i -lt 50 ]
do
if [ -d ${path}/.git ]
then
cd $path/product
return
else
i=$((i+1))
path=${path}/..
fi
done
echo "No git repo found"
}
export GOPATH=$HOME/.go
export PATH="${HOME}/avr/binaries/bin:${PATH}"
export GCC_COLORS=1