Commits

Anonymous committed 8bbfc9b

zshrc

  • Participants
  • Parent commits 658558c

Comments (0)

Files changed (1)

snippets/dot.zshrc

-
 # Lines configured by zsh-newuser-install
 umask 022
 
 setopt list_packed
 
 export LANG=ja_JP.UTF-8
-export PATH=/opt/local/bin:/opt/local/sbin:$PATH
-export MANPATH=/opt/local/man:$MANPATH
 export EDITOR=emacs
 export OUTPUT_CHARSET=UTF-8
 bindkey -e
 local BLUE=$'%{\e[1;34m%}'
 local DEFAULT=$'%{\e[1;m%}'
 
+autoload -U colors; colors
+
+function rprompt-git-current-branch {
+        local name st color
+
+        if [[ "$PWD" =~ '/\.git(/.*)?$' ]]; then
+                return
+        fi
+        name=$(basename "`git symbolic-ref HEAD 2> /dev/null`")
+        if [[ -z $name ]]; then
+                return
+        fi
+        st=`git status 2> /dev/null`
+        if [[ -n `echo "$st" | grep "^nothing to"` ]]; then
+                color=${fg[green]}
+        elif [[ -n `echo "$st" | grep "^nothing added"` ]]; then
+                color=${fg[yellow]}
+        elif [[ -n `echo "$st" | grep "^# Untracked"` ]]; then
+                color=${fg_bold[red]}
+        else
+                color=${fg[red]}
+        fi
+
+        # %{...%} は囲まれた文字列がエスケープシーケンスであることを明示する
+        # これをしないと右プロンプトの位置がずれる
+        echo "%{$color%}$name%{$reset_color%} "
+}
+
+# プロンプトが表示されるたびにプロンプト文字列を評価、置換する
+setopt prompt_subst
+
+RPROMPT='[`rprompt-git-current-branch`%~]'
+
 export HOSTNAME=`hostname`
-export PROMPT=$BLUE'> %(!.#.$) '$DEFAULT
-export RPROMPT=$GREEN'[${USER}@${HOSTNAME}:%~]'$DEFAULT
+export PROMPT=$BLUE'${USER}@${HOSTNAME}> %(!.#.$) '$DEFAULT
+#export RPROMPT=$GREEN'[${USER}@${HOSTNAME}:%~]'$DEFAULT
 setopt PROMPT_SUBST
 setopt NO_BEEP
 setopt AUTOLIST
 
-OUTPUTZ_KEY=c3hOxeU9q.Se
-OUTPUTZ_API_URL=http://outputz.com/api/post
-
-preexec() {
-#    SIZE=`echo $argv[1] | wc -c | tr -d ' '`
-#    URI=http://www.zsh.org/`echo ${argv[1]} | sed "s/ /_/g"`
-#    POST_DATA="key=${OUTPUTZ_KEY}&uri=${URI}&size=${SIZE}"
-#    CONTENT_TYPE="Content-Type: application/x-www-form-urlencoded"
-#    wget -O - --header "$CONTENT_TYPE" --post-data="$POST_DATA" "$OUTPUTZ_API_URL" >& /dev/null
-}
-
-
 #http://0xcc.net/blog/archives/cat_7.html
 #case "$TERM" in
 #    xterm*|kterm*|rxvt*)
 #    PROMPT='%m:%c%# '
 #    ;;
 #esac
+
+export PATH=$PATH:~/.cabal/bin:/usr/local/depot_tools
+export LD_LIBRARY_PATH=/usr/local/lib
+export CXX='ccache g++'
+export CC='ccache gcc'