Skip to content

Instantly share code, notes, and snippets.

@m-nakamura145

m-nakamura145/.zshrc

Created Jan 11, 2019
Embed
What would you like to do?
#
# Executes commands at the start of an interactive session.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Source Prezto.
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
fi
alias g=git
alias gb='(){git co -b $1}'
alias gd='(){git branch -D $1}'
alias gg='git gr'
alias gs='git status'
alias gm='git commit'
alias gl='git branch'
alias cb="git symbolic-ref --short HEAD|tr -d \"\\n\""
alias grep="grep --color -n -I --exclude='*.svn-*' --exclude='entries' --exclude='*/cache/*'"
bindkey -e
setopt auto_cd
setopt correct
setopt nobeep
setopt prompt_subst
setopt ignoreeof
setopt no_tify
setopt hist_ignore_dups
setopt correct
setopt extended_history
setopt hist_ignore_space
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_NO_FUNCTIONS
setopt HIST_NO_STORE
setopt HIST_REDUCE_BLANKS
setopt no_promptcr
setopt SHARE_HISTORY
setopt print_eight_bit
setopt interactive_comments
setopt magic_equal_subst
setopt auto_menu
setopt extended_glob
autoload -Uz is-at-least
#For zsh-completions
fpath=(/usr/local/share/zsh-completions $fpath)
autoload -U compinit; compinit -u
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
zstyle ':completion:*' ignore-parents parent pwd ..
zstyle ':completion:*:sudo:*' command-path /usr/local/sbin /usr/local/bin \
/usr/sbin /usr/bin /sbin /bin /usr/X11R6/bin
zstyle ':completion:*:processes' command 'ps x -o pid,s,args'
autoload -Uz vcs_info
alias tree="tree -NC"
function chpwd() { ls -1 }
# peco
function peco-select-history() {
BUFFER=$(history 1 | sort -k1,1nr | perl -ne 'BEGIN { my @lines = (); } s/^\s*\d+\*?\s*//; $in=$_; if (!(grep {$in eq $_} @lines)) { push(@lines, $in); print $in; }' | peco --query "$LBUFFER")
CURSOR=$#BUFFER
zle reset-prompt
}
zle -N peco-select-history
bindkey '^r' peco-select-history
function peco-z-search
{
which peco z > /dev/null
if [ $? -ne 0 ]; then
echo "Please install peco and z"
return 1
fi
local res=$(z | sort -rn | cut -c 12- | peco)
if [ -n "$res" ]; then
BUFFER+="cd $res"
zle accept-line
else
return 1
fi
}
zle -N peco-z-search
bindkey '^]' peco-z-search
function peco-git-checkout () {
local selected_branch=$(git branch --list --no-color | colrm 1 2 | peco)
if [ -n "$selected_branch" ]; then
BUFFER="git checkout ${selected_branch}"
zle accept-line
fi
}
zle -N peco-git-checkout
bindkey '^g' peco-git-checkout
# hub
eval "$(hub alias -s)"
function git(){hub "$@"}
alias see='git browse'
source ~/.zsh.d/z.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.