Created
March 10, 2026 11:29
-
-
Save megurock/2159048b8aa8ad810fc8f53bc56673d5 to your computer and use it in GitHub Desktop.
/.config/wezterm/wezterm.lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local wezterm = require('wezterm') | |
| local mux = wezterm.mux | |
| local config = {} | |
| if wezterm.config_builder then | |
| config = wezterm.config_builder() | |
| end | |
| -- プロジェクト・レイアウト設定を読み込み | |
| local projects = require('projects') | |
| local layouts = require('layouts') | |
| -- 起動時の処理 | |
| wezterm.on('gui-startup', function() | |
| local _, pane, _ = mux.spawn_window {} | |
| -- プロジェクトが 1 つだけならそのまま構築 | |
| if #projects == 1 then | |
| layouts[projects[1].layout or 'dev-3pane'](pane, projects[1]) | |
| return | |
| end | |
| -- 複数プロジェクトがある場合はメッセージを表示 | |
| pane:send_text('echo "プロジェクトを選択してください(Leader + p)"\n') | |
| end) | |
| -- プロジェクト選択キーバインド用のアクション | |
| local select_project_action = wezterm.action_callback(function(window, pane) | |
| local choices = {} | |
| for i, project in ipairs(projects) do | |
| table.insert(choices, { | |
| id = tostring(i), | |
| label = project.label .. ' (' .. project.cwd .. ')', | |
| }) | |
| end | |
| window:perform_action( | |
| wezterm.action.InputSelector { | |
| title = 'プロジェクトを選択', | |
| choices = choices, | |
| action = wezterm.action_callback(function(_, p, id, _) | |
| if id then | |
| local project = projects[tonumber(id)] | |
| layouts[project.layout or 'dev-3pane'](p, project) | |
| end | |
| end), | |
| }, | |
| pane | |
| ) | |
| end) | |
| -- カラースキーム設定 | |
| config.color_scheme = 'Tokyo Night' | |
| -- フォント設定 | |
| config.font = wezterm.font_with_fallback { | |
| 'Hack Nerd Font Mono', | |
| 'Hiragino Sans', | |
| } | |
| config.font_size = 16.0 | |
| -- ウィンドウの余白設定 | |
| config.window_padding = { | |
| left = 8, | |
| right = 8, | |
| top = 8, | |
| bottom = 8, | |
| } | |
| -- タブが 1 つのときは、タブバーを非表示 | |
| config.hide_tab_bar_if_only_one_tab = true | |
| -- ターミナルタイプの設定 | |
| config.term = 'wezterm' | |
| -- 終了確認ダイアログ | |
| config.window_close_confirmation = 'NeverPrompt' | |
| -- リーダーキーを Ctrl+Space に設定 | |
| config.leader = { key = ' ', mods = 'CTRL' } | |
| -- キーバインディング設定 | |
| config.keys = { | |
| { | |
| key = "h", | |
| mods = "CTRL", | |
| action = wezterm.action.ActivatePaneDirection("Left"), | |
| }, | |
| -- ウィンドウ分割 | |
| { | |
| key = 'v', | |
| mods = 'LEADER', | |
| action = wezterm.action.SplitPane { direction = 'Right' }, | |
| }, | |
| { | |
| key = 's', | |
| mods = 'LEADER', | |
| action = wezterm.action.SplitPane { direction = 'Down' }, | |
| }, | |
| { | |
| key = 'q', | |
| mods = 'LEADER', | |
| action = wezterm.action.CloseCurrentPane { confirm = false }, | |
| }, | |
| -- Shift + Enter をエスケープシーケンスとして送信(Claude Code の改行用) | |
| { | |
| key = "Return", | |
| mods = "SHIFT", | |
| action = wezterm.action.SendString("\x1b[13;2u"), | |
| }, | |
| -- ウィンドウ移動 | |
| { | |
| key = 'h', | |
| mods = 'LEADER', | |
| action = wezterm.action.ActivatePaneDirection("Left"), | |
| }, | |
| { | |
| key = 'j', | |
| mods = 'LEADER', | |
| action = wezterm.action.ActivatePaneDirection("Down"), | |
| }, | |
| { | |
| key = 'k', | |
| mods = 'LEADER', | |
| action = wezterm.action.ActivatePaneDirection("Up"), | |
| }, | |
| { | |
| key = 'l', | |
| mods = 'LEADER', | |
| action = wezterm.action.ActivatePaneDirection("Right"), | |
| }, | |
| -- プロジェクト選択 | |
| { | |
| key = 'p', | |
| mods = 'LEADER', | |
| action = select_project_action, | |
| }, | |
| } | |
| -- URL のハイパーリンク設定(デフォルトルール + ファイルパス) | |
| config.hyperlink_rules = wezterm.default_hyperlink_rules() | |
| -- Cmd+Click で URL を開く(macOS) | |
| config.mouse_bindings = { | |
| { | |
| event = { Up = { streak = 1, button = 'Left' } }, | |
| mods = 'CMD', | |
| action = wezterm.action.OpenLinkAtMouseCursor, | |
| }, | |
| } | |
| return config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment