Last active
September 20, 2017 05:26
-
-
Save yagihiro/173169 to your computer and use it in GitHub Desktop.
.zshrc
This file contains 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
# ~/.zshrc | |
# completion --------------------------------------------------- | |
dir=~/.oh-my-zsh/custom/plugins/zsh-completions/src | |
if [ -e $dir ]; then | |
fpath=($dir $fpath) | |
plugins+=(zsh-completions) | |
autoload -U compinit && compinit | |
fi | |
zstyle ':completion:*' list-colors 'di=34' 'ln=35' 'so=32' 'ex=31' 'bd=46;34' 'cd=43;34' | |
setopt auto_cd | |
setopt auto_pushd | |
setopt correct | |
setopt list_packed | |
setopt noautoremoveslash | |
# prompt --------------------------------------------------- | |
PROMPT="[%~]%% " | |
RPROMPT="%m:%n%" | |
SPROMPT="correct: %R -> %r ? " | |
# keybind --------------------------------------------------- | |
bindkey -e | |
# history --------------------------------------------------- | |
export HISTIFILE=$HOME/.zsh_history | |
export HISTSIZE=10000 | |
export SAVEHIST=100000 | |
setopt hist_ignore_dups | |
setopt share_history | |
setopt EXTENDED_HISTORY | |
autoload history-search-end | |
zle -N history-beginning-search-backward-end history-search-end | |
zle -N history-beginning-search-forward-end history-search-end | |
bindkey "^P" history-beginning-search-backward-end | |
bindkey "^N" history-beginning-search-forward-end | |
# alias --------------------------------------------------- | |
export LS_COLORS='di=34;01:ln=35:so=32:pi=33:ex=31:bd=46;34:cd=43;34:su=41;30:sg=46;30:tw=42;30:ow=43;30' | |
case "${OSTYPE}" in | |
darwin*) | |
alias ls="ls -G" | |
alias la="ls -a" | |
alias ll="ls -la" | |
;; | |
linux*) | |
alias ls="ls --color" | |
alias la="ls -a" | |
alias ll="ls -la" | |
;; | |
esac | |
# env --------------------------------------------------- | |
PATH=$HOME/bin:$PATH | |
PATH=$HOME/r/go/bin:$PATH | |
PATH=/usr/local/opt/mysql@5.6/bin:$PATH | |
export PATH | |
# ------------ Golang ---------------------- | |
export GOPATH=$HOME/gopath | |
export PATH=$GOPATH/bin:$PATH | |
# git --------------------------------------------------- | |
autoload -Uz add-zsh-hook | |
setopt prompt_subst | |
alias g="git" | |
typeset -A emoji | |
emoji[ok]=$'\U2705' | |
emoji[error]=$'\U274C' | |
emoji[git]=$'\U1F500' | |
emoji[git_changed]=$'\U1F37A' | |
emoji[git_untracked]=$'\U1F363' | |
emoji[git_clean]=$'\U2728' | |
emoji[right_arrow]=$'\U2794' | |
function _vcs_git_indicator () { | |
typeset -A git_info | |
local git_indicator git_status | |
git_status=("${(f)$(git status --porcelain --branch 2> /dev/null)}") | |
(( $? == 0 )) && { | |
git_info[branch]="${${git_status[1]}#\#\# }" | |
shift git_status | |
git_info[changed]=${#git_status:#\?\?*} | |
git_info[untracked]=$(( $#git_status - ${git_info[changed]} )) | |
git_info[clean]=$(( $#git_status == 0 )) | |
git_indicator=("${emoji[git]} %{%F{blue}%}${git_info[branch]}%{%f%}") | |
(( ${git_info[clean]} )) && git_indicator+=("${emoji[git_clean]}") | |
(( ${git_info[changed]} )) && git_indicator+=("${emoji[git_changed]} %{%F{yellow}%}${git_info[changed]} changed%{%f%}") | |
(( ${git_info[untracked]} )) && git_indicator+=("${emoji[git_untracked]} %{%F{red}%}${git_info[untracked]} untracked%{%f%}") | |
} | |
_vcs_git_indicator="${git_indicator}" | |
} | |
add-zsh-hook precmd _vcs_git_indicator | |
function { | |
local dir='%{%F{blue}%B%}%~%{%b%f%}' | |
local now='%{%F{yellow}%}%D{%b %e %a %R %Z}%{%f%}' | |
local rc="%(?,${emoji[ok]} ,${emoji[error]} %{%F{red}%}%?%{%f%})" | |
local user='%{%F{green}%}%n%{%f%}' | |
local host='%{%F{green}%}%m%{%f%}' | |
[ "$SSH_CLIENT" ] && local via="${${=SSH_CLIENT}[1]} %{%B%}${emoji[right_arrow]}%{%b%} " | |
local git='$_vcs_git_indicator' | |
local mark=$'\n%# ' | |
PROMPT="$dir $user($via$host) $rc $git$mark" | |
RPROMPT="$now" | |
} | |
source "$GOPATH/src/github.com/sachaos/git-recent-branch/git-recent-branch_functions.sh" | |
export PATH=$PATH:$GOPATH/src/github.com/sachaos/git-recent-branch | |
# ------------ mysql ----------------------- | |
alias mysql_connections="lsof -i TCP:3306" | |
# ------------ python ---------------------- | |
export PATH=$PATH:$HOME/Library/Python/2.7/bin | |
# ------------ rust ------------------------ | |
export PATH=$PATH:$HOME/.cargo/bin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment