Skip to content

Instantly share code, notes, and snippets.

@metasta
Last active October 8, 2018 10:02
Show Gist options
  • Save metasta/1752247 to your computer and use it in GitHub Desktop.
Save metasta/1752247 to your computer and use it in GitHub Desktop.
.zshrc
# users generic .zshrc file for zsh(1)
# 言語
#
export LANG=ja_JP.UTF-8
# LISTMAX
#
# たくさん補完候補を表示する前に確認する
# -1 : 確認しない
# 0 : ウィンドウに収まらないとき確認
export LISTMAX=0
# TIMEFMT
#
# timeコマンドの出力フォーマット
#
export TIMEFMT=$'\nreal\t%E\nuser\t%U\nsys\t%S'
## シェル通常設定
#
# プロンプト
#
setopt promptsubst
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
PROMPT=$(echo '%{\033[01;32m%}%n@%m%{\033[m%}:%{\033[01;34m%}%(4~,%-1~/.../%1~,%~)%{\033[m%}%(!.#.$) ')
else
PROMPT='%n@%m:%(4~,%-1~/.../%1~,%~)%(!.#.$) '
fi
PROMPT2='%_> '
RPROMPT='%*'
SPROMPT='もしかして: "%r" [y/N] '
# ディレクトリ自動変更
#
setopt autocd
# "cd -[tab]" でディレクトリ履歴
#
setopt autopushd
setopt pushdignoredups
# コマンド訂正
#
setopt correct
# 一覧を詰めて表示
#
setopt listpacked
# パス末尾のスラッシュを除去しない
#
setopt noautoremoveslash
# 一覧時にビープ音を鳴らさない
#
setopt nolistbeep
## キーバインド
#
# Emacs 風キーバインド (e.g. C-aで行頭、C-eで行末) 他
#
bindkey -e
bindkey "^[[1~" beginning-of-line # Home gets to line head
bindkey "^[[4~" end-of-line # End gets to line end
bindkey "^[[3~" delete-char # Del
# コマンド履歴、検索用ショートカットキー ^P/^N
#
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
bindkey "\\ep" history-beginning-search-backward-end
bindkey "\\en" history-beginning-search-forward-end
# Shift-Tab で逆方向
#
bindkey "\e[Z" reverse-menu-complete
## コマンド履歴
#
HISTFILE=${HOME}/.zsh_history
HISTSIZE=50000
SAVEHIST=50000
setopt histignorealldups histsavenodups # 重複履歴を保存しない
setopt histignorespace # 先頭にSPACEを入れると履歴を残さない
setopt sharehistory # 複数端末で履歴を共有
## 補完
#
fpath=(${HOME}/.zsh/functions/Completion ${fpath})
autoload -U compinit && compinit
export LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:ex=01;32:*.tar=01;31'
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
zstyle ':completion:*:default' menu select true
unsetopt automenu
## zshエディタ、zed
#
#autoload zed
## 予測
#
#autoload predict-on && predict-on
## エイリアス
#
# 補完より前に適用される
#
setopt complete_aliases # エイリアス前のコマンド補完をチェック
alias where="command -v"
alias which="/usr/bin/which"
alias j="jobs -l"
case $OSTYPE in
darwin* | *bsd* )
export LSCOLORS='ExGxFxdaCxDaDahbadacec'
alias ls="ls -G"
;;
* )
alias ls="ls --color=auto"
;;
esac
alias la="ls -a"
alias lf="ls -F"
alias ll="ls -lAFh"
alias du="du -h"
alias df="df -h"
alias su="su -l"
alias grep="grep --color=auto"
alias diff="diff -U 0"
## ターミナル設定
#
# ターミナルタイトル
#
case "$TERM" in
xterm*|rxvt*)
function precmd(){
echo -n "\e]2;$USER@$HOST\a"
}
;;
esac
## 個人設定(~/.zshrc.mine) 読み込み
#
[ -f "${HOME}/.zshrc.mine" ] && source "${HOME}/.zshrc.mine"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment