[OpenBSD] zsh をパッケージからインストールして初期設定まで終わらせる。

OpenBSD はデフォルトで ksh が設定されていますがイマイチ使いづらく感じたので zsh をインストールしてみました。

パッケージからインストールです。

$ cat /etc/shells
# $OpenBSD: shells,v 1.8 2009/02/14 17:06:40 sobrado Exp $
#
# list of acceptable shells for chpass(1).
# ftpd(8) will not allow users to connect who are not using
# one of these shells, unless the user is listed in /etc/ftpchroot.
/bin/sh
/bin/csh
/bin/ksh
$ pkg_info -Q zsh
zsh-5.0.5p0
$ sudo pkg_add zsh-5.0.5p0
Password:
quirks-2.54 signed on 2015-03-09T11:04:08Z
zsh-5.0.5p0: ok
$ which zsh
/usr/local/bin/zsh
$ cat /etc/shells
# $OpenBSD: shells,v 1.8 2009/02/14 17:06:40 sobrado Exp $
#
# list of acceptable shells for chpass(1).
# ftpd(8) will not allow users to connect who are not using
# one of these shells, unless the user is listed in /etc/ftpchroot.
/bin/sh
/bin/csh
/bin/ksh
/usr/local/bin/zsh
$

/usr/local/bin にインストールされました。/etc/shells にも zsh が追加されています。

さっそく zsh と叩くと zsh 設定用のメニューが起動しました。

$ zsh
This is the Z Shell configuration function for new users,
zsh-newuser-install.
You are seeing this message because you have no zsh startup files
(the files .zshenv, .zprofile, .zshrc, .zlogin in the directory
~). This function can help you with a few settings that should
make your use of the shell easier.
You can:
(q) Quit and do nothing. The function will be run again next time.
(0) Exit, creating the file ~/.zshrc containing just a comment.
That will prevent this function being run again.
(1) Continue to the main menu.
— Type one of the keys in parentheses —

ここで 1 を押します。

Please pick one of the following options:(1) Configure settings for history, i.e. command lines remembered
and saved by the shell. (Recommended.)(2) Configure the new completion system. (Recommended.)(3) Configure how keys behave when editing command lines. (Recommended.)(4) Pick some of the more common shell options. These are simple “on”
or “off” switches controlling the shell’s features.(0) Exit, creating a blank ~/.zshrc file.(a) Abort all settings and start from scratch. Note this will overwrite
any settings from zsh-newuser-install already in the startup file.
It will not alter any of your other settings, however.(q) Quit and do nothing else. The function will be run again next time.
— Type one of the keys in parentheses —

これがメインメニューです。上の3つが推奨設定となっているようです。まず 1 を押します。

History configuration
=====================# (1) Number of lines of history kept within the shell.
HISTSIZE=1000 (not yet saved)
# (2) File where history is saved.
HISTFILE=~/.histfile (not yet saved)
# (3) Number of lines of history to save to $HISTFILE.
SAVEHIST=1000 (not yet saved)# (0) Remember edits and return to main menu (does not save file yet)
# (q) Abandon edits and return to main menu— Type one of the keys in parentheses —

ヒストリーを 1000 個保存するとかそのファイルが .histfile だとかが表示されました。とくに異存がないので 0 を押してヒストリーの設定を確定してメインメニューに戻ります。

Please pick one of the following options:(1) Configure settings for history, i.e. command lines remembered
and saved by the shell. (Unsaved changes.)(2) Configure the new completion system. (Recommended.)(3) Configure how keys behave when editing command lines. (Recommended.)(4) Pick some of the more common shell options. These are simple “on”
or “off” switches controlling the shell’s features.(0) Exit, saving the new settings. They will take effect immediately.(a) Abort all settings and start from scratch. Note this will overwrite
any settings from zsh-newuser-install already in the startup file.
It will not alter any of your other settings, however.(q) Quit and do nothing else. The function will be run again next time.
— Type one of the keys in parentheses —

メインメニューに戻ると (1) のところが (Unsaved changes.) と表示されています。変更があるけどまだ保存されていないことを教えてくれています。

2 を押し、コマンド補完機能の設定を行います。

The new completion system (compsys) allows you to complete
commands, arguments and special shell syntax such as variables. It provides
completions for a wide range of commonly used commands in most cases simply
by typing the TAB key. Documentation is in the zshcompsys manual page.
If it is not turned on, only a few simple completions such as filenames
are available but the time to start the shell is slightly shorter.You can:
(1) Turn on completion with the default options.(2) Run the configuration tool (compinstall). You can also run
this from the command line with the following commands:
autoload -Uz compinstall
compinstall
if you don’t want to configure completion now.(0) Don’t turn on completion.— Type one of the keys in parentheses —

zsh のコマンド補完機能を ON にするのが (1) となっています。素直にこれを使いたいので 1 を押します。

Please pick one of the following options:(1) Configure settings for history, i.e. command lines remembered
and saved by the shell. (Unsaved changes.)(2) Use the new completion system. (Unsaved changes.)(3) Configure how keys behave when editing command lines. (Recommended.)(4) Pick some of the more common shell options. These are simple “on”
or “off” switches controlling the shell’s features.(0) Exit, saving the new settings. They will take effect immediately.(a) Abort all settings and start from scratch. Note this will overwrite
any settings from zsh-newuser-install already in the startup file.
It will not alter any of your other settings, however.(q) Quit and do nothing else. The function will be run again next time.
— Type one of the keys in parentheses —

またメインメニューに戻ってきました。(2) も (Unsaved changes.) になったことが確認できます。

引続き、(3) を設定すべく 3 を押します。

Default editing configuration
=============================The keys in the shell’s line editor can be made to behave either
like Emacs or like Vi, two common Unix editors. If you have no
experience of either, Emacs is recommended. If you don’t pick one,
the shell will try to guess based on the EDITOR environment variable.
Usually it’s better to pick one explicitly.# (1) Change default editing configuration
bindkey -e (not yet saved)# (0) Remember edits and return to main menu (does not save file yet)
# (q) Abandon edits and return to main menu— Type one of the keys in parentheses —

zsh のラインエディターの振る舞いを Emacs のようにするか Vi のようにするかの設定です。

よくわからなかったのですが 1 を押すと次の選択肢が表示されました。

Pick a keymap (set of keys) to use when editing.
Type:
(e) for Emacs keymap (recommended unless you are vi user)
(v) for Vi keymap
(n) not to set a keymap (allow shell to choose)
(k) to keep the current setting, (e):
— Type one of the keys in parentheses —

Vi のように振る舞わせたいので v を押すと1つ前の画面に戻りました。

Default editing configuration
=============================The keys in the shell’s line editor can be made to behave either
like Emacs or like Vi, two common Unix editors. If you have no
experience of either, Emacs is recommended. If you don’t pick one,
the shell will try to guess based on the EDITOR environment variable.
Usually it’s better to pick one explicitly.# (1) Change default editing configuration
bindkey -v (set but not saved)# (0) Remember edits and return to main menu (does not save file yet)
# (q) Abandon edits and return to main menu— Type one of the keys in parentheses —

さっきは bindkey -e と表示されていたところが bindkey -v に変わりました。-v は Vi の v で、-e は Emacs の e なんだと思います。0 を押してメインメニューに戻ります。

Please pick one of the following options:(1) Configure settings for history, i.e. command lines remembered
and saved by the shell. (Unsaved changes.)(2) Use the new completion system. (Unsaved changes.)(3) Configure how keys behave when editing command lines. (Unsaved changes.)(4) Pick some of the more common shell options. These are simple “on”
or “off” switches controlling the shell’s features.(0) Exit, saving the new settings. They will take effect immediately.(a) Abort all settings and start from scratch. Note this will overwrite
any settings from zsh-newuser-install already in the startup file.
It will not alter any of your other settings, however.(q) Quit and do nothing else. The function will be run again next time.
— Type one of the keys in parentheses —

(3) のところも (Unsaved changes.) に変わりました。

他のオプションも設定できるようだったので 4 を押してどんなものがあるか表示させてみました。

Common shell options
====================The following are some of the shell options that are most often used.
The descriptions are very brief; if you would like more information,
read the zshoptions manual page (type “man zshoptions”).# (1) Change directory given just path.
# unsetopt autocd (no value set)
# (2) Use additional pattern matching features.
# unsetopt extendedglob (no value set)
# (3) Append new history lines instead of overwriting.
# unsetopt appendhistory (no value set)
# (4) Unmatched patterns cause an error.
# setopt nomatch (no value set)
# (5) Beep on errors.
# setopt beep (no value set)
# (6) Immediately report changes in background job status.
# unsetopt notify (no value set)# (0) or (q) Return to main menu (no changes made yet)— Type one of the keys in parentheses —

ただ見たかっただけなので 0 を押してメインメニューに戻ります。

Please pick one of the following options:(1) Configure settings for history, i.e. command lines remembered
and saved by the shell. (Unsaved changes.)(2) Use the new completion system. (Unsaved changes.)(3) Configure how keys behave when editing command lines. (Unsaved changes.)(4) Pick some of the more common shell options. These are simple “on”
or “off” switches controlling the shell’s features.

(0) Exit, saving the new settings. They will take effect immediately.

(a) Abort all settings and start from scratch. Note this will overwrite
any settings from zsh-newuser-install already in the startup file.
It will not alter any of your other settings, however.

(q) Quit and do nothing else. The function will be run again next time.
— Type one of the keys in parentheses —

メインメニューで 0 を押して変更した箇所を保存して終了します。

The function will not be run in future, but you can run
it yourself as follows:
autoload -Uz zsh-newuser-install
zsh-newuser-install -fThe code added to ~/.zshrc is marked by the lines
# Lines configured by zsh-newuser-install
# End of lines configured by zsh-newuser-install
You should not edit anything between these lines if you intend to
run zsh-newuser-install again. You may, however, edit any other part
of the file.
hogehoge%

なにやら今触っていた zsh の設定メニューについての説明が表示された後、zsh のプロンプトになりました。

(Visited 185 times, 1 visits today)

Follow me!

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です