Fresh take on using wezterm without tmux for remote dev
This commit is contained in:
parent
64cb98db3c
commit
b9779d4df4
8 changed files with 280 additions and 138 deletions
|
@ -1,5 +1,4 @@
|
|||
alias e='tmux-edit-helper'
|
||||
alias eh='tmux-edit-history'
|
||||
alias e='wezterm-edit-helper'
|
||||
alias dotgit='git --work-tree $HOME --git-dir $HOME/.dot_git'
|
||||
alias git='git-branchless wrap --'
|
||||
alias l='bat --wrap=never --pager="less -S"'
|
||||
|
|
|
@ -2,10 +2,89 @@ local wezterm = require("wezterm")
|
|||
local mux = wezterm.mux
|
||||
local act = wezterm.action
|
||||
|
||||
local dev_host = "dln-dev"
|
||||
local spawn_dev_nvim = { "ssh", dev_host, "nvim", "--listen", os.getenv("XDG_RUNTIME_DIR") .. "/nvim-persistent.sock" }
|
||||
local config = {}
|
||||
|
||||
wezterm.add_to_config_reload_watch_list(os.getenv("HOME") .. "/.config/shelman-theme/current/wezterm")
|
||||
-- ------------------------------------------------------------------------------------
|
||||
-- Workspace behavior
|
||||
|
||||
-- local nvim_args = { "nvim", "--listen", "$XDG_RUNTIME_DIR" .. "/nvim-persistent.sock" }
|
||||
local nvim_args = { "nvim", "--listen", os.getenv("XDG_RUNTIME_DIR") .. "/nvim-persistent.sock" }
|
||||
|
||||
config.exec_domains = {
|
||||
wezterm.exec_domain("dev", function(cmd)
|
||||
local wrapped = { "/usr/bin/ssh", "-t", "dev" }
|
||||
for _, arg in ipairs(cmd.args or { os.getenv("SHELL") }) do
|
||||
table.insert(wrapped, arg)
|
||||
end
|
||||
cmd.args = wrapped
|
||||
return cmd
|
||||
end),
|
||||
}
|
||||
|
||||
local function activate_nvim(window, pane)
|
||||
wezterm.log_info("nvim")
|
||||
for _, t in ipairs(window:mux_window():tabs_with_info()) do
|
||||
for _, p in ipairs(t.tab:panes()) do
|
||||
if p:get_title() == "nvim" or t.tab:get_title() == "nvim" then
|
||||
window:perform_action(
|
||||
act.Multiple({
|
||||
act.ActivateTab(t.index),
|
||||
act.MoveTab(0),
|
||||
}),
|
||||
pane
|
||||
)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local nvim_tab, nvim_pane, _ = window:mux_window():spawn_tab({ args = nvim_args })
|
||||
window:perform_action(act.MoveTab(0), nvim_pane)
|
||||
nvim_tab:set_title("nvim")
|
||||
end
|
||||
|
||||
local function activate_tab(title, index)
|
||||
return function(window, pane)
|
||||
wezterm.log_info(title)
|
||||
for _, t in ipairs(window:mux_window():tabs_with_info()) do
|
||||
if t.tab:get_title() == title then
|
||||
window:perform_action(
|
||||
act.Multiple({
|
||||
act.ActivateTab(t.index),
|
||||
act.MoveTab(index),
|
||||
}),
|
||||
pane
|
||||
)
|
||||
return
|
||||
end
|
||||
end
|
||||
local tab, _, _ = window:mux_window():spawn_tab({
|
||||
cwd = "~",
|
||||
})
|
||||
tab:set_title(title)
|
||||
window:perform_action(act.MoveTab(index), pane)
|
||||
end
|
||||
end
|
||||
|
||||
wezterm.on("activate-nvim", activate_nvim)
|
||||
wezterm.on("tab-2", activate_tab("t2", 1))
|
||||
wezterm.on("tab-3", activate_tab("t3", 2))
|
||||
wezterm.on("tab-4", activate_tab("t4", 3))
|
||||
wezterm.on("tab-5", activate_tab("t5", 4))
|
||||
wezterm.on("tab-6", activate_tab("t6", 5))
|
||||
wezterm.on("tab-7", activate_tab("t7", 6))
|
||||
wezterm.on("tab-8", activate_tab("t8", 7))
|
||||
wezterm.on("tab-9", activate_tab("t9", 8))
|
||||
wezterm.on("tab-10", activate_tab("t10", 9))
|
||||
|
||||
wezterm.on("user-var-changed", function(window, pane, name, _)
|
||||
if name == "nvim_activate" then
|
||||
activate_nvim(window, pane)
|
||||
end
|
||||
end)
|
||||
|
||||
-- ------------------------------------------------------------------------------------
|
||||
-- Appearance
|
||||
|
||||
local function scheme_for_appearance(appearance)
|
||||
if appearance:find("Dark") then
|
||||
|
@ -25,44 +104,21 @@ local function font_for_appearance(appearance)
|
|||
return wezterm.font({
|
||||
family = "IosevkaShelman Nerd Font",
|
||||
--weight = "Regular",
|
||||
--weight = "Regular",
|
||||
})
|
||||
end
|
||||
end
|
||||
config.color_scheme = scheme_for_appearance(wezterm.gui.get_appearance())
|
||||
|
||||
return {
|
||||
color_scheme = scheme_for_appearance(wezterm.gui.get_appearance()),
|
||||
font = font_for_appearance(wezterm.gui.get_appearance()),
|
||||
|
||||
font_rules = {
|
||||
-- ------------------------------------------------------------------------------------
|
||||
-- Fonts
|
||||
config.font = font_for_appearance(wezterm.gui.get_appearance())
|
||||
config.font_rules = {
|
||||
{
|
||||
italic = true,
|
||||
intensity = "Bold",
|
||||
reverse = false,
|
||||
font = wezterm.font("IosevkaShelman Nerd Font", { weight = "ExtraLight", italic = true }),
|
||||
-- font = wezterm.font("Iosevka Term Curly Slab", { weight = "Thin", italic = true }),
|
||||
|
||||
-- font = wezterm.font({ -- Normal text
|
||||
-- -- family = "Monaspace Radon",
|
||||
-- family = "Monaspace Argon",
|
||||
-- harfbuzz_features = {
|
||||
-- "calt",
|
||||
-- "liga",
|
||||
-- "dlig",
|
||||
-- "ss01",
|
||||
-- "ss02",
|
||||
-- "ss03",
|
||||
-- "ss04",
|
||||
-- "ss05",
|
||||
-- "ss06",
|
||||
-- "ss07",
|
||||
-- "ss08",
|
||||
-- },
|
||||
-- weight = "Regular",
|
||||
-- -- weight = "ExtraLight",
|
||||
-- stretch = "Normal",
|
||||
-- style = "Normal",
|
||||
-- }),
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -71,60 +127,95 @@ return {
|
|||
reverse = false,
|
||||
font = wezterm.font("IosevkaShelman Nerd Font", { weight = "Light", italic = true }),
|
||||
},
|
||||
},
|
||||
-- front_end = "WebGpu",
|
||||
-- webgpu_power_preference = "HighPerformance",
|
||||
front_end = "OpenGL",
|
||||
warn_about_missing_glyphs = false,
|
||||
bold_brightens_ansi_colors = false,
|
||||
-- allow_square_glyphs_to_overflow_width = "Never",
|
||||
font_size = 16,
|
||||
command_palette_font_size = 13.5,
|
||||
line_height = 1.0,
|
||||
initial_cols = 132,
|
||||
initial_rows = 45,
|
||||
use_resize_increments = true,
|
||||
adjust_window_size_when_changing_font_size = false,
|
||||
window_decorations = "RESIZE",
|
||||
window_padding = {
|
||||
left = 6,
|
||||
right = 6,
|
||||
}
|
||||
-- config.dpi = 192
|
||||
config.font_size = 15
|
||||
config.line_height = 1.0
|
||||
config.warn_about_missing_glyphs = false
|
||||
config.bold_brightens_ansi_colors = false
|
||||
config.unicode_version = 14
|
||||
|
||||
-- Config
|
||||
config.enable_wayland = true
|
||||
config.front_end = "WebGpu"
|
||||
config.webgpu_power_preference = "HighPerformance"
|
||||
config.term = "wezterm"
|
||||
config.check_for_updates = false
|
||||
|
||||
-- UI
|
||||
config.command_palette_font_size = 13.5
|
||||
config.initial_cols = 132
|
||||
config.initial_rows = 45
|
||||
config.status_update_interval = 100
|
||||
config.audible_bell = "Disabled"
|
||||
config.use_resize_increments = true
|
||||
config.adjust_window_size_when_changing_font_size = false
|
||||
config.window_decorations = "RESIZE"
|
||||
config.window_frame = {
|
||||
border_left_width = "4px",
|
||||
border_right_width = "4px",
|
||||
border_bottom_height = "4px",
|
||||
border_top_height = "4px",
|
||||
border_left_color = "#000000",
|
||||
border_right_color = "#000000",
|
||||
border_bottom_color = "#000000",
|
||||
border_top_color = "#000000",
|
||||
}
|
||||
config.window_padding = {
|
||||
left = 0,
|
||||
right = 0,
|
||||
top = 0,
|
||||
bottom = 0,
|
||||
},
|
||||
unicode_version = 14,
|
||||
default_cursor_style = "SteadyBlock",
|
||||
cursor_thickness = "6px",
|
||||
cursor_blink_rate = 700,
|
||||
hide_mouse_cursor_when_typing = false,
|
||||
underline_position = -9,
|
||||
underline_thickness = 1,
|
||||
enable_wayland = true,
|
||||
enable_tab_bar = false,
|
||||
tab_bar_at_bottom = true,
|
||||
use_fancy_tab_bar = false,
|
||||
show_tab_index_in_tab_bar = true,
|
||||
enable_scroll_bar = false,
|
||||
scrollback_lines = 5000,
|
||||
alternate_buffer_wheel_scroll_speed = 1,
|
||||
check_for_updates = false,
|
||||
status_update_interval = 100,
|
||||
audible_bell = "Disabled",
|
||||
term = "wezterm",
|
||||
disable_default_key_bindings = true,
|
||||
keys = {
|
||||
}
|
||||
|
||||
-- Tabs
|
||||
config.enable_tab_bar = false
|
||||
config.tab_bar_at_bottom = true
|
||||
config.use_fancy_tab_bar = false
|
||||
config.show_tab_index_in_tab_bar = true
|
||||
|
||||
-- Cursor
|
||||
config.default_cursor_style = "SteadyBlock"
|
||||
config.cursor_thickness = "6px"
|
||||
config.cursor_blink_rate = 700
|
||||
config.hide_mouse_cursor_when_typing = false
|
||||
config.underline_position = -9
|
||||
config.underline_thickness = 1
|
||||
|
||||
-- Scrolling
|
||||
config.enable_scroll_bar = false
|
||||
config.scrollback_lines = 5000
|
||||
config.alternate_buffer_wheel_scroll_speed = 1
|
||||
|
||||
-- Keys
|
||||
config.disable_default_key_bindings = true
|
||||
config.keys = {
|
||||
{ key = "c", mods = "ALT|SHIFT", action = act.CopyTo("ClipboardAndPrimarySelection") },
|
||||
{ key = "v", mods = "ALT|SHIFT", action = act.PasteFrom("Clipboard") },
|
||||
{ key = "0", mods = "CTRL", action = "ResetFontSize" },
|
||||
{ key = "-", mods = "CTRL", action = "DecreaseFontSize" },
|
||||
{ key = "=", mods = "CTRL", action = "IncreaseFontSize" },
|
||||
{ key = "Enter", mods = "ALT", action = "ToggleFullScreen" },
|
||||
{ key = "UpArrow", mods = "SHIFT", action = act.ScrollByLine(-1) },
|
||||
{ key = "DownArrow", mods = "SHIFT", action = act.ScrollByLine(1) },
|
||||
{ key = "PageUp", mods = "SHIFT", action = act.ScrollByPage(-0.5) },
|
||||
{ key = "PageDown", mods = "SHIFT", action = act.ScrollByPage(0.5) },
|
||||
},
|
||||
mouse_bindings = {
|
||||
{ key = "r", mods = "ALT", action = act.ReloadConfiguration },
|
||||
{ key = "o", mods = "ALT", action = act.ActivateCommandPalette },
|
||||
{ key = "Backspace", mods = "ALT", action = act.SwitchWorkspaceRelative(1) },
|
||||
{ key = "1", mods = "ALT", action = act.EmitEvent("activate-nvim") },
|
||||
{ key = "2", mods = "ALT", action = act.EmitEvent("tab-2") },
|
||||
{ key = "3", mods = "ALT", action = act.EmitEvent("tab-3") },
|
||||
{ key = "4", mods = "ALT", action = act.EmitEvent("tab-4") },
|
||||
{ key = "5", mods = "ALT", action = act.EmitEvent("tab-5") },
|
||||
{ key = "6", mods = "ALT", action = act.EmitEvent("tab-6") },
|
||||
{ key = "7", mods = "ALT", action = act.EmitEvent("tab-7") },
|
||||
{ key = "8", mods = "ALT", action = act.EmitEvent("tab-8") },
|
||||
{ key = "9", mods = "ALT", action = act.EmitEvent("tab-9") },
|
||||
{ key = "0", mods = "ALT", action = act.EmitEvent("tab-10") },
|
||||
}
|
||||
|
||||
-- Mouse
|
||||
config.mouse_bindings = {
|
||||
{
|
||||
event = { Down = { streak = 1, button = { WheelUp = 1 } } },
|
||||
mods = "SHIFT",
|
||||
|
@ -143,5 +234,6 @@ return {
|
|||
event = { Down = { streak = 1, button = { WheelDown = 1 } } },
|
||||
action = act.ScrollByPage(0.25),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return config
|
||||
|
|
10
.local/share/applications/wezterm-dev-secondary.desktop
Normal file
10
.local/share/applications/wezterm-dev-secondary.desktop
Normal file
|
@ -0,0 +1,10 @@
|
|||
[Desktop Entry]
|
||||
Name=wezterm-dev-secondary
|
||||
GenericName=wezterm-dev-secondary
|
||||
StartupWMClass=org.wezfurlong.wezterm-dev-secondary
|
||||
Type=Application
|
||||
TryExec=/usr/bin/wezterm
|
||||
Icon=org.wezfurlong.wezterm
|
||||
Terminal=false
|
||||
Categories=System;TerminalEmulator;
|
||||
Exec=/usr/bin/wezterm --config 'default_prog={"/usr/bin/fish"}' start --class=org.wezfurlong.wezterm-dev-secondary --domain=dev
|
10
.local/share/applications/wezterm-dev.desktop
Normal file
10
.local/share/applications/wezterm-dev.desktop
Normal file
|
@ -0,0 +1,10 @@
|
|||
[Desktop Entry]
|
||||
Name=wezterm-dev
|
||||
GenericName=wezterm-dev
|
||||
StartupWMClass=org.wezfurlong.wezterm-dev
|
||||
Type=Application
|
||||
TryExec=/usr/bin/wezterm
|
||||
Icon=org.wezfurlong.wezterm
|
||||
Terminal=false
|
||||
Categories=System;TerminalEmulator;
|
||||
Exec=/usr/bin/wezterm --config 'default_prog={"/usr/bin/fish"}' start --class=org.wezfurlong.wezterm-dev --domain=dev
|
|
@ -1,10 +0,0 @@
|
|||
[Desktop Entry]
|
||||
Name=wezterm-dln-dev-secondary
|
||||
GenericName=wezterm-dln-dev-secondary
|
||||
StartupWMClass=org.wezfurlong.wezterm-secondary
|
||||
Type=Application
|
||||
TryExec=/usr/bin/wezterm
|
||||
Icon=org.wezfurlong.wezterm
|
||||
Terminal=false
|
||||
Categories=System;TerminalEmulator;
|
||||
Exec=/usr/bin/wezterm --config 'default_prog={"ssh", "-tq", "dln-dev", "--", "tmux", "-u", "new", "-As1", "-t0"}' start --class=org.wezfurlong.wezterm-secondary
|
|
@ -1,10 +0,0 @@
|
|||
[Desktop Entry]
|
||||
Name=wezterm-dln-dev
|
||||
GenericName=wezterm-dln-dev
|
||||
StartupWMClass=org.wezfurlong.wezterm
|
||||
Type=Application
|
||||
TryExec=/usr/bin/wezterm
|
||||
Icon=org.wezfurlong.wezterm
|
||||
Terminal=false
|
||||
Categories=System;TerminalEmulator;
|
||||
Exec=/usr/bin/wezterm --config 'default_prog={"ssh", "-tq", "dln-dev", "--", "tmux", "-u", "new", "-As0", "-t0"}' start --class=wezterm-dln-dev
|
|
@ -12,6 +12,7 @@ Include ~/.ssh/private_config
|
|||
|
||||
Host 10.1.100.16
|
||||
Host dln-dev
|
||||
Host dev
|
||||
Hostname 10.1.100.16
|
||||
#Hostname aarn.shelman.io
|
||||
#Port 2022
|
||||
|
|
50
bin/wezterm-edit-helper
Executable file
50
bin/wezterm-edit-helper
Executable file
|
@ -0,0 +1,50 @@
|
|||
#!/usr/bin/env bash
|
||||
set -fe -o pipefail
|
||||
|
||||
eval "$(direnv export bash 2>/dev/null)"
|
||||
|
||||
PATH="$HOME/bin:$PATH"
|
||||
|
||||
if [ -n "$1" ]; then
|
||||
_file=$(readlink -f "$@")
|
||||
else
|
||||
FZF=${FZF:-"fzf-tmux -p 90%,50% -y 0 --layout=reverse"}
|
||||
_root=$(git rev-parse --show-toplevel 2>/dev/null || jj workspace root 2>/dev/null || pwd)
|
||||
_store=$(echo "$_root" | sha1sum | cut -d ' ' -f 1)
|
||||
_file=$( ( (fre --store_name "$_store" --sorted | xargs -n 100 ls -d 2>/dev/null || true) && fd --type f --hidden --follow --exclude .git --exclude .jj --ignore-file "${_root}/.gitignore" . "$_root") | cat -n | sort -k2 -k1n | uniq -f1 | sort -nk1,1 | cut -f2- | sed -e "s#^${_root}/##" | $FZF --no-sort)
|
||||
_file="${_root}/${_file}"
|
||||
fre --store_name "$_store" --add "$_file"
|
||||
fi
|
||||
|
||||
fre --store_name "edit-history" --add "$_file"
|
||||
|
||||
_nvim_socket="$XDG_RUNTIME_DIR/nvim-persistent.sock"
|
||||
|
||||
nvim --server "$_nvim_socket" --remote "$_file"
|
||||
|
||||
function _nvim_setenv() {
|
||||
nvim --server "$_nvim_socket" --remote-expr "execute(\"let \$${1} = \\\"${2}\\\"\")" 2>&1 >/dev/null
|
||||
}
|
||||
|
||||
_nvim_setenv AR "$AR"
|
||||
_nvim_setenv AS "$AS"
|
||||
_nvim_setenv BUILD_COMMAND "$BUILD_COMMAND"
|
||||
_nvim_setenv CC "$CC"
|
||||
_nvim_setenv CXX "$CXX"
|
||||
_nvim_setenv GOFLAGS "$GOFLAGS"
|
||||
_nvim_setenv GOPACKAGESDRIVER "$GOPACKAGESDRIVER"
|
||||
_nvim_setenv LC_ALL "$LC_ALL"
|
||||
_nvim_setenv LD "$LD"
|
||||
_nvim_setenv NM "$NM"
|
||||
_nvim_setenv NM "$NM"
|
||||
_nvim_setenv OBJCOPY "$OBJCOPY"
|
||||
_nvim_setenv OBJDUMP "$OBJDUMP"
|
||||
_nvim_setenv PATH "$PATH"
|
||||
_nvim_setenv RANLIB "$RANLIB"
|
||||
_nvim_setenv READELF "$READELF"
|
||||
_nvim_setenv RUST_SRC_PATH "$RUST_SRC_PATH"
|
||||
_nvim_setenv SIZE "$SIZE"
|
||||
_nvim_setenv STRIP "$STRIP"
|
||||
|
||||
# Wezterm: switch tab to nvim
|
||||
printf "\033]1337;SetUserVar=%s=%s\007" nvim_activate $(date +%s | base64)
|
Loading…
Reference in a new issue