sorin-ionescu/prezto でやってたので真似してみた。
fortune コマンドをインストール
まずは格言を表示するためのコマンド fortune
をインストールします。
以下は Mac の場合
$ brew install fortune
zsh ログイン時に fortune を実行
~/.zlogin
ファイルに以下のコードを追加します。
(ファイルがない場合は新規作成して下さい)
.zlogin
# Print a random, hopefully interesting, adage.
if (( $+commands[fortune] )); then
fortune -a
print
fi
if
文では fortune
コマンドの有無をチェックしています。
zsh 特有の書き方なので、bash
や他のシェルでは type
や which
コマンドなどでチェックして下さい。
(zsh でも type
や which
でチェックしても問題ありません)
.zlogin
# Print a random, hopefully interesting, adage.
if type fortune > /dev/null 2>&1; then
fortune -a
print
fi