Skip to content

Instantly share code, notes, and snippets.

@upamune
Created May 2, 2015 14:09
Show Gist options
  • Save upamune/d0c71c031203f02926ce to your computer and use it in GitHub Desktop.
Save upamune/d0c71c031203f02926ce to your computer and use it in GitHub Desktop.
############################################
# _______| |__ _ __ ___ | |__ _ _ #
# |_ / __| '_ \| '__/ __| | '_ \| | | |#
# _ / /\__ \ | | | | | (__ | |_) | |_| |#
#(_) /___|___/_| |_|_| \___| |_.__/ \__, |#
# |___/ #
# _ _ _ #
# (_) __ _ (_) | _____ __ _ ___ ___ #
# | |/ _` || | |/ / _ \/ _` |/ _ \/ __| #
# | | (_| || | < __/ (_| | (_) \__ \ #
# _/ |\__,_|/ |_|\_\___|\__, |\___/|___/ #
#|__/ |__/ |_| #
############################################
# 環境変数
export LANG=ja_JP.UTF-8
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
#git 補完できるように
fpath=(~/.zsh/complention $fpath)
# 色を使用出来るようにする
autoload -Uz colors
colors
# 補完機能を有効にする
autoload -Uz compinit
compinit
# 補完時に大文字と小文字を区別しない
zstyle ':complention:*' matcher-list 'm:{a-z}={A-Z}'
# C-w の挙動を変える(細かく消す)
autoload -Uz select-word-style
select-word-style default
zstyle ':zle:*' word-chars " /=;@:{},|"
zstyle ':zle:*' word-style unspecified
# Emacs 風キーバインドにする
bindkey -e
# ヒストリの設定
HISTFILE=~/.zsh_history
HISTSIZE=1000000
SAVEHIST=1000000
HIST_STAMPS="mm/dd/yyyy"
# ヒストリに保存するときに余分なスペースを削除する
setopt hist_reduce_blanks
# 同時に起動したzshの間でヒストリを共有する
setopt share_history
# 同じコマンドをヒストリに残さない
setopt hist_ignore_all_dups
# 履歴をインクリメンタルサーチできるようにする
bindkey '^r' history-incremental-pattern-search-backward
bindkey '^s' history-incremental-pattern-search-forward
# '#' 以降をコメントとして扱う
setopt interactive_comments
# ディレクトリ名だけでcdできるようにする
setopt AUTO_CD
# 最近移動したディレクトリに移動できるようにする
autoload -Uz add-zsh-hook
autoload -Uz chpwd_recent_dirs cdr
add-zsh-hook chpwd chpwd_recent_dirs
# Ctrl-Dでzshを終了しない
setopt IGNORE_EOF
# Ctrl-Q/Ctrl-Sのフローコントロールを無効にする
setopt NO_FLOW_CONTROL
# beep音を無効にする
setopt NO_BEEP
# エイリアス
alias l='ls --color=auto'
alias ls='ls --color=auto'
alias la='ls -a'
alias ll='ls -l'
alias cp='cp -i'
alias mv='mv -i'
alias mkdir='mkdir -p'
alias hist='history'
alias vimconfig='vim ~/.vimrc'
alias zshconfig='vim ~/.zshrc'
alias -g L='| less'
alias -g G='| grep'
#OS 別設定
case ${OSTYPE} in
# For MacOS
darwin*)
echo hi
# rmtrashが存在したらrmをrmtrashにエイリアスする
if which rmtrash > /dev/null 2>&1 ; then
alias -g rm='rmtrash'
fi
# Cでクリップボードにコピーできるようにする
if which pbcopy > /dev/null 2>&1 ; then
alias -g C='| pbcopy'
fi
;;
# For Linux
linux*)
# fcitxが存在したら環境変数を設定する
if which fcitx > /dev/null 2>&1 ; then
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS=”@im=fcitx”
fi
# xselが存在したらCでクリップボードにコピーできるようにする
if which xsel > /dev/null 2>&1 ; then
alias -g C='| xsel --input --clipboard'
fi
# HOME直下に.nvmが存在したら環境変数を設定する
if [ -d $HOME/.nvm ] ; then
source /usr/share/nvm/init-nvm.sh
fi
# nvmが存在したらnvmのinitとnodeのバージョンを指定する
if which nvm > /dev/null 2>&1 ; then
nvm use v0.10.38 > /dev/null
export PATH=$HOME/.nvm/v0.10.38/bin:$PATH
fi
;;
esac
########################################
# _ _ _ #
# / \ _ __ | |_(_) __ _ ___ _ __ #
# / _ \ | '_ \| __| |/ _` |/ _ \ '_ \ #
# / ___ \| | | | |_| | (_| | __/ | | |#
#/_/ \_\_| |_|\__|_|\__, |\___|_| |_|#
# |___/ #
########################################
if [[ -f $HOME/.zsh/antigen/antigen.zsh ]]; then
source $HOME/.zsh/antigen/antigen.zsh
antigen use oh-my-zsh
antigen bundle zsh-users/zsh-completions src
antigen bundle zsh-users/zsh-syntax-highlighting
antigen bundle mollifier/anyframe
antigen bundle m4i/cdd
antigen theme amuse
antigen apply
# zsh-completions の設定
fpath=($HOME/.zsh/zsh-completions/src(N-/) $fpath)
# anyframe の設定
# Ctrl-Pでコマンドを挿入できるようにする
function peco-put-history() {
builtin history -n -r 1 \
| anyframe-selector-auto "$LBUFFER" \
| anyframe-action-put
}
zle -N peco-put-history
bindkey '^x^p' peco-put-history
# Ctrl-xwでtmuxのウィンドウを切り替えられるようにする
function peco-tmux() {
local i=$(tmux lsw | awk '/active.$/ {print NR-1}')
local f='#{window_index}: #{window_name}#{window_flags} #{pane_current_path}'
tmux lsw -F "$f" \
| anyframe-selector-auto "" --initial-index $i \
| cut -d ':' -f 1 \
| anyframe-action-execute tmux select-window -t
}
zle -N peco-tmux
bindkey '^xw' peco-tmux
# cdd の設定
if [[ -f $HOME/.antigen/repos/https-COLON--SLASH--SLASH-github.com-SLASH-m4i-SLASH-cdd.git/cdd ]]; then
source $HOME/.antigen/repos/https-COLON--SLASH--SLASH-github.com-SLASH-m4i-SLASH-cdd.git/cdd
touch $CDD_FILE
autoload -Uz add-zsh-hook
add-zsh-hook chpwd _cdd_chpwd
fi
fi
############################
#| |_ _ __ ___ _ ___ #
#| __| '_ ` _ \| | | \ \/ /#
#| |_| | | | | | |_| |> < #
# \__|_| |_| |_|\__,_/_/\_\#
############################
# tmuxがインストールされていたら自動的に起動してアタッチする
if which tmux > /dev/null 2>&1 ; then
if [ -z $TMUX ] ; then
if [ -z `tmux ls` ] ; then
tmux
else
tmux attach
fi
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment