はじめに
環境
Windows 11 Professional
WSL2
Ubuntu 24.04 LTS
事前確認
使用しているShellの確認
echo $SHELL
$ echo $SHELL
/bin/bash
bash
を使っている。
構築
zshのインストール
sudo apt install zsh
ログ
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
zsh-common
Suggested packages:
zsh-doc
The following NEW packages will be installed:
zsh zsh-common
0 upgraded, 2 newly installed, 0 to remove and 89 not upgraded.
Need to get 4985 kB of archives.
After this operation, 19.1 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu noble/main amd64 zsh-common all 5.9-6ubuntu2 [4173 kB]
Get:2 http://archive.ubuntu.com/ubuntu noble/main amd64 zsh amd64 5.9-6ubuntu2 [812 kB]
Fetched 4985 kB in 2s (2415 kB/s)
Selecting previously unselected package zsh-common.
(Reading database ... 47037 files and directories currently installed.)
Preparing to unpack .../zsh-common_5.9-6ubuntu2_all.deb ...
Unpacking zsh-common (5.9-6ubuntu2) ...
Selecting previously unselected package zsh.
Preparing to unpack .../zsh_5.9-6ubuntu2_amd64.deb ...
Unpacking zsh (5.9-6ubuntu2) ...
Setting up zsh-common (5.9-6ubuntu2) ...
Setting up zsh (5.9-6ubuntu2) ...
Processing triggers for debianutils (5.17build1) ...
Processing triggers for man-db (2.12.0-4build2) ...
ログインシェルの変更
chsh
/bin/zsh
が zsh
のパスなので設定をする。
Changing the login shell for kbushi
Enter the new value, or press ENTER for the default
Login Shell [/bin/bash]: /bin/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.
(2) Populate your ~/.zshrc with the configuration recommended
by the system administrator and exit (you will need to edit
the file by hand, if so desired).
--- Type one of the keys in parentheses ---
0
と入力する。
→ .zshrc
が生成される。
oh-my-zshのインストール
https://ohmyz.sh/#install に従ってインストールする。
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
ログ
Cloning Oh My Zsh...
remote: Enumerating objects: 1404, done.
remote: Counting objects: 100% (1404/1404), done.
remote: Compressing objects: 100% (1344/1344), done.
remote: Total 1404 (delta 36), reused 1130 (delta 32), pack-reused 0 (from 0)
Receiving objects: 100% (1404/1404), 3.26 MiB | 45.07 MiB/s, done.
Resolving deltas: 100% (36/36), done.
From https://github.com/ohmyzsh/ohmyzsh
* [new branch] master -> origin/master
branch 'master' set up to track 'origin/master'.
Already on 'master'
/home/kbushi
Looking for an existing zsh config...
Found /home/kbushi/.zshrc. Backing up to /home/kbushi/.zshrc.pre-oh-my-zsh
Using the Oh My Zsh template file and adding it to /home/kbushi/.zshrc.
__ __
____ / /_ ____ ___ __ __ ____ _____/ /_
/ __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \
/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / /
\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/
/____/ ....is now installed!
Before you scream Oh My Zsh! look over the `.zshrc` file to select plugins, themes, and options.
• Follow us on X: @ohmyzsh
• Join our Discord community: Discord server
• Get stickers, t-shirts, coffee mugs and more: Planet Argon Shop
テーマ(powerlevel10k)を入れる
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k
~/.zshrc
を編集する。
-ZSH_THEME="robbyrussell"
+ZSH_THEME="powerlevel10k/powerlevel10k"
ログアウトして再度ログインをする。
↓
This is Powerlevel10k configuration wizard. You are seeing it because you haven't
defined any Powerlevel10k configuration options. It will ask you a few questions and
configure your prompt.
Does this look like a diamond (rotated square)?
reference: https://graphemica.com/%E2%97%86
---> <---
(y) Yes.
(n) No.
(q) Quit and do nothing.
Choice [ynq]:
インストールウィザードが始まるので設定する。
5~6回くらい聞かれるのでよさそうなものを選んで設定した。
参考
【WSL2】WSL2環境でOh my zshを入れてAgnosterのテーマを適用する
https://qiita.com/kazuki_yoshida/items/a66a52ef813e168195bbWSL2でWeb開発環境の構築メモ (zsh, node, dockerなど)
https://zenn.dev/moroya/articles/0ab24a733e4b7aElevate Your Terminal: Exploring the Top Zsh Themes for a Stylish Shell Experience
https://medium.com/@anisettyanudeep/elevate-your-terminal-exploring-the-top-zsh-themes-for-a-stylish-shell-experience-af43d21ba3dc
おわりに
zsh
を10年ぶりくらいに環境に入れた。oh-my-zsh
いまだに好きなのでこれを使うようにしてるけど、他に何か人気なのは出ているのかも今度調べてみようかな。powerlevel10k
は初めて使うので、これから楽しみ。