LoginSignup
29
27

More than 3 years have passed since last update.

WSLでお手軽にオシャレfish環境構築

Last updated at Posted at 2019-01-12

始めに

Windows10には、WSL(Windows Subsystem for Linux)と呼ばれる、Linux環境を動作することが出来る機能が備わっています。
Windows上で簡単にオシャレなfish環境を構築する手順を記載していきます。

WSL導入

下記URLを参照して、Windows10上にWSLを導入します。本記事は、Ubuntu 18.04 を対象にしています。

Repositoryの参照先を日本に変更

sudo sed -i -e 's%http://.*.ubuntu.com%http://ftp.jaist.ac.jp/pub/Linux%g' /etc/apt/sources.list

パッケージのアップデート

sudo apt update
sudo apt upgrade -y

fishの導入

sudo apt-add-repository ppa:fish-shell/release-2
sudo apt-get update
sudo apt-get install -y fish

fishをdefault shellへ設定

$ chsh
Password:
Changing the login shell for sugi
Enter the new value, or press ENTER for the default
        Login Shell [/bin/bash]: /usr/bin/fish

一度ターミナルを終了し、再度起動します

fisherの導入

curl https://git.io/fisher --create-dirs -sLo ~/.config/fish/functions/fisher.fish

テーマのインストール

bobthefishをインストール
agnosterは、サブコマンドの補完時に表示がずれたため、bobthefishを使用している

fisher install oh-my-fish/theme-bobthefish

bobthefishの設定

promptをnew lineで実行するように変更

set -g theme_newline_cursor yes

gitのmasterブランチを表示

set -g theme_display_git_master_branch yes

カラースキーマを dracula と指定

set -g theme_color_scheme dracula

fontの関連で表示がおかしくなったため、powerline用のfontは使用しないように指定

set -g theme_powerline_fonts no

時刻を表示するとFontの都合でおかしくなったため、時刻を表示しないように設定

set -g theme_display_date no

コマンド実行時間の非表示

set -g theme_display_cmd_duration no

上記の環境変数を、shell起動時に有効になるように指定

string trim '
set -g theme_newline_cursor yes
set -g theme_display_git_master_branch yes
set -g theme_color_scheme dracula
set -g theme_powerline_fonts no
set -g theme_display_date no
set -g theme_display_cmd_duration no
' >> ~/.config/fish/config.fish

Fontの導入

以下のURLを参照し、[Myrica P]Font をWindows10へ導入します。

Hyperターミナルの導入

hyper install

以下のURLにアクセスして、hyperをinstall
https://hyper.is/

以下のpathに、hyperの設定ファイルが生成されており、これを編集します

  • Hyperのバージョンが2.x.x 台:C:\Users\<username>\.hyper.js
  • Hyperのバージョンが3.x.x 台:C:\Users\<username>\AppData\Roaming\Hyper\.hyper.js

hyper settings

shell のvalueをwsl.exeに変更

shellArgsに '~' を指定することにより、WSL起動時のDirectoryをhomedirに指定しています

shell: 'C:\\Windows\\System32\\wsl.exe',

...snip...

shellArgs: ['~'],

フォントサイズ。16,18あたりがちょうどよさそう

  fontSize: 18,

フォントファミリーの指定

  fontFamily: '"Myrica P"',

カーソルの点滅

  cursorBlink: true,

選択したらコピーする動作

  copyOnSelect: true,

pluginの指定

  plugins: [
    'hyper-iceberg',
    'hyper-opacity'
  ],

wsl上での設定

wsl.confを作成

uid,gidが1000のユーザー(defaultで作成されるユーザ)に対して、Windows側のファイルに対するアクセス権の設定を行う。
umask22を指定することで、書き込み権限を除外する

bashで実行する場合

cat <<'EOF' > /etc/wsl.conf
[automount]
enable = true
root = /mnt/
options = "metadata,uid=1000,gid=1000,umask=22"
EOF

fishで実行する場合 (ヒアドキュメントが存在しないので、代わりにstringコマンドで)

string trim '
[automount]
enable = true
root = /mnt/
options = "metadata,uid=1000,gid=1000,umask=22"
' >> /etc/wsl.conf

fish pluginの導入

fzf

Ctrl + Rでコマンド履歴を検索できるようになります。

# pluginのインストール
$ fisher add jethrokuan/fzf

# fzf本体のインストール
$ git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
$ ~/.fzf/install

参考URL

29
27
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
29
27