Skip to content

Instantly share code, notes, and snippets.

@handlename
Created May 29, 2015 10:42
Show Gist options
  • Save handlename/6f007f93a4284d47b5fe to your computer and use it in GitHub Desktop.
Save handlename/6f007f93a4284d47b5fe to your computer and use it in GitHub Desktop.
dot files
#set-option -g default-shell /usr/local/bin/zsh
set-option -g default-command "reattach-to-user-namespace -l /usr/local/bin/zsh"
## bindings
# prefix
unbind C-b
set-option -g prefix C-t
bind-key C-t send-prefix
# window
bind-key k kill-window
bind-key -r C-n next-window
bind-key -r C-h previous-window
bind-key C-t last-window
bind-key b split-window 'tmux lsw | peco | cut -d":" -f 1 | xargs tmux select-window -t'
# window and pane
bind-key 0 kill-pane
bind-key 1 break-pane
bind-key 2 split-window -v
bind-key 3 split-window -h
bind-key -r n select-pane -L
## display
# status
set-option -g status-fg black
set-option -g status-bg white
set-window-option -g window-status-bg white
set-window-option -g window-status-fg black
set-window-option -g window-status-current-bg black
set-window-option -g window-status-current-fg white
## misc
set-option -g history-limit 10000
bind-key -temacs-copy C-q copy-pipe "cat | ~/bin/nopaste-cli >> ~/.last_np; tmux split-window -p 1 'tail -n1 ~/.last_np | less'"
bind-key -temacs-copy C-w copy-pipe "cat | reattach-to-user-namespace pbcopy"
# Created by NAGATA Hiroaki for 4.3.10
# paths are in ~/.zshenv
# antigen
ANTIGEN_PATH=$GOPATH/src/github.com/zsh-users/antigen/antigen.zsh
if [[ -f $ANTIGEN_PATH ]]; then
source $ANTIGEN_PATH
antigen bundle zsh-users/zaw
antigen bundle zsh-users/zsh-syntax-highlighting
antigen bundle zsh-users/zsh-completions
antigen bundle rupa/z
antigen bundle mollifier/anyframe
antigen apply
fi
# extended auto complete
autoload -U compinit
compinit
zstyle ':completion:*' list-colors 'di=33' 'ln=35' 'so=32' 'ex=31' 'bd=46;33' 'cd=43;34'
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
# dir history
setopt auto_pushd
setopt pushd_ignore_dups
# candidates list format
setopt list_packed
# interactive correct
setopt correct
# set color for ls
export LSCOLORS=dxfxcxdxbxegedabagacad
export LS_COLORS='di=33:ln=35:so=32:pi=33:ex=31:bd=46;34:cd=43;33:su=41;30:sg=46;30:tw=42;30:ow=43;30'
# cdr
autoload -Uz chpwd_recent_dirs cdr add-zsh-hook
add-zsh-hook chpwd chpwd_recent_dirs
zstyle ':chpwd:*' recent-dirs-max 5000
zstyle ':chpwd:*' recent-dirs-default yes
zstyle ':completion:*' recent-dirs-insert both
# prompt
autoload -Uz vcs_info
zstyle ':vcs_info:*' formats '%s:%b'
zstyle ':vcs_info:*' actionformats '%s:%b[%a]'
function update_vcs_info_msg() {
psvar=()
LANG=en_US.UTF-8 vcs_info
[[ -n "$vcs_info_msg_0_" ]] && psvar[1]="$vcs_info_msg_0_"
}
add-zsh-hook precmd update_vcs_info_msg
if [ "${TERM}" != "dumb" ]; then
autoload colors
colors
PROMPT="%B%F{black}-- %D{%Y/%m/%d %H:%M:%S} --
%B%F{cyan}%m:%F{yellow}%/ %1(v|%{${fg[green]}%}%1v%f |)
%F{cyan}%F{red}%(!,#,$)%{${reset_color}%}%b "
PROMPT2="%{${fg[orange]}%}%_ %%%{${reset_color}%} "
SPROMPT="%{${fg[yellow]}%}%r%{${reset_color}%} is correct? [n, y, a, e]: "
fi
# mysql prompt
export MYSQL_PS1='mysql \d > '
# terminal title
case "${TERM}" in
kterm*|xterm|xterm-color)
precmd() {
echo -ne "\033]0;${USER}@${HOST%%.*}:${PWD}\007"
}
;;
esac
case "${TERM}" in
dumb | emacs)
PROMPT="%m:%~> "
unsetopt zle
;;
esac
# command history
HISTFILE=$HOME/.zsh_histories/.zsh_history
HISTSIZE=500000
SAVEHIST=500000
setopt hist_ignore_dups
setopt share_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
# git
export GIT_PS1_SHOWUPSTREAM=1
export GIT_PS1_SHOWUNTRACKEDFILES=1
export GIT_PS1_SHOWSTASHSTATE=1
export GIT_PS1_SHOWDIRTYSTATE=1
zstyle ':filter-select' case-insensitive yes
# zaw
bindkey '^xb' zaw-git-branches
bindkey '^xd' zaw-cdr
# anyframe
bindkey '^xg' anyframe-widget-cd-ghq-repository
bindkey '^xh' anyframe-widget-execute-history
bindkey '^xk' anyframe-widget-kill
function anyflame-widget-ggi() {
get-git-ignore \
| anyframe-selector-auto \
| awk '{print "get-git-ignore --lang="$1}' \
| anyframe-action-execute
}
alias ggi=anyflame-widget-ggi
# z
# https://github.com/rupa/z
function _z_add () {
z --add "$(pwd -P)"
}
add-zsh-hook chpwd _z_add
# for emacs
perl $HOME/.emacs.d/scripts/init_shellenv.pl
# alias
setopt complete_aliases
# ls
alias l="/usr/share/vim/vim73/macros/less.sh $1"
alias ls='ls -G'
alias la='ls -aG'
alias ll='ls -lhG'
alias lla='ls -lahG'
alias df='df -h'
alias du='du -h'
# ps
alias psg="ps aux | grep"
# rsync
alias rsync="rsync -P"
function replace-all() {
perl -p -i -e 's/'$1'/'$2'/g' $3
}
# git
eval "$(gh alias -s)"
alias g="hub"
# perl
alias pd="LANG=C perldoc"
alias pl="$GOPATH/src/github.com/kayac/nakamap/web/vendor/bin/carton exec perl -Ilib"
alias pv="prove -l"
alias pvv="./vendor/bin/carton exec prove -lv"
alias pvr="./vendor/bin/carton exec prove -lr"
alias ce="$GOPATH/src/github.com/kayac/nakamap/web/vendor/bin/carton exec"
# remove backup files
alias rmbak="find . -name '*~' -o -name '.#*' -o -name '#*#' | xargs rm -v"
# emacs
alias e='emacsclient -n'
# tmux
if [[ "$TMUX" != "" ]]; then
# http://unknownplace.org/memo/2012/03/27/1/
alias pbcopy="ssh 127.0.0.1 pbcopy"
alias pbpaste="ssh 127.0.0.1 pbpaste"
function s() {
tmux split-window -h "$*"
}
function t() {
name=$1
if test $name = "ssh" || test $name = "mosh"; then
name=$2
fi
tmux new-window -n $name "$*"
}
fi
setopt no_complete_aliases
# other
zmodload zsh/files
# melt
source ~/.zshrc.d/melt.zsh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment