Created
September 16, 2014 15:34
-
-
Save t-kashima/1128489c5a73dadcec91 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
autoload -U compinit | |
compinit | |
zstyle ':completion:*:default' menu select=1 | |
# when tmux down | |
if [ "$TMUX" = "" ]; then | |
# tmux wake up!!! | |
tmux; | |
fi | |
source ~/.zsh_profile | |
# zsh history setting | |
HISTFILE=$HOME/.zsh-history | |
HISTSIZE=100000 | |
SAVEHIST=100000 | |
# zsh basic setting | |
export LANG=ja_JP.UTF-8 | |
setopt extended_history | |
setopt share_history | |
export PATH=$PATH:$HOME/bin:/usr/local/bin | |
# application setting | |
alias screenshot="ruby $HOME/bin/screenshot.rb" | |
alias emacs="/Applications/Emacs24.app/Contents/MacOS/Emacs" | |
alias ls='ls -G' | |
# mysql setting | |
export PATH=$PATH:/usr/local/mysql/bin | |
# perl setting | |
export PERL5LIB=$HOME/perl/lib/perl5:$HOME/perl/lib/perl5/site_perl:$HOME/perl/lib/perl5/darwin-2level | |
export PERL_CPANM_OPT="--local-lib=~/perl" | |
export PATH=$PATH:$HOME/perl/bin | |
# android setting | |
export ANDROID_NDK_HOME=$HOME/bin/android-ndk | |
export PATH=$PATH:${ANDROID_NDK_HOME} | |
export PATH=$PATH:/Library/Android/android-sdk/platform-tools | |
export PATH=$PATH:$HOME/bin/homebrew/bin:/Library/Android/android-sdk/bin | |
export NDK_ROOT=$ANDROID_NDK_HOME | |
export ANDROID_HOME=/Library/Android/android-sdk | |
export CFLAGS='-g -O0' | |
export CXXFLAGS=$CFLAGS | |
# rvm setting | |
PATH=$PATH:$HOME/.rvm/bin | |
if [[ -s $HOME/.rvm/scripts/rvm ]]; then | |
source $HOME/.rvm/scripts/rvm; | |
fi | |
# travis setting | |
[ -f $HOME/.travis/travis.sh ] && source $HOME/.travis/travis.sh | |
# cocos setting | |
export COCOS_CONSOLE_ROOT=$HOME/Develop/cocos2d-x-3.2/tools/cocos2d-console/bin | |
export PATH=$PATH:$COCOS_CONSOLE_ROOT | |
# go setting | |
export GOROOT=/usr/local/opt/go/libexec | |
export GOPATH=$HOME/go | |
export PATH=$PATH:$GOPATH/bin:$GOROOT/bin | |
# prompt setting | |
function branch-status-check { | |
local prefix branchname suffix | |
# .gitの中だから除外 | |
if [[ "$PWD" =~ '/\.git(/.*)?$' ]]; then | |
return | |
fi | |
branchname=`get-branch-name` | |
# ブランチ名が無いので除外 | |
if [[ -z $branchname ]]; then | |
return | |
fi | |
prefix=`get-branch-status` #色だけ返ってくる | |
suffix='%{'${reset_color}'%}' | |
echo ' on '${prefix}${branchname}${suffix}'' | |
} | |
function get-branch-name { | |
# gitディレクトリじゃない場合のエラーは捨てます | |
echo `git rev-parse --abbrev-ref HEAD 2> /dev/null` | |
} | |
function get-branch-status { | |
local res color | |
output=`git status --short 2> /dev/null` | |
if [ -z "$output" ]; then | |
res=':' # status Clean | |
color='%{'${fg[green]}'%}' | |
elif [[ $output =~ "[\n]?\?\? " ]]; then | |
res='?:' # Untracked | |
color='%{'${fg[yellow]}'%}' | |
elif [[ $output =~ "[\n]? M " ]]; then | |
res='M:' # Modified | |
color='%{'${fg[red]}'%}' | |
else | |
res='A:' # Added to commit | |
color='%{'${fg[cyan]}'%}' | |
fi | |
# echo ${color}${res}'%{'${reset_color}'%}' | |
echo ${color} # 色だけ返す | |
} | |
function get-current-path { | |
color='%{'${fg[yellow]}'%}' | |
echo ${color}'%~''%{'${reset_color}'%}' | |
} | |
setopt prompt_subst | |
export prompt='%n:`get-current-path``branch-status-check`% → ' | |
# peco search history | |
function peco-select-history() { | |
local tac | |
if which tac > /dev/null; then | |
tac="tac" | |
else | |
tac="tail -r" | |
fi | |
BUFFER=$(\history -n 1 | \ | |
eval $tac | \ | |
peco --query "$LBUFFER") | |
CURSOR=$#BUFFER | |
zle clear-screen | |
} | |
zle -N peco-select-history | |
bindkey "^r" peco-select-history | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment