diff --git a/.config/wezterm/wezterm.lua b/.config/wezterm/wezterm.lua index cd0962e..aa03e89 100644 --- a/.config/wezterm/wezterm.lua +++ b/.config/wezterm/wezterm.lua @@ -52,6 +52,24 @@ end local is_server = wezterm.hostname() == "dln-dev" +wezterm.on("user-var-changed", function(window, pane, name, value) + wezterm.log_info("user-var-changed", name, value) + + if name == "nvim_activate" then + for _, t in ipairs(window:mux_window():tabs_with_info()) do + for _, p in ipairs(t.tab:panes()) do + if p:get_title() == "nvim" then + window:perform_action(act.ActivateTab(t.index), p) + if t.index > 0 then + window:perform_action(act.MoveTab(0), p) + end + end + end + end + -- window:perform_action(act.ActivateTab(0), pane) + end +end) + return { color_scheme = _get_scheme(), color_scheme_dirs = { "/home/dln/.config/wezterm" }, @@ -154,6 +172,9 @@ return { { key = "7", mods = "ALT", action = act({ ActivateTab = 6 }) }, { key = "8", mods = "ALT", action = act({ ActivateTab = 7 }) }, { key = "9", mods = "ALT", action = act({ ActivateTab = 8 }) }, + { key = "0", mods = "ALT", action = act({ ActivateTab = 9 }) }, + { key = "RightArrow", mods = "CTRL", action = act.ActivateTabRelative(1) }, + { key = "LeftArrow", mods = "CTRL", action = act.ActivateTabRelative(-1) }, }, unix_domains = { { diff --git a/.zshrc b/.zshrc index 43cb2f9..71995e5 100644 --- a/.zshrc +++ b/.zshrc @@ -105,7 +105,7 @@ export LESS="--mouse --wheel-lines=1 -nRXF" ## Aliases alias c='cut -c-${COLUMNS}' -alias e='tmux-edit-helper' +alias e='wezterm-edit-helper' alias dotgit='git --work-tree $HOME --git-dir $HOME/.dot_git' alias l=bat alias lw='bat --wrap=never' diff --git a/bin/tmux-edit-helper b/bin/wezterm-edit-helper similarity index 59% rename from bin/tmux-edit-helper rename to bin/wezterm-edit-helper index 1742e56..8b00b00 100755 --- a/bin/tmux-edit-helper +++ b/bin/wezterm-edit-helper @@ -14,11 +14,17 @@ else fre --store_name "$_store" --add "$_file" fi -tmux select-window -t nvim 2>/dev/null || - tmux new-window -S -n nvim \ - -e "BUILD_COMMAND=$BUILD_COMMAND" \ - -e "GOPACKAGESDRIVER=$GOPACKAGESDRIVER" \ - -e "GOFLAGS=$GOFLAGS" \ - nvim --listen "$XDG_RUNTIME_DIR/nvim.sock" +function _nvim_setenv() { + nvim --server "$XDG_RUNTIME_DIR/nvim.sock" --remote-expr "execute(\"let \$${1} = \\\"${2}\\\"\")" +} + +nvim --server "$XDG_RUNTIME_DIR/nvim.sock" --remote-expr "42" 2>/dev/null || + (wezterm cli spawn --cwd "${PWD}" nvim --listen "$XDG_RUNTIME_DIR/nvim.sock" && sleep 0.5) + +_nvim_setenv BUILD_COMMAND "$BUILD_COMMAND" +_nvim_setenv GOPACKAGESDRIVER "$GOPACKAGESDRIVER" +_nvim_setenv GOFLAGS "$GOFLAGS" nvim --server "$XDG_RUNTIME_DIR/nvim.sock" --remote "$_file" + +printf "\033]1337;SetUserVar=%s=%s\007" nvim_activate $(date +%s | base64)