LoginSignup
17
17

More than 5 years have passed since last update.

zshの設定ファイルの構成

Last updated at Posted at 2014-12-13

zsh Advent Calendar 2014 23日目

私のzshのディレクトリ構成を紹介します。
oh-my-zshは全く使って無くて完全に自分の趣味のディレクトリ構成になってます。

ディレクトリ構成

Directory
$HOME
├── .zsh.d/
├── .zshenv
├── .zshenv_config/
│    └── .zsh_00_path
├── .zshrc
└── .zshrc_config/
     ├── .zsh_00_alias
     ├── .zsh_01_prompt
     ├── .zsh_02_zaw
     ├── .zsh_09_tmuxinator
     ├── .zsh_10_BusterJS
     ├── .zsh_10_exenv
     :
     :

設定ファイル

.zshenv関連

対話式以外でzshを起動する事はないので、.zshenvの設定を.zshrcに移動しても良いのですが、path等は.zshenvに設定してます。

.zshenv
#-*- mode: shell-script; coding: utf-8; -*-
unlimit
limit stacksize 8192
limit coredumpsize 8192
limit -s

umask 022

export LANG=ja_JP.UTF-8
export LC_ALL=ja_JP.UTF-8

# Setup command search path
typeset -U path

export RSYNC_RSH=ssh
export CVS_RSH=ssh

for conf in $HOME/.zshenv_config/.zsh_*; do
        source ${conf};
done

最後の部分で、.zshenv_config/内のファイルを読み込んでます。

.zshrc関連

.zshrc
HISTFILE=~/private/.zsh_history
HISTSIZE=10000000
SAVEHIST=10000000
function history-all() { history -E 1 } # 全履歴の一覧を出力する

autoload -Uz history-search-end
zle -N history-beginning-search-forward-end  history-search-end
zle -N history-beginning-search-backward-end history-search-end
bindkey '\eP' history-beginning-search-backward-end    #Esc-P
bindkey '\eN' history-beginning-search-forward-end     #Esc-N
FCEDIT=vi   # fc -e viと同じ

autoload -Uz up-line-or-beginning-search down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
bindkey '^P' up-line-or-beginning-search
bindkey '^N' down-line-or-beginning-search
#
# snip
#
manpath=(/usr/*/man(N-/) /usr/local/*/man(N-/) ${manpath})

hosts=(`hostname` example.com)

zmodload zsh/files     # mv / cp / chgrp等のコマンドをzshのbuilt-inコマンドに置き換える。
#
# snip
#
zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters

zstyle ':completion:*' hosts $hosts

# rm以外のコマンドで*.oファイルなどは保管しない。
zstyle ':completion:*:*:(^(rm)):*:*files' ignored-patterns '*?.o' '*?.c~' '*?.old' '*?.pro'

zstyle ':completion:*' list-separator '-->'
#
# snip
#
for conf in $HOME/.zshrc_config/.zsh_*; do
    source ${conf};
done

最後の部分で、.zshrc_config/内のファイルを読み込んでます。
.zshrc_configの中は以下の様になっていて、数字の若い順番に読み込んでいます。
使わなくなって設定は、頭にnot-sourceを付けてfor inで読み込ませないようにしてます。

Filelist
.zsh_00_alias
.zsh_00_prompt
.zsh_00_zaw
.zsh_10_busterjs
.zsh_10_exenv
.zsh_10_golang
.zsh_10_highlighting
.zsh_10_java
.zsh_10_jstestdriver
.zsh_10_nenv
.zsh_10_rbenv
.zsh_10_tmuxinator
.zsh_20_antlr
.zsh_20_kerl
.zsh_20_peco
.zsh_30_gcsdk
not-source.zsh_10_rvm

.zsh.dディレクトリ

.zsh.dには以下のモジュールをgit cloneして置いてます。

Libraries
zaw
zsh-completions
zsh-syntax-highlighting

まとめ

かなりコンパクトな構成になっているのですが、zshが元々強力なので全然問題ないです。
ぜひ、自分で設定ファイルを0から書いてみてください。結構面白いですよ。

17
17
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
17