Software development of explosion! -夢の破片(カケラ)たちの日々-

ソフトウェア開発を中心としたコンピューター関連のネタを扱ったブログです

Software development is passion and explosion!

zshでzsh-completions

目的

家の macOS Catalina をようやく、bash から zsh へ移行した。 bashよりも使いやすいため、Dockerコンテナーを使って設定を試し、その手順を書き残そうと思う。

手順

docker pull

docker pull ubuntu:bionic

docker run と最新化

docker run --rm -it --name ubuntu ubuntu:bionic bash
apt update -qq
apt full-upgrade -qqy

zsh と git のインストール

apt install -qqy --no-install-recommends git ca-certificates
apt install -qqy --no-install-recommends zsh

Prezto のインストール

zsh
cd $HOME
git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"
setopt EXTENDED_GLOB
for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do
  ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"
done

これで Prezto のインストールはOK

zsh-completions

git clone https://github.com/zsh-users/zsh-completions.git  "${ZDOTDIR:-$HOME}/.zsh-completions"
echo 'fpath=(${ZDOTDIR:-$HOME}/.zsh-completions/src $fpath)' >> $HOME/.zshrc

zsh-completions のインストールもこれで良い。

というか。。。

公式サイトの手順でaptリポジトリーを追加しようにも、証明書の期限切れ?らしくてエラーとなるオプションで回避出来はするはずだけども、セキュリティー的によくないからやってない。 https://software.opensuse.org/download.html?project=shells%3Azsh-users%3Azsh-completions&package=zsh-completions

echo 'deb http://download.opensuse.org/repositories/shells:/zsh-users:/zsh-completions/xUbuntu_18.04/ /' > /etc/apt/sources.list.d/shells:zsh-users:zsh-completions.list
wget -nv https://download.opensuse.org/repositories/shells:zsh-users:zsh-completions/xUbuntu_18.04/Release.key -O Release.key
apt-key add - < Release.key
apt update -qq
W: GPG error: http://download.opensuse.org/repositories/shells:/zsh-users:/zsh-completions/xUbuntu_18.04  InRelease: The following signatures were invalid: EXPKEYSIG 9CBE063CAB8FE1F1 shells:zsh-users:zsh-completions OBS Project <shells:zsh-users:zsh-completions@build.opensuse.org>
E: The repository 'http://download.opensuse.org/repositories/shells:/zsh-users:/zsh-completions/xUbuntu_18.04  InRelease' is not signed.

bashのcomplationよりも優秀で、↓のように候補が一覧表示されたりする、

$ git c<tab>
 -- common commands --
checkout  -- checkout a branch or paths to the working tree
clone     -- clone a repository into a new directory
commit    -- record changes to the repository

追記

テーマ変更の方法もメモしとく

# テーマ一覧
prompt -l
 
# テーマをプレビュー
prompt -p <テーマ名>
 
# すべてのテーマをプレビュー
prompt -p
 
# テーマを適用(再起動したら戻る)
prompt <テーマ名>

# テーマ適用(.zpreztorc)
zstyle ':prezto:module:prompt' theme '<テーマ名>'

個人的には、元のbashみたいに見える redhat テーマが好き