LoginSignup
14
11

More than 5 years have passed since last update.

MacBook に Docker と Hyper-Term と Fish-Shell を入れて開発環境を整える

Last updated at Posted at 2018-09-06

まえがき

新しいMBP買ったんですよ、13インチi7 2018版です(自慢)
これまでは Windows10 + WSL で シェル環境を使っていたのですが、いろいろと好き放題して何が入っているのかわからないような状況にしてしまったので、反省を込めて開発環境はDockerベース+見た目かっこいいシェルで構築しようと思います。
ターミナルは iTerm2 じゃなく Hyper + FishShell がナウいらしいので使っていきます。

やりたいこと

  • Docker で開発環境を構築する
  • ターミナルをいい感じにする

導入するもの

  • macOS High Sierra
    • 10.13.6(17G2208)
  • Docker Community Edition
    • 18.06.0-ce-mac70 (26399)
      • CentOS
        • AWS-CLI
        • Python3
  • ターミナル
    • Hyper 2.0.0
  • シェル
    • Fish

Docker 環境整備

Dockerfile を書く

~/work/dockerfile
FROM centos:latest
MAINTAINER saitotaks
LABEL version="1.0"

ARG pip_installer="https://bootstrap.pypa.io/get-pip.py"
ARG ius_repository="https://centos7.iuscommunity.org/ius-release.rpm"

# Install packages
RUN yum update -y  && \
    yum install -y python curl git groff

# Install aws-cli
RUN curl ${pip_installer} | python && \
    pip install awscli

# Install python3.6
RUN yum install -y ${ius_repository} && \
    yum install -y python36u python36u-libs python36u-devel python36u-pip

# Check versions
RUN aws --version && \
    python --version && \
    python3.6 --version

CentOSが必要だったのでpull

console
$ docker --version
Docker version 18.06.0-ce, build 0ffa825
$ docker pull centos:latest
...
Digest: sha256:b67d21dfe609ddacf404589e04631d90a342921e81c40aeaf3391f6717fa5322
Status: Image is up to date for centos:latest

Docker build して確認

console
$ docker build -t saitos .
Sending build context to Docker daemon  3.584kB
...

aws-cli/1.15.65 Python/2.7.5 Linux/4.9.93-linuxkit-aufs botocore/1.10.64
Python 2.7.5
Python 3.6.5
Removing intermediate container 4db9c5b2e008
 ---> e57077f745a2
Successfully built e57077f745a2
Successfully tagged saitos:latest

動作確認

console
$ docker run -it saitos /bin/bash
[root@04338d62a4bb /]# hostname
04338d62a4bb

Hyper インストール

https://hyper.is/
ここから DL してインストール

プラグインインストール

# マテリアルテーマ
hyper i hyper-material-theme
# 背景透過
hyper i hyper-transparent-bg  
# キー押したときにかっこいくなる
hyper i hyperpower
# 複数タブに同時にキー送れる
hyper i hyper-broadcast
# バッファに表示された文字列を検索できる
hyper i hyper-search
# フッターにステータス表示
hyper i hyper-statusline
# タブにアイコン表示
hyper i hyper-tab-icons-plus

Fish

Homebrew インストール

https://brew.sh/
手順通りインストール

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Fish

https://github.com/fish-shell/fish-shell
手順通りインストールして /etc/shells に追記

$ sudo sh -c "echo '/usr/local/bin/fish' >> /etc/shells"
$ tail /etc/shells
# Ftpd will not allow users to connect who are not using
# one of these shells.

/bin/bash
/bin/csh
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
/usr/local/bin/fish
$ fish -v
fish, version 2.7.1
$ # ターミナル変更、ログオフ必要
$ chsh -s /usr/local/bin/fish

Fisheram

Fish のプラグインマネージャです
https://github.com/fisherman/fisherman
手順通りインストール

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

Fishプラグインインストール

# 履歴で cd できるもの
$ fisher install # Dockerコマンド補完
$ fisher install docker-completion
# bobthefish テーマ
$ fisher install omf/theme-bobthefish
# テーマに必要な Powerline フォントをインストール
$ ./fonts/install.sh 
Copying fonts...
Powerline fonts installed to /Users/saitotak/Library/Fonts
# fish に文字コード指定してあげる必要がありましたecho "export LANG=ja_JP.UTF-8" >> ~/.config/fish/config.fish

~/.hyper.js
    // default font size in pixels for all tabs
    fontSize: 13,

    // font family with optional fallbacks
    //fontFamily: 'Menlo, "DejaVu Sans Mono", Consolas, "Lucida Console", monospace',
    fontFamily: '"Source Code Pro for Powerline"',

デフォルトターミナルをFishに設定

image.png

完成

できたー
image.png

参考

Hyperでイケてるターミナルをつかおう - Qiita
fish shell を使いたい人生だった | Developers.IO
Hyper と fish の環境構築をしてみたよ - OTOBANK Engineering Blog

14
11
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
14
11