<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PHPプログラマのバリ・ポジ情報ブログ &#187; zsh</title>
	<atom:link href="http://blog.veryposi.info/tag/zsh/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.veryposi.info</link>
	<description>PHP,JavaScriptやサーバーの設定などのプログラミングに関する情報をバリ・ポジティブに発信しているプログラマのブログ、『バリ・ポジ』</description>
	<lastBuildDate>Thu, 10 May 2012 06:23:01 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>最強のシェル　zshの設定</title>
		<link>http://blog.veryposi.info/server/server-setup/zsh-setup/</link>
		<comments>http://blog.veryposi.info/server/server-setup/zsh-setup/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 12:09:12 +0000</pubDate>
		<dc:creator>gensan</dc:creator>
				<category><![CDATA[設定]]></category>
		<category><![CDATA[zsh]]></category>

		<guid isPermaLink="false">http://blog.veryposi.info/?p=957</guid>
		<description><![CDATA[UNIXでShellというと、「bash」や「tcsh」を使っている人が多いかと思いますが、俺がおススメするのは、最強のシェルその名も「zsh」です。 zshの設定内容をまとめておきますばい勉強したばいzsh最高ばい &#038; [...]]]></description>
			<content:encoded><![CDATA[<p>UNIXでShellというと、「bash」や「tcsh」を使っている人が多いかと思いますが、俺がおススメするのは、最強のシェルその名も「<span style="background-color: rgb(255, 255, 153);"><span style="font-size: large;">zsh</span></span>」です。</p>
<p>zshの設定内容をまとめておきますばい<img src="http://blog.veryposi.info/wp-content/plugins/fckeditor-for-wordpress-plugin/smiles/typepad/book.gif" alt="" />勉強したばい<img src="http://blog.veryposi.info/wp-content/plugins/fckeditor-for-wordpress-plugin/smiles/typepad/catface.gif" alt="" />zsh最高ばい<img src="http://blog.veryposi.info/wp-content/plugins/fckeditor-for-wordpress-plugin/smiles/typepad/up.gif" alt="" /></p>
<p>&nbsp;</p>
<p>と思ったけど・・・難しい<img alt="" src="http://blog.veryposi.info/wp-content/plugins/fckeditor-for-wordpress-plugin/smiles/typepad/impact.gif" />勉強中です<img alt="" src="http://blog.veryposi.info/wp-content/plugins/fckeditor-for-wordpress-plugin/smiles/typepad/down.gif" /></p>
<p>&nbsp;</p>
<p>.zshenv</p>
<div class="syntax">
<table>
<tbody>
<tr>
<td class="line_numbers">
<pre>
1
2
</pre>
</td>
<td class="code">
<pre class="bash"><span style="color: rgb(128, 128, 128); font-style: italic;"># 文字コードの設定</span>
<span style="color: rgb(122, 8, 116); font-weight: bold;">export</span> <span style="color: rgb(0, 120, 0);">LANG=</span>ja_JP.UTF<span style="color: rgb(0, 0, 0);">-8</span></pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>.zshrc</p>
<div class="syntax">
<table>
<tbody>
<tr>
<td class="line_numbers">
<pre>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
</pre>
</td>
<td class="code">
<pre class="bash"><span style="color: rgb(128, 128, 128); font-style: italic;">###############################################</span>
<span style="color: rgb(128, 128, 128); font-style: italic;"># キーバインド                                #</span>
<span style="color: rgb(128, 128, 128); font-style: italic;">###############################################</span>
<span style="color: rgb(128, 128, 128); font-style: italic;"># viライクキーバインド</span>
bindkey -v
<span style="color: rgb(128, 128, 128); font-style: italic;"># Emacsライクキーバインド</span>
<span style="color: rgb(128, 128, 128); font-style: italic;">#bindkey -e</span>
&nbsp;
<span style="color: rgb(128, 128, 128); font-style: italic;">###############################################</span>
<span style="color: rgb(128, 128, 128); font-style: italic;"># 補完関係                                    #</span>
<span style="color: rgb(128, 128, 128); font-style: italic;">###############################################</span>
<span style="color: rgb(128, 128, 128); font-style: italic;"># 標準の補完設定</span>
autoload -U compinit
compinit
&nbsp;
<span style="color: rgb(128, 128, 128); font-style: italic;"># ディレクトリ名を入力するだけでカレントディレクトリを変更</span>
setopt auto_cd
&nbsp;
<span style="color: rgb(128, 128, 128); font-style: italic;"># タブキー連打で補完候補を順に表示</span>
setopt auto_menu
&nbsp;
<span style="color: rgb(128, 128, 128); font-style: italic;"># 自動修正機能<span style="color: rgb(122, 8, 116); font-weight: bold;">(</span>候補を表示<span style="color: rgb(122, 8, 116); font-weight: bold;">)</span></span>
<span style="color: rgb(128, 128, 128); font-style: italic;">#setopt correct</span>
&nbsp;
<span style="color: rgb(128, 128, 128); font-style: italic;"># 補完候補を詰めて表示</span>
setopt list_packed
&nbsp;
<span style="color: rgb(128, 128, 128); font-style: italic;"># 補完候補一覧でファイルの種別を識別マーク表示<span style="color: rgb(122, 8, 116); font-weight: bold;">(</span><span style="color: rgb(194, 12, 185); font-weight: bold;">ls</span> -F の記号<span style="color: rgb(122, 8, 116); font-weight: bold;">)</span></span>
setopt list_types
&nbsp;
<span style="color: rgb(128, 128, 128); font-style: italic;"># パスの最後に付くスラッシュを自動的に削除しない</span>
setopt noautoremoveslash
&nbsp;
<span style="color: rgb(128, 128, 128); font-style: italic;"># = 以降でも補完できるようにする<span style="color: rgb(122, 8, 116); font-weight: bold;">(</span> --<span style="color: rgb(0, 120, 0);">prefix=</span>/usr 等の場合<span style="color: rgb(122, 8, 116); font-weight: bold;">)</span></span>
setopt magic_equal_subst
&nbsp;
<span style="color: rgb(128, 128, 128); font-style: italic;"># 補完候補リストの日本語を正しく表示</span>
setopt print_eight_bit
&nbsp;
<span style="color: rgb(128, 128, 128); font-style: italic;"># 補完の時に大文字小文字を区別しない<span style="color: rgb(122, 8, 116); font-weight: bold;">(</span>但し、大文字を打った場合は小文字に変換しない<span style="color: rgb(122, 8, 116); font-weight: bold;">)</span></span>
zstyle <span style="color: rgb(255, 0, 0);">':completion:*'</span> matcher-list <span style="color: rgb(255, 0, 0);">'m:{a-z}={A-Z}'</span>
&nbsp;
<span style="color: rgb(128, 128, 128); font-style: italic;"># <span style="color: rgb(194, 12, 185); font-weight: bold;">ls</span>コマンドの補完候補にも色付き表示</span>
<span style="color: rgb(122, 8, 116); font-weight: bold;">eval</span> `<span style="color: rgb(194, 12, 185); font-weight: bold;">dircolors</span>`
zstyle <span style="color: rgb(255, 0, 0);">':completion:*:default'</span> list-colors <span style="color: rgb(0, 120, 0);">$<span style="color: rgb(122, 8, 116); font-weight: bold;">{</span>LS_COLORS<span style="color: rgb(122, 8, 116); font-weight: bold;">}</span></span>
<span style="color: rgb(128, 128, 128); font-style: italic;"># <span style="color: rgb(194, 12, 185); font-weight: bold;">kill</span> の候補にも色付き表示</span>
zstyle <span style="color: rgb(255, 0, 0);">':completion:*:*:kill:*:processes'</span> list-colors <span style="color: rgb(255, 0, 0);">'=(#b) #([%0-9]#)*=0=01;31'</span>
&nbsp;
<span style="color: rgb(128, 128, 128); font-style: italic;">###############################################</span>
<span style="color: rgb(128, 128, 128); font-style: italic;"># 履歴関係                                    #</span>
<span style="color: rgb(128, 128, 128); font-style: italic;">###############################################</span>
<span style="color: rgb(128, 128, 128); font-style: italic;"># ヒストリー機能</span>
<span style="color: rgb(0, 120, 0);">HISTFILE=</span>~/.zsh_history      <span style="color: rgb(128, 128, 128); font-style: italic;"># ヒストリファイルを指定</span>
<span style="color: rgb(0, 120, 0);">HISTSIZE=</span><span style="color: rgb(0, 0, 0);">10000</span>               <span style="color: rgb(128, 128, 128); font-style: italic;"># ヒストリに保存するコマンド数</span>
<span style="color: rgb(0, 120, 0);">SAVEHIST=</span><span style="color: rgb(0, 0, 0);">10000</span>               <span style="color: rgb(128, 128, 128); font-style: italic;"># ヒストリファイルに保存するコマンド数</span>
setopt hist_ignore_all_dups  <span style="color: rgb(128, 128, 128); font-style: italic;"># 重複するコマンド行は古い方を削除</span>
setopt hist_ignore_dups      <span style="color: rgb(128, 128, 128); font-style: italic;"># 直前と同じコマンドラインはヒストリに追加しない</span>
setopt share_history         <span style="color: rgb(128, 128, 128); font-style: italic;"># コマンド履歴ファイルを共有する</span>
setopt append_history        <span style="color: rgb(128, 128, 128); font-style: italic;"># 履歴を追加 <span style="color: rgb(122, 8, 116); font-weight: bold;">(</span>毎回 .zsh_history を作るのではなく<span style="color: rgb(122, 8, 116); font-weight: bold;">)</span></span>
setopt inc_append_history    <span style="color: rgb(128, 128, 128); font-style: italic;"># 履歴をインクリメンタルに追加</span>
setopt hist_no_store         <span style="color: rgb(128, 128, 128); font-style: italic;"># <span style="color: rgb(122, 8, 116); font-weight: bold;">history</span>コマンドは履歴に登録しない</span>
setopt hist_reduce_blanks    <span style="color: rgb(128, 128, 128); font-style: italic;"># 余分な空白は詰めて記録</span>
<span style="color: rgb(128, 128, 128); font-style: italic;">#setopt hist_ignore_space    # 先頭がスペースの場合、ヒストリに追加しない</span>
&nbsp;
<span style="color: rgb(128, 128, 128); font-style: italic;"># <span style="color: rgb(122, 8, 116); font-weight: bold;">cd</span> - と入力してTabキーで今までに移動したディレクトリを一覧表示</span>
setopt auto_pushd
&nbsp;
<span style="color: rgb(128, 128, 128); font-style: italic;"># ディレクトリスタックに重複する物は古い方を削除</span>
setopt pushd_ignore_dups
&nbsp;
<span style="color: rgb(128, 128, 128); font-style: italic;"># コマンド履歴の検索機能の設定</span>
<span style="color: rgb(128, 128, 128); font-style: italic;"># ^<span style="color: rgb(122, 8, 116); font-weight: bold;">[</span>  は「エスケープ」</span>
<span style="color: rgb(128, 128, 128); font-style: italic;"># viなら    Ctrl-v ESC</span>
<span style="color: rgb(128, 128, 128); font-style: italic;"># Emacsなら Ctrl-q ESC</span>
<span style="color: rgb(128, 128, 128); font-style: italic;"># viで編集する場合</span>
<span style="color: rgb(128, 128, 128); font-style: italic;"># 上<span style="color: rgb(0, 0, 0);">2</span>行は Ctrl-v を押下した後、希望のキーを押下</span>
<span style="color: rgb(128, 128, 128); font-style: italic;"># 下<span style="color: rgb(0, 0, 0);">2</span>行は「エスケープ」の後にキーの端末コードを入力</span>
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 <span style="color: rgb(255, 0, 0);">&quot;^[OA&quot;</span> history-beginning-search-backward-end
bindkey <span style="color: rgb(255, 0, 0);">&quot;^[OB&quot;</span> history-beginning-search-forward-end
bindkey <span style="color: rgb(255, 0, 0);">&quot;^[[A&quot;</span> history-beginning-search-backward-end
bindkey <span style="color: rgb(255, 0, 0);">&quot;^[[B&quot;</span> history-beginning-search-forward-end
<span style="color: rgb(128, 128, 128); font-style: italic;"># 複数行コマンドの場合、上記の設定だと少々不都合</span>
<span style="color: rgb(128, 128, 128); font-style: italic;"># tcshの様にする場合は以下のようにする</span>
<span style="color: rgb(128, 128, 128); font-style: italic;">#bindkey </span><span style="color: rgb(255, 0, 0);">&quot;^P&quot;</span> history-beginning-search-backward-end
<span style="color: rgb(128, 128, 128); font-style: italic;">#bindkey </span><span style="color: rgb(255, 0, 0);">&quot;^N&quot;</span> history-beginning-search-forward-end
&nbsp;
<span style="color: rgb(128, 128, 128); font-style: italic;"># インクリメンタルサーチの設定</span>
bindkey <span style="color: rgb(255, 0, 0);">&quot;^R&quot;</span> history-incremental-search-backward
bindkey <span style="color: rgb(255, 0, 0);">&quot;^S&quot;</span> history-incremental-search-forward
&nbsp;
<span style="color: rgb(128, 128, 128); font-style: italic;"># 全履歴の一覧を出力する</span>
<span style="color: rgb(0, 0, 0); font-weight: bold;">function</span> history-all <span style="color: rgb(122, 8, 116); font-weight: bold;">{</span> <span style="color: rgb(122, 8, 116); font-weight: bold;">history</span> -E <span style="color: rgb(0, 0, 0);">1</span> <span style="color: rgb(122, 8, 116); font-weight: bold;">}</span>
&nbsp;
<span style="color: rgb(128, 128, 128); font-style: italic;">###############################################</span>
<span style="color: rgb(128, 128, 128); font-style: italic;"># プロンプト関係                              #</span>
<span style="color: rgb(128, 128, 128); font-style: italic;">###############################################</span>
<span style="color: rgb(128, 128, 128); font-style: italic;"># プロンプトに escape sequence <span style="color: rgb(122, 8, 116); font-weight: bold;">(</span>環境変数<span style="color: rgb(122, 8, 116); font-weight: bold;">)</span> を通す</span>
setopt prompt_subst
&nbsp;
<span style="color: rgb(128, 128, 128); font-style: italic;"># プロンプトの設定</span>
<span style="color: rgb(0, 120, 0);">PROMPT=</span><span style="color: rgb(255, 0, 0);">'%m%# '</span>
<span style="color: rgb(0, 120, 0);">RPROMPT=</span><span style="color: rgb(255, 0, 0);">' %~'</span>
&nbsp;
<span style="color: rgb(128, 128, 128); font-style: italic;"># ターミナルのタイトル</span>
<span style="color: rgb(0, 0, 0); font-weight: bold;">case</span> <span style="color: rgb(255, 0, 0);">&quot;${TERM}&quot;</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">in</span>
kterm*|xterm<span style="color: rgb(122, 8, 116); font-weight: bold;">)</span>
    precmd<span style="color: rgb(122, 8, 116); font-weight: bold;">(</span><span style="color: rgb(122, 8, 116); font-weight: bold;">)</span> <span style="color: rgb(122, 8, 116); font-weight: bold;">{</span>
        <span style="color: rgb(122, 8, 116); font-weight: bold;">echo</span> -ne <span style="color: rgb(255, 0, 0);">&quot;<span style="color: rgb(0, 0, 153); font-weight: bold;">\0</span>33]0;${USER}@${HOST%%.*}:${PWD}<span style="color: rgb(0, 0, 153); font-weight: bold;">\0</span>07&quot;</span>
    <span style="color: rgb(122, 8, 116); font-weight: bold;">}</span>
    ;;
<span style="color: rgb(0, 0, 0); font-weight: bold;">esac</span>
&nbsp;
<span style="color: rgb(128, 128, 128); font-style: italic;">###############################################</span>
<span style="color: rgb(128, 128, 128); font-style: italic;"># その他                                      #</span>
<span style="color: rgb(128, 128, 128); font-style: italic;">###############################################</span>
<span style="color: rgb(128, 128, 128); font-style: italic;"># ファイル作成時のパーミッション</span>
<span style="color: rgb(122, 8, 116); font-weight: bold;">umask</span> <span style="color: rgb(0, 0, 0);">022</span>
&nbsp;
setopt no_beep               <span style="color: rgb(128, 128, 128); font-style: italic;"># ビープ音を消す</span>
<span style="color: rgb(128, 128, 128); font-style: italic;">#setopt nolistbeep           # 補完候補表示時などにビープ音を鳴らさない</span>
&nbsp;
<span style="color: rgb(128, 128, 128); font-style: italic;">#setopt interactive_comments # コマンドラインで # 以降をコメントとする</span>
&nbsp;
setopt numeric_glob_sort     <span style="color: rgb(128, 128, 128); font-style: italic;"># 辞書順ではなく数値順でソート</span>
&nbsp;
setopt no_multios            <span style="color: rgb(128, 128, 128); font-style: italic;"># <span style="color: rgb(194, 12, 185); font-weight: bold;">zsh</span>のリダイレクト機能を制限する</span>
&nbsp;
unsetopt promptcr            <span style="color: rgb(128, 128, 128); font-style: italic;"># 改行コードで終らない出力もちゃんと出力する</span>
<span style="color: rgb(128, 128, 128); font-style: italic;">#setopt ignore_eof           # Ctrl-dでログアウトしない</span>
&nbsp;
setopt no_hup                <span style="color: rgb(128, 128, 128); font-style: italic;"># ログアウト時にバックグラウンドジョブを<span style="color: rgb(194, 12, 185); font-weight: bold;">kill</span>しない</span>
setopt no_checkjobs          <span style="color: rgb(128, 128, 128); font-style: italic;"># ログアウト時にバックグラウンドジョブを確認しない</span>
setopt notify                <span style="color: rgb(128, 128, 128); font-style: italic;"># バックグラウンドジョブが終了したら<span style="color: rgb(122, 8, 116); font-weight: bold;">(</span>プロンプトの表示を待たずに<span style="color: rgb(122, 8, 116); font-weight: bold;">)</span>すぐに知らせる</span>
&nbsp;
<span style="color: rgb(128, 128, 128); font-style: italic;">#setopt rm_star_wait         # <span style="color: rgb(194, 12, 185); font-weight: bold;">rm</span> * を実行する前に確認</span>
setopt rm_star_silent        <span style="color: rgb(128, 128, 128); font-style: italic;"># <span style="color: rgb(194, 12, 185); font-weight: bold;">rm</span> * を実行する前に確認しない</span>
<span style="color: rgb(128, 128, 128); font-style: italic;">#setopt no_clobber           # リダイレクトで上書きを禁止</span>
unsetopt no_clobber          <span style="color: rgb(128, 128, 128); font-style: italic;"># リダイレクトで上書きを許可</span>
&nbsp;
<span style="color: rgb(128, 128, 128); font-style: italic;">#setopt chase_links          # シンボリックリンクはリンク先のパスに変換してから実行</span>
<span style="color: rgb(128, 128, 128); font-style: italic;">#setopt print_exit_value     # 戻り値が <span style="color: rgb(0, 0, 0);">0</span> 以外の場合終了コードを表示</span>
<span style="color: rgb(128, 128, 128); font-style: italic;">#setopt single_line_zle      # デフォルトの複数行コマンドライン編集ではなく、１行編集モードになる</span>
&nbsp;
<span style="color: rgb(128, 128, 128); font-style: italic;"># カーソル位置から前方削除<span style="color: rgb(122, 8, 116); font-weight: bold;">(</span>Ctrl-u<span style="color: rgb(122, 8, 116); font-weight: bold;">)</span></span>
bindkey <span style="color: rgb(255, 0, 0);">'^U'</span> backward-kill-line
&nbsp;
<span style="color: rgb(128, 128, 128); font-style: italic;"># Ctrl-h で単語ごとに削除</span>
bindkey <span style="color: rgb(255, 0, 0);">&quot;^h&quot;</span> backward-kill-word
<span style="color: rgb(128, 128, 128); font-style: italic;"># / を単語の一部とみなさない記号の環境変数から削除</span>
<span style="color: rgb(0, 120, 0);">WORDCHARS=</span><span style="color: rgb(255, 0, 0);">'*?_-.[]~=&amp;;!#$%^(){}&lt;&gt;'</span>
&nbsp;
<span style="color: rgb(128, 128, 128); font-style: italic;">#function chpwd<span style="color: rgb(122, 8, 116); font-weight: bold;">(</span><span style="color: rgb(122, 8, 116); font-weight: bold;">)</span> <span style="color: rgb(122, 8, 116); font-weight: bold;">{</span> <span style="color: rgb(194, 12, 185); font-weight: bold;">ls</span> <span style="color: rgb(122, 8, 116); font-weight: bold;">}</span>     # <span style="color: rgb(122, 8, 116); font-weight: bold;">cd</span> の後 <span style="color: rgb(194, 12, 185); font-weight: bold;">ls</span> も実行</span>
&nbsp;
<span style="color: rgb(128, 128, 128); font-style: italic;">###############################################</span>
<span style="color: rgb(128, 128, 128); font-style: italic;"># エイリアス                                  #</span>
<span style="color: rgb(128, 128, 128); font-style: italic;">###############################################</span>
<span style="color: rgb(128, 128, 128); font-style: italic;"># 補完される前にオリジナルのコマンドまで展開してチェックする</span>
setopt complete_aliases
&nbsp;
<span style="color: rgb(128, 128, 128); font-style: italic;"># エイリアス</span>
<span style="color: rgb(122, 8, 116); font-weight: bold;">alias</span> <span style="color: rgb(0, 120, 0);">ls=</span><span style="color: rgb(255, 0, 0);">'ls --color=auto'</span>
<span style="color: rgb(122, 8, 116); font-weight: bold;">alias</span> <span style="color: rgb(0, 120, 0);">h=</span><span style="color: rgb(255, 0, 0);">'history -E -32'</span>
<span style="color: rgb(122, 8, 116); font-weight: bold;">alias</span> <span style="color: rgb(0, 120, 0);">ll=</span><span style="color: rgb(255, 0, 0);">'ls -laF --color | more'</span></pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.veryposi.info/server/server-setup/zsh-setup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: blog.veryposi.info @ 2026-04-11 01:28:44 -->