#!/bin/zsh # # Darwin or Linux OSNAME=`uname` # For Emacs Tramp mode [[ $TERM == "dumb" ]] && unsetopt zle && PS1='$ ' && return autoload colors colors for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do eval _$color='%{$terminfo[bold]$fg[${(L)color}]%}' eval $color='%{$fg[${(L)color}]%}' (( count = $count + 1 )) done # right prompt #RPROMPT=$(echo "$RED%D %T$FINISH") #PROMPT=$(echo "$CYAN%n[$BLUE%~]$_YELLOW>>$FINISH ") PROMPT=$(echo "%B$CYAN%n$_YELLOW@$BLUE%<<[%~%<<]$_YELLOW>> $WHITE%b") export HISTSIZE=10000 export SAVEHIST=10000 export HISTFILE="$HOME/.zsh_history" setopt INC_APPEND_HISTORY setopt HIST_IGNORE_DUPS setopt EXTENDED_HISTORY setopt AUTO_PUSHD setopt HIST_IGNORE_SPACE export CLICOLOR=1 export LSCOLORS=ExFxCxDxBxegedabagaced man() { env \ GROFF_NO_SGR=$(printf "1") \ LESS_TERMCAP_mb=$(printf "\e[1;31m") \ LESS_TERMCAP_md=$(printf "\e[1;31m") \ LESS_TERMCAP_me=$(printf "\e[0m") \ LESS_TERMCAP_se=$(printf "\e[0m") \ LESS_TERMCAP_so=$(printf "\e[1;44;33m") \ LESS_TERMCAP_ue=$(printf "\e[0m") \ LESS_TERMCAP_us=$(printf "\e[1;32m") \ man "$@" } LS_COLORS="rs=0:di=01;34:ln=01;36:mh=00: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:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:" #export LS_COLORS ###==================== # #autoload -U compinit #compinit #zstyle ':completion:*:descriptions' format '%U%B%d%b%u' #zstyle ':completion:*:warnings' format '%BSorry, no matches for: %d%b' # # # # Use modern completion system autoload -Uz compinit compinit zstyle ':completion:*' auto-description 'specify: %d' zstyle ':completion:*' completer _expand _complete _correct _approximate #zstyle ':completion:*' format 'Completing %d' zstyle ':completion:*' group-name '' zstyle ':completion:*' menu select=2 #eval "$(dircolors -b)" zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} 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:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*' zstyle ':completion:*' menu select=long zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s zstyle ':completion:*' use-compctl false zstyle ':completion:*' verbose true zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31' zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd' ######################## zsh alias ######################### alias grep='grep --color -E' #alias mvim='mvim --remote-silent' #alias vim='/usr/local/bin/mvim -v' alias tmux='tmux -2' if [[ $OSNAME == 'Darwin' ]]; then alias l='ls -l' alias ll='ls -l' alias la='ls -a' elif [[ $OSNAME == 'Linux' ]]; then alias l='ls -l --color=auto' alias ll='ls -l --color=auto' alias la='ls -a --color=auto' alias ls='ls --color=auto' fi alias diff='colordiff' alias mv='mv -i' alias cp='cp -i' alias ln='ln -i' #alias svn='colorsvn' alias sed='/usr/local/bin/gsed' ##### Git alias 'gs'='git status' alias 'ga'='git add' alias 'gc'='git commit' alias 'gl'='git log --oneline --graph --all --color --decorate --abbrev-commit' alias 'git-log'='git log --oneline --graph --all --color --decorate --abbrev-commit' alias 'gdiff'='git diff' alias 'gpush'='git push origin master' ########################### zsh completion ########################## # #autoload -U compinit #compinit #zstyle ':completion:*:descriptions' format '%U%B%d%b%u' #zstyle ':completion:*:warnings' format '%BSorry, no matches for: %d%b' # #autoload -U compinit #compinit # #autoload -U promptinit #promptinit # #setopt correctall # # zstyle ':completion:*' menu select setopt AUTOLIST setopt AUTOMENU autoload -U compinit compinit WORDCHARS='*?_-[]~=&;!#$%^(){}<>' ################ # #http://techanic.net/2012/12/30/my_git_prompt_for_zsh.html # Adapted from code found at . setopt prompt_subst autoload -U colors && colors # Enable colors in prompt # Modify the colors and symbols in these variables as desired. GIT_PROMPT_SYMBOL="%{$fg[blue]%}±" GIT_PROMPT_PREFIX="%{$fg[green]%}[%{$reset_color%}" GIT_PROMPT_SUFFIX="%{$fg[green]%}]%{$reset_color%}" GIT_PROMPT_AHEAD="%{$fg[red]%}ANUM%{$reset_color%}" GIT_PROMPT_BEHIND="%{$fg[cyan]%}BNUM%{$reset_color%}" GIT_PROMPT_MERGING="%{$fg_bold[magenta]%}⚡︎%{$reset_color%}" GIT_PROMPT_UNTRACKED="%{$fg_bold[red]%}•%{$reset_color%}" GIT_PROMPT_MODIFIED="%{$fg_bold[yellow]%}•%{$reset_color%}" GIT_PROMPT_STAGED="%{$fg_bold[green]%}•%{$reset_color%}" # Show Git branch/tag, or name-rev if on detached head parse_git_branch() { (git symbolic-ref -q HEAD || git name-rev --name-only --no-undefined --always HEAD) 2> /dev/null } # Show different symbols as appropriate for various Git repository states parse_git_state() { # Compose this value via multiple conditional appends. local GIT_STATE="" local NUM_AHEAD="$(git log --oneline @{u}.. 2> /dev/null | wc -l | tr -d ' ')" if [ "$NUM_AHEAD" -gt 0 ]; then GIT_STATE=$GIT_STATE${GIT_PROMPT_AHEAD//NUM/$NUM_AHEAD} fi local NUM_BEHIND="$(git log --oneline ..@{u} 2> /dev/null | wc -l | tr -d ' ')" if [ "$NUM_BEHIND" -gt 0 ]; then GIT_STATE=$GIT_STATE${GIT_PROMPT_BEHIND//NUM/$NUM_BEHIND} fi local GIT_DIR="$(git rev-parse --git-dir 2> /dev/null)" if [ -n $GIT_DIR ] && test -r $GIT_DIR/MERGE_HEAD; then GIT_STATE=$GIT_STATE$GIT_PROMPT_MERGING fi if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then GIT_STATE=$GIT_STATE$GIT_PROMPT_UNTRACKED fi if ! git diff --quiet 2> /dev/null; then GIT_STATE=$GIT_STATE$GIT_PROMPT_MODIFIED fi if ! git diff --cached --quiet 2> /dev/null; then GIT_STATE=$GIT_STATE$GIT_PROMPT_STAGED fi if [[ -n $GIT_STATE ]]; then echo "$GIT_PROMPT_PREFIX$GIT_STATE$GIT_PROMPT_SUFFIX" fi } # If inside a Git repository, print its branch and state git_prompt_string() { local git_where="$(parse_git_branch)" [ -n "$git_where" ] && echo "$GIT_PROMPT_SYMBOL$(parse_git_state)$GIT_PROMPT_PREFIX%{$fg[yellow]%}${git_where#(refs/heads/|tags/)}$GIT_PROMPT_SUFFIX" } # Set the right-hand prompt RPS1='$(git_prompt_string)' #source ~/Private/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh # [[ -f "~/.zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ]] && source ~/.zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh # http://stackoverflow.com/questions/3483604/which-shortcut-in-zsh-does-the-same-as-ctrl-u-in-bash bindkey \^U backward-kill-line export ZSHHOME="$HOME/.zsh" [[ -f "$ZSHHOME/cpverc" ]] && . "$ZSHHOME/cpverc" [[ -f "$ZSHHOME/eccrc" ]] && . "$ZSHHOME/eccrc" #` git log --oneline --abbrev-commit --all --graph --decorate --color ` `which brew` &> /dev/null if [ $? -eq 0 ]; then [[ -s `brew --prefix`/etc/autojump.sh ]] && . `brew --prefix`/etc/autojump.sh fi alias emacs='TERM=xterm-256color emacs -nw' alias tw='open -a /Applications/TextWrangler.app/' # #function exists { which $1 &> /dev/null } # #if exists percol; then # function percol_select_history() { # local tac # exists gtac && tac="gtac" || { exists tac && tac="tac" || { tac="tail -r" } } # BUFFER=$(fc -l -n 1 | eval $tac | percol --query "$LBUFFER") # CURSOR=$#BUFFER # move cursor # zle -R -c # refresh # } # # zle -N percol_select_history # bindkey '^R' percol_select_history #fi export LANG='en_US.UTF-8' export LC_ALL="en_US.UTF-8" lftp-cp() { server='cmbu-ftp.cisco.com' user='cmbu' pass='cisco123!@#' home='/FTPServer/users/peli3' dir=`date +%m%d` localfile=$1; remotefile=${home}/${dir}/$2; echo "copy ${localfile} to ftp://${server}${remotefile}" lftp -e "mkdir ${home}/${dir}; put ${localfile} -o ${remotefile}; bye" -u $user,$pass $server } merge_logs() { ls -rl jabber.log* | awk '{print $9}' | Xargs cat >> full.log } export MANPATH=$MANPATH:/usr/local/man ## vim YouCompleteMe # https://github.com/Valloric/YouCompleteMe/issues/18 #export DYLD_FORCE_FLAT_NAMESPACE=1 export MANPATH=$MANPATH:${HOME}/perl5/man export PATH=$PATH:"${HOME}/scripts" ## hunspell path export DICPATH="/usr/local/share/hunspell/" if [[ $OSNAME == 'Darwin' ]]; then export PYTHONSTARTUP="$HOME/.pythonrc" export PYTHONPATH="/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/" export DEV_ENV_ROOT=$HOME/android/ export ANDROID_NDK_ROOT="${DEV_ENV_ROOT}/android-ndk-r10d/" export ANDROID_SDK_ROOT="${DEV_ENV_ROOT}/android-sdk-macosx/" #export ANDROID_TOOLCHAIN="${DEV_ENV_ROOT}/standalone-toolchain-api14/" export ANDROID_NDK_HOME="$HOME/android/android-ndk-r10d" export ANDROID_TOOLCHAIN="$ANDROID_NDK_HOME/standalone-toolchain-api14/" export ANDROID_HOME="$HOME/android/android-sdk-macosx/" export PATH=$PATH:"${ANDROID_TOOLCHAIN}/bin/":"${ANDROID_HOME}/platform-tools/" export PATH="$HOME/bin":"/usr/local/bin":$PATH ## appended by cpan initializaion PATH="$HOME/perl5/bin${PATH:+:${PATH}}"; export PATH; PERL5LIB="$HOME/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB; PERL_LOCAL_LIB_ROOT="$HOME/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT; PERL_MB_OPT="--install_base \"$HOME/perl5\""; export PERL_MB_OPT; PERL_MM_OPT="INSTALL_BASE=$HOME/perl5"; export PERL_MM_OPT; fi # add Racket into PATH export PATH="/Applications/Racket v6.6/bin":$PATH; export MANPATH="/Applications/Racket v6.6/man":$MANPATH; # export ~/.bin into PATH export PATH="$HOME/.bin":$PATH;