guneysus
1/13/2015 - 11:52 PM

Custom zshrc for displaying icons hg/git repos and Dropbox folder

Custom zshrc for displaying icons hg/git repos and Dropbox folder

# Lines configured by zsh-newuser-install
HISTFILE=~/.history_zsh
HISTSIZE=10000
SAVEHIST=1000
setopt appendhistory autocd beep extendedglob nomatch notify
bindkey -v # vi keys
autoload -Uz compinit
compinit
# End of lines added by compinstall

function greet() { echo -e Bismillah }
function _exit()    # function to run upon exit of shell
{
    echo -e "Hasta la vista, baby"
}
trap _exit EXIT
greet

alias py_check='python -m py_compile'
alias tmux='tmux -2'
export BROWSER=chromium-browser

function prompt_char {
    # echo $( [ -f .dropbox ]  && echo -e "%{$fg_no_bold[blue]%}\uf16b%{$reset_color%}") && return
    cat .dropbox >/dev/null 2>/dev/null && echo -e "%{$fg_no_bold[blue]%}\uf16b%{$reset_color%}" && return
    git branch >/dev/null 2>/dev/null && echo -e "%{$fg_no_bold[yellow]%}\uf17c%{$reset_color%}" && return
    hg root >/dev/null 2>/dev/null && echo -e "%{$fg_no_bold[blue]%}\uf171%{$reset_color%}"  && return
    echo '○'
}

# with the help of
# https://github.com/robbyrussell/oh-my-zsh/blob/master/themes/fishy.zsh-theme
_fishy_collapsed_wd() {
  echo $(pwd | perl -pe "
   BEGIN {
      binmode STDIN,  ':encoding(UTF-8)';
      binmode STDOUT, ':encoding(UTF-8)';
   }; s|^$HOME|~|g; s|/([^/])[^/]*(?=/)|/\$1|g") | \
    sed -re "s/\//\xe3\x80\x89/g" # \u3009
    # sed -re "s/\//\xee\x82\xb1/g" # \ue0b1 
    # sed -re "s/\//\xe2\x9d\xad/g" # \u276d ❭
    # sed -re "s/\//\xe2\x9d\xaf/g" # \u276f ❯
    # sed -re "s/\//\xe2\x9d\xb1/g" # \u2771 ❱
}

# You must intall hg prompt from
# http://sjl.bitbucket.org/hg-prompt/

hg_prompt() {
    hg prompt "(%{$fg_bold[magenta]%}{{branch}}%{$reset_color%}{@{bookmark}}|%{$fg_bold[green]%}{-->[+{outgoing|count}]}{status}%{$reset_color%})" 2> /dev/null
}


local user_color='green'; [ $UID -eq 0 ] && user_color='red'
PROMPT='$(echo -e "\u0000")%{$fg[$user_color]%}$(_fishy_collapsed_wd)%{$reset_color%}%(!.#. $(echo -e "\u2502"))'

PROMPT2='%{$fg[red]%}\ %{$reset_color%}'

local return_status="%{$fg_bold[red]%}%(?..%?)%{$reset_color%}"
RPROMPT='$(hg_prompt)$(git_super_status)${return_status}%{$reset_color%}$(prompt_char)'

alias lsabs='find `pwd` -name'