Skip to content

Instantly share code, notes, and snippets.

@tamago324
Last active March 22, 2026 12:56
Show Gist options
  • Select an option

  • Save tamago324/46d8704a52afc2b70746bfff4addce20 to your computer and use it in GitHub Desktop.

Select an option

Save tamago324/46d8704a52afc2b70746bfff4addce20 to your computer and use it in GitHub Desktop.
wezterm の設定
local wezterm = require("wezterm")
local config = wezterm.config_builder()
local act = wezterm.action
-- wsl のパスに変換
local function windows_to_wsl_path(path)
local drive, rest = path:match("^([A-Za-z]):[\\/](.+)$")
if not drive then
return path
end
return "/mnt/" .. drive:lower() .. "/" .. rest:gsub("\\", "/")
end
-- クリップボードのイメージを貼り付ける
local function save_clipboard_image(window, pane)
local script = [[
$ErrorActionPreference = 'Stop'
$tempDir = Join-Path ([Environment]::GetFolderPath('LocalApplicationData')) 'Temp'
$tempDir = [System.IO.Path]::GetFullPath($tempDir)
$stamp = Get-Date -Format 'yyyy-MM-dd-HH-mm-ss-fff'
$path = Join-Path $tempDir ($stamp + '-image.png')
$dir = Split-Path -Parent $path
New-Item -ItemType Directory -Force -Path $dir | Out-Null
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
if (-not [System.Windows.Forms.Clipboard]::ContainsImage()) {
Write-Error 'Clipboard does not contain an image.'
exit 1
}
$image = [System.Windows.Forms.Clipboard]::GetImage()
$image.Save($path, [System.Drawing.Imaging.ImageFormat]::Png)
Write-Output $path
]]
local success, stdout, _ = wezterm.run_child_process({
"powershell.exe",
"-NoProfile",
"-Sta",
"-Command",
script,
})
local path = stdout:match("([^\r\n]+)%s*$") or ""
local wsl_path = windows_to_wsl_path(path)
if success then
window:toast_notification("WezTerm", "Saved clipboard image to " .. wsl_path, nil, 4000)
window:perform_action(act.SendString(wsl_path), pane)
return
end
window:toast_notification("WezTerm", "Clipboard image save failed; see logs", nil, 6000)
end
config.font = wezterm.font("Cica")
config.font_size = 12
config.color_scheme = "Catppuccin Mocha"
config.scrollback_lines = 10000
config.window_background_opacity = 0.90
config.front_end = "WebGpu"
-- タブは必要な時だけ表示する
config.enable_tab_bar = true
-- config.hide_tab_bar_if_only_one_tab = true
-- タイトルバーを薄くする
-- window_decorations = "RESIZE"
config.default_domain = "WSL:Ubuntu"
-- config.wsl_domains = {
-- {
-- name = "WSL:Ubuntu",
-- distribution = "Ubuntu",
-- default_cwd = "~",
-- },
-- }
-- 初期サイズを調整
config.initial_cols = 140
config.initial_rows = 36
-- 周りの隙間を無くす
config.window_padding = {
left = 0,
right = 0,
top = 0,
bottom = 0,
}
-- タブバーの+を消す
config.show_new_tab_button_in_tab_bar = false
-- -- タブがーを透明にする
-- config.use_fancy_tab_bar = false
-- config.colors = {
-- tab_bar = {
-- background = "none",
-- },
-- }
-- config.window_background_gradient = {
-- colors = { "#000000" },
-- }
config.tab_bar_at_bottom = true
-------------------------
-- keymap
-------------------------
config.leader = { key = "g", mods = "CTRL", timeout_milliseconds = 500 }
config.keys = {
-- 新しいタブを開く (Ctrl+Shift+T)
-- https://github.com/wezterm/wezterm/issues/5902
{
key = "T",
mods = "CTRL|SHIFT",
action = act.SpawnCommandInNewTab({
domain = { DomainName = "WSL:Ubuntu" },
cwd = "~",
}),
},
-- 縦分割 (Ctrl+Shift+V)
{
key = "v",
mods = "CTRL|SHIFT",
action = act.SplitHorizontal({ domain = "CurrentPaneDomain" }),
},
-- 横分割 (Ctrl+Shift+S)
{
key = "s",
mods = "CTRL|SHIFT",
action = act.SplitVertical({ domain = "CurrentPaneDomain" }),
},
-- コピーモードは、デフォルトで Ctrl+Shift+X
{
-- ペースト
key = "p",
mods = "LEADER",
action = act.PasteFrom("Clipboard"),
},
-- クリップボードの画像を temp に保存
{
key = "i",
mods = "LEADER",
action = wezterm.action_callback(function(window, pane)
save_clipboard_image(window, pane)
end),
},
-- パネルの最大化
{
key = "Enter",
mods = "LEADER",
action = act.TogglePaneZoomState,
},
-- パネルの入れ替え
{
key = "s",
mods = "LEADER",
action = act.PaneSelect({
mode = "SwapWithActive",
}),
},
-- Leader + h で左のペインへ
{
key = "h",
mods = "ALT",
action = act.ActivatePaneDirection("Left"),
},
-- Leader + l で右のペインへ
{
key = "l",
mods = "ALT",
action = act.ActivatePaneDirection("Right"),
},
-- Leader + k で上のペインへ
{
key = "k",
mods = "ALT",
action = act.ActivatePaneDirection("Up"),
},
-- Leader + j で下のペインへ
{
key = "j",
mods = "ALT",
action = act.ActivatePaneDirection("Down"),
},
-- Alt + LeftArrow で左に広げる
{
key = "LeftArrow",
mods = "ALT",
action = act.AdjustPaneSize({ "Left", 5 }),
},
-- Alt + RightArrow で右に広げる
{
key = "RightArrow",
mods = "ALT",
action = act.AdjustPaneSize({ "Right", 5 }),
},
-- Alt + UpArrow で上に広げる
{
key = "UpArrow",
mods = "ALT",
action = act.AdjustPaneSize({ "Up", 5 }),
},
-- Alt + DownArrow で下に広げる
{
key = "DownArrow",
mods = "ALT",
action = act.AdjustPaneSize({ "Down", 5 }),
},
{
key = "l",
mods = "LEADER",
action = wezterm.action_callback(function(window, pane)
wezterm.log_info(pane:get_foreground_process_info())
end),
},
}
return config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment