MacデフォルトのTerminalからAlacrittyに乗り換える
概要
これまでMac純正のターミナルを使用していましたが、異なるMac間での設定の統一が面倒だと感じ、Alacrittyを導入してみました。
AlacrittyはRust製のターミナルエミュレータで、設定をyamlファイルに書くことができ、設定の共通化が用意です。
他にも動作が高速であったり、Cross Platformに対応していたり、True Colorを表示できるなど、多くの機能を兼ね備えております。
今回はその導入方法について、こちらにメモを残しておきます。
Alacrittyとは
Alacritty - A fast, cross-platform, OpenGL terminal emulator
Alacrittyとは、Rust製のターミナルエミュレータで
インストール方法
cargoやbrew (参考: alacritty — Homebrew Formulae)などでインストールできます。その他のインストール方法については、こちらをご覧ください。
cargo install alacritty # or brew install --cask alacritty
設定ファイル
Alacrittyは設定をyamlファイルで管理することができます。
設定ファイルは、以下の4つの箇所を探しにいくようです。
$XDG_CONFIG_HOME/alacritty/alacritty.yml
$XDG_CONFIG_HOME/alacritty.yml
$HOME/.config/alacritty/alacritty.yml
$HOME/.alacritty.yml
自分の環境では、~/.config/alacritty/
配下にalacritty.yml
ファイルを作成しました。
こちらのファイルを参考にしながら、以下のような設定を記述します。
テーマに関しては、eendroroy/alacritty-theme: Collection of Alacritty color schemesで提供されているHyperを使用しています。
※フォントは、yuru7/HackGenを使用しております。
window: padding: x: 1 y: 0 opacity: 0.99 scrolling: # consoleのlogを10000行まで保持 history: 10000 # Colors (Hyper) from https://github.com/eendroroy/alacritty-theme/blob/master/themes/hyper.yaml colors: # Default colors primary: # background: '0x000000' background: '0x1E2220' foreground: '0xffffff' cursor: text: '0xF81CE5' cursor: '0xffffff' # Normal colors normal: black: '0x000000' # red: '0xfe0100' red: '0xBC100D' green: '0x33ff00' yellow: '0xfeff00' blue: '0x0066ff' magenta: '0xcc00ff' cyan: '0x00ffff' white: '0xd0d0d0' # Bright colors bright: black: '0x808080' red: '0xfe0100' green: '0x33ff00' yellow: '0xfeff00' blue: '0x0066ff' magenta: '0xcc00ff' cyan: '0x00ffff' white: '0xFFFFFF' # Font font: size: 11 normal: family: 'HackGen35Nerd Console' style: Regular bold: family: 'HackGen35Nerd Console' style: Bold italic: family: 'HackGen35Nerd Console' style: Italic bold_italic: family: 'HackGen35Nerd Console' style: Bold Itali env: TERM: xterm-256color cursor: style: shape: Block
True Colorを表示できるようにする
[こちら]https://gist.github.com/andersevenrud/015e61af2fd264371032763d4ed965b6)を参考に、True Color表示できるようにします。
使用している環境でTrue Color表示ができているかを確認するには、以下を実行します。
True Color表示ができていない場合
できている場合
できていない場合は以下を実施します。
~/.config/alacritty/alacritty.yml
に以下を追記env: TERM: xterm-256color
(tmuxを使用する場合)
~/.tmux.conf
に以下を追記set -g default-terminal "tmux-256color" set -ag terminal-overrides ",xterm-256color:RGB"
(vimを使用する場合)
~/.vimrc
に以下を追記" You might have to force true color when using regular vim inside tmux as the " colorscheme can appear to be grayscale with "termguicolors" option enabled. if !has('gui_running') && &term =~ '^\%(screen\|tmux\)' let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum" let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum" endif syntax on set termguicolors " ここは個人の好きなテーマに書き換える colorscheme yourfavcolorscheme
設定した画面
設定した画面は上記のようになります。かなりいい感じの色合いになっていますね。
※ 自分はAlacrittyに加えて、Starshipも使用しています。Starshipについては以下の記事をご覧ください。
参考
- alacritty/alacritty: A cross-platform, OpenGL terminal emulator.
- eendroroy/alacritty-theme: Collection of Alacritty color schemes
- True Color (24-bit) and italics with alacritty + tmux + vim (neovim) · GitHub
- ターミナルエミュレータをAlacrittyに変えた - Qiita
- yuru7/HackGen: Hack と源柔ゴシックを合成したプログラミングフォント 白源 (はくげん/HackGen)