Open14

wezterm+vim環境構築ログ

あまたつあまたつ

メイン参考

https://qiita.com/sonarAIT/items/0571c869e5f9ab3be817

環境

macOS 14.3.1

weztermとvimのインストール

% homebrew install vim 
% homebrew install --cask wezterm

weztermの環境構築

システムのルートディレクトリに.wezterm.luaをつくる

% touch .wezterm.lua

vimのTab幅を4にする

.vimrcに記述する

set tabstop=4

基本的なvim操作

移動

  • h: 左へ移動
  • j: 下へ移動
  • k: 上へ移動
  • s: 右へ移動

削除

  • x: カーソル位置を削除
  • dd: 行の切り取り
    • p: 貼り付け

.wezterm.luaを書いていく

local wezterm = require 'wezterm'

local config = {}

if wezterm.config_builder then
  config = wezterm.config_builder()
end

-- カラースキームの設定
config.color_scheme = 'AdventureTime'

return config
  • 設定ファイルの取得
  • カラーの設定
あまたつあまたつ

weztermを背景透明化&デフォルト全画面表示&コマンド切り替え

-- 背景透過
config.window_background_opacity = 0.85

-- 最初からフルスクリーンで起動
local mux = wezterm.mux
wezterm.on("gui-startup", function(cmd)
    local tab, pane, window = mux.spawn_window(cmd or {})
    window:gui_window():toggle_fullscreen()
end)

-- ショートカットキー設定
local act = wezterm.action
config.keys = {
  -- Alt(Opt)+Shift+Fでフルスクリーン切り替え
  {
    key = 'f',
    mods = 'SHIFT|META',
    action = wezterm.action.ToggleFullScreen,
  },
}

  • wezterm.on("gui-startup", function(cmd)
    local tab, pane, window = mux.spawn_window(cmd or {})
    window:gui_window():toggle_fullscreen()
    end)

    • gui-startup: 起動時になんかする
    • mux.spawn_window(cmd or {}): 新たなwindowを構築する。tab,pane,windowをそれぞれ変数に割り当てる
    • window:gui_window():toggle_fullscreen(): 生成されたウィンドウのうちGUIウィンドウを取得して、フルスクリーンへ変換する
    • ショートカットキーはそのまま
あまたつあまたつ

タブとペイン分けのショートカットキー

-- ショートカットキー設定
local act=wezterm.action
config.leader = { key = ",", mods = "CTRL", timeout_milliseconds = 2000 }

config.keys={
	{
		key='f',
		mods='SHIFT|META',
		action=act.ToggleFullScreen,
	},
	{
		key='t',
		mods='SHIFT|CTRL',
		action=act.SpawnTab 'CurrentPaneDomain',
	},
	{
		key='/',
		mods='LEADER',
		action=act.SplitHorizontal {domain='CurrentPaneDomain'},
	},
	{
		key='%',
		mods='LEADER',
		action=act.SplitVertical {domain='CurrentPaneDomain'},
	},
	{
 		key = 'x',
  		mods = 'LEADER',
  		action = wezterm.action.CloseCurrentPane {confirm=false},
	},
    { key = 'h', mods = 'LEADER', action = act.ActivatePaneDirection 'Left' },
    { key = 'H', mods = 'LEADER', action = act.AdjustPaneSize{ 'Left', 1 } },
    { key = 'l', mods = 'LEADER', action = act.ActivatePaneDirection 'Right' },
    { key = 'L', mods = 'LEADER', action = act.AdjustPaneSize{ 'Right', 1 } },
    { key = 'k', mods = 'LEADER', action = act.ActivatePaneDirection 'Up' },
    { key = 'K', mods = 'LEADER', action = act.AdjustPaneSize{ 'Up', 1 } },
    { key = 'j', mods = 'LEADER', action = act.ActivatePaneDirection 'Down' },
    { key = 'J', mods = 'LEADER', action = act.AdjustPaneSize{ 'Down', 1 } },


LEADERをctrl+,に設定

  • ctrl+shift+t: 新規タブ作成
  • LEADER+/: 横に分割
  • LEADER+%: 縦に分割
  • LEADER+hjkl: 移動

ペインを削除するショートカット

{
  key = 'x',
  mods = 'LEADER',
  action = wezterm.action.CloseCurrentPane { confirm = false },
}
あまたつあまたつ

一旦全体.wezterm.lua

local wezterm=require 'wezterm'
local config ={}

if wezterm.config_builder then
    config=wezterm.config_builder()
end

config.color_scheme='AdventureTime'

config.window_background_opacity=0.85

local mux=wezterm.mux
wezterm.on("gui-startup",function(cmd)
	local tab,pane,window=mux.spawn_window(cmd or {})
	window:gui_window():toggle_fullscreen()
end)

local act=wezterm.action
config.keys={
	{
		key='f',
		mods='SHIFT|META',
		action=act.ToggleFullScreen,
	},
	{
		key='t',
		mods='SHIFT|CTRL',
		action=act.SpawnTab 'CurrentPaneDomain',
	},
	{
		key='d',
		mods='SHIFT|CTRL',
		action=act.SplitHorizontal {domain='CurrentPaneDomain'},
	},
	{
 		key = 'x',
  		mods = 'SHIFT|CTRL',
  		action = wezterm.action.CloseCurrentPane {confirm=false},
	},

}

config.font=wezterm.font("Monaspace Krypton")
config.font_size=16
return config
あまたつあまたつ

いい感じの見た目にしたい

メイン参考

https://zenn.dev/monicle/articles/59ff479ae51c66
zshのパッケージマネージャ antigenを使う
https://github.com/zsh-users/antigen?tab=readme-ov-file
インストール

% cd ~/.locl/bin
----------なかったら作ってね---------------------
% curl -L git.io/antigen > antigen.zsh

.zshrcに追記

source $HOME/.local/bin/antigen.zsh

# Load the oh-my-zsh's library
antigen use oh-my-zsh

antigen bundles <<EOBUNDLES
   # Bundles from the default repo (robbyrussell's oh-my-zsh)
   git
   # Syntax highlighting bundle.
   zsh-users/zsh-syntax-highlighting
   # Fish-like auto suggestions
   zsh-users/zsh-autosuggestions
   # Extra zsh completions
   zsh-users/zsh-completions
   # z
   rupa/z z.sh
   # abbr
   olets/zsh-abbr@main
EOBUNDLES

# Load the theme
antigen theme robbyrussell

# Tell antigen that you're done
antigen apply
あまたつあまたつ

こういうやつにしたい

% brew install starship
% touch ~/.config/starship.toml
% starship preset tokyo-night -o ~/.config/starship.toml
format = """
[░▒▓](#a3aed2)\
[  ](bg:#a3aed2 fg:#090c0c)\
[](bg:#769ff0 fg:#a3aed2)\
$directory\
[](fg:#769ff0 bg:#394260)\
$git_branch\
$git_status\
[](fg:#394260 bg:#212736)\
$nodejs\
$rust\
$golang\
$php\
[](fg:#212736 bg:#1d2230)\
$time\
[ ](fg:#1d2230)\
\n$character"""

[directory]
style = "fg:#e3e5e5 bg:#769ff0"
format = "[ $path ]($style)"
truncation_length = 3
truncation_symbol = "…/"

[directory.substitutions]
"Documents" = "󰈙 "
"Downloads" = " "
"Music" = " "
"Pictures" = " "

[git_branch]
symbol = ""
style = "bg:#394260"
format = '[[ $symbol $branch ](fg:#769ff0 bg:#394260)]($style)'

[git_status]
style = "bg:#394260"
format = '[[($all_status$ahead_behind )](fg:#769ff0 bg:#394260)]($style)'

[nodejs]
symbol = ""
style = "bg:#212736"
format = '[[ $symbol ($version) ](fg:#769ff0 bg:#212736)]($style)'

[rust]
symbol = ""
style = "bg:#212736"
format = '[[ $symbol ($version) ](fg:#769ff0 bg:#212736)]($style)'

[golang]
symbol = ""
style = "bg:#212736"
format = '[[ $symbol ($version) ](fg:#769ff0 bg:#212736)]($style)'

[php]
symbol = ""
style = "bg:#212736"
format = '[[ $symbol ($version) ](fg:#769ff0 bg:#212736)]($style)'

[time]
disabled = false
time_format = "%R" # Hour:Minute Format
style = "bg:#1d2230"
format = '[[  $time ](fg:#a0a9cb bg:#1d2230)]($style)'