0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

windowsで使うvscode remote developmentでのzsh環境構築

Posted at

経緯

いままでずっとbashを使っていたのですが、zshが便利というのを聞いて使いたくなってみたので、入れてみました。今のところファイル選択の時の補完が優秀ということだけなので、これからもっと使い込んでいきたいです。

環境は以下のとおりです。

  • ホストPC
    • windows11
  • 接続先
    • ubuntu server
    • wsl2 ubuntu
  • 統合開発環境
    • VScode
  • 利用拡張機能
    • Remote Development

zshのインストール

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install zsh

そのあとzshを起動させる。

zsh

するとconfigrationメッセージがでてくるがdo nothingのqを押す。

Prezto

zshの設定のフレームワークのPreztoをインストールして設定する。
https://github.com/sorin-ionescu/prezto
インストール方法はgithubにも記載してあるのでそちらを参照してもOKです。

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

デフォルトshellをzshに変更する

chsh -s /bin/zsh

spaceship-prompt

今回はオシャレなspaceship-promptを利用する。
https://github.com/spaceship-prompt/spaceship-prompt

インストール方法に従ってコマンドを入力していく。

最初にprezrto-contribを入れる。(これがないとテーマが使えない)

cd $ZPREZTODIR
git clone --recurse-submodules https://github.com/belak/prezto-contrib contrib

zshの設定ファイルである~/.zpreztorcを編集する
以下のように編集する

before

zstyle ':prezto:load' pmodule \
  'environment' \
  'terminal' \
  'editor' \
  'history' \
  'directory' \
  'spectrum' \
  'utility' \
  'completion' \
  'history-substring-search' \
  'prompt'

after

zstyle ':prezto:load' pmodule \
  'environment' \
  'terminal' \
  'editor' \
  'history' \
  'directory' \
  'spectrum' \
  'utility' \
  'completion' \
  'history-substring-search' \
  'contrib-prompt' \
  'prompt'

そして、~/.zpreztorcにテーマ設定があるので、
zstyle ':prezto:module:prompt' theme 'spaceship'と記載する。
もともとsorinが設定されているとおもうので、そこにspaceshipと上書きすれば良い。

VScodeの設定

これでも使えるのだが、spaceshipがPowerLineというFontを使っている。しかし、windows側にこのfontがないと文字化けしてしまうので、fontをインストールして文字化けを治す

fontのインストール

このファイルをダウンロードして、右クリックからのインストールをする。
https://github.com/powerline/fonts/blob/master/UbuntuMono/Ubuntu%20Mono%20derivative%20Powerline.ttf

VScodeでのフォント設定

VScodeの設定画面でterminal.integrated.fontFamilyの項目を先程インストールしたフォントであるUbuntu Mono derivative Powerlineを設定し、VScodeを再起動する。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?