0
4

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 3 years have passed since last update.

秋の dotfiles 大掃除【フォント、プロンプト編】

Last updated at Posted at 2020-10-30

今回はプログラミング用フォント Source Code Pro とプロンプトをカスタマイズする Stariship について紹介します。

環境

macOS Catalina 19.15.7
Rust 1.47.0(stable)
Starship 0.46.2

1. Source Code Pro(フォント)

Source Code Pro はAdobeがプログラミング用フォントとしてオープンソースで開発したフォントです。ソースコードが見やすいようにモノスペース(等幅)で、大文字のI(アイ)と小文字のl(エル)と数字の1(イチ)の判別がしやすく、また大文字のO(オー)と数字の0(ゼロ)の判別も容易となっています。
source-code-pro_regular

1.1 インストール

Source Code Proを追加するにはGitHubのフォントデータをダウンロードして手動でフォントを追加できますが、今回は以下のシェルスクリプトで追加します。

mkdir -p /tmp/source-code-pro
cd /tmp/source-code-pro

curl -LO https://github.com/adobe-fonts/source-code-pro/archive/release.zip
unzip release.zip

cp source-code-pro-release/TTF/* ~/Library/fonts/

cd /tmp
rm -rf source-code-pro

デフォルトでインストールされている Font Book.app でフォントが追加されたか確認できます。
font-book_app

2. Starship

Starishipはディレクトリやユーザ名などを表示するプロンプトをカスタマイズするツールで、gitのブランチやステータス、プログラミング言語のバージョンなどをおしゃれに表示できます。StarshipはさまざまなOS、シェルで高速で実行できます。
starship

2.1 インストール

macOSにStarshipをインストールする方法は3つあります。

  • Homebrewでインストールする
  • cargoでインストールする
  • ビルド済みのバイナリをインストールする

README.md によるとcargoやビルド済みのバイナリからStarshipをインストールすると最新のバージョンを利用することができます。

Homebrewでインストールする

HomebrewでStarshipをインストールする

brew install starship

cargo.ioからソースをインストールする

1. Rustの環境を構築する

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

2. Starshipをインストールする

cargo install starship 

ビルド済みのバイナリをインストールする

curl -fsSL https://starship.rs/install.sh | bash

2.2 Starshipを有効にする

fish shell を使っているので $HOME/.config/fish/config.fish に Starship を読み込ませるようにしています。他のシェルでの設定方法は README.md を参考してみてください。

$HOME/.config/fish/config.fish
starship init fish | source

2.3 Starshipの設定

~/.config/starship.toml
add_newline = false

[cmd_duration]
disabled = true

コマンドを実行したあとに改行が入ったり、実行時間が表示しないように add_newlinecmd_duration::disable の設定を変更しています。
他にも言語ごとにバージョンの表示やバッテリーの使用状況などを表示できるため、https://starship.rs/config/ を参考に自分好みのプロンプトにカスタマイズしてみましょう:rocket:


参考サイト

starship/README.md
🚀 プロンプトを超絶おしゃれにする Starship を紹介 - Qiita

0
4
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
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?