You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Similar to ActivatePaneDirection it would be awesome to have ActivatePaneOrWindowDirection - it is very handy when using multiple monitors and could be a killer feature in these situations.
Describe the solution you'd like
One option is to implement a bare minimum in wezterm and allow users to take it from there. See #3006 and lua config attached below.
The bare minimum:
gui_window:get_position() - allows finding window relative to the current, see find_window_direction function below
tab:get_pane_direction(direction) - gets pane in the given direction in the current tab or returns nil if there is none
Describe alternatives you've considered
I've tried to implement it in lua without changes to wezterm but it turns out we are not exposing enough API to do it.
Additional context
Here is screen recording of me using Ctrl-hjkl to navigate between windows.
And here is config:
localwezterm=require'wezterm'localact=wezterm.actionlocalos=require("os")
localfunctionactive_tab(window)
for_, tinpairs(window:tabs_with_info()) doift.is_activethenreturnt.tabendendendlocalfunctionfind_window_direction(window, direction)
localwx= {}
localp0=window:get_position()
localsz0=window:get_dimensions()
for_, winpairs(wezterm.mux.all_windows()) dolocalx=0localx0=0localp=w:gui_window():get_position()
localsz=w:gui_window():get_dimensions()
ifdirection=='Left' thenx=p.x+sz.pixel_widthx0=p0.xelseifdirection=='Right' thenx=p.xx0=p0.x+sz0.pixel_widthelseifdirection=='Up' thenx=p.y+sz.pixel_heightx0=p0.yelseifdirection=='Down' thenx=p.yx0=p0.y+sz0.pixel_heightendif (direction=='Left' ordirection=='Up') andx<x0thenwx[#wx+1] = { x0-x, w }
elseif (direction=='Right' ordirection=='Down') andx>x0thenwx[#wx+1] = { x-x0, w }
endendtable.sort(wx, function(a, b) returna[1] <b[1] end)
if#wx>0thenreturnwx[1][2]
endreturnnilend-- Nvim navigator implementation-- The usage of NVIM_LISTEN_ADDRESS is depricated see https://github.com/neovim/neovim/pull/11009-- see https://github.com/wez/wezterm/discussions/995-- see https://github.com/aca/wezterm.nvimlocalmove_around=function(window, pane, direction_wez, direction_nvim)
localresult=os.execute("env NVIM_LISTEN_ADDRESS=/tmp/nvim" ..pane:pane_id() .." wezterm.nvim.navigator " ..direction_nvim)
ifresultthenprint("vim window")
window:perform_action(wezterm.action({ SendString="\x17" ..direction_nvim }), pane)
elselocalt=pane:tab()
ifnottthen-- Debug panes do not have tabs :(t=active_tab(window:mux_window())
endift:get_pane_direction(direction_wez) thenprint("wez pane")
window:perform_action(wezterm.action({ ActivatePaneDirection=direction_wez }), pane)
elseprint("wez window")
localw=find_window_direction(window, direction_wez)
ifwthenprint("wez window focus")
w:gui_window():focus()
endendendendwezterm.on("move-left", function(window, pane)
move_around(window, pane, "Left", "h")
end)
wezterm.on("move-right", function(window, pane)
move_around(window, pane, "Right", "l")
end)
wezterm.on("move-up", function(window, pane)
move_around(window, pane, "Up", "k")
end)
wezterm.on("move-down", function(window, pane)
move_around(window, pane, "Down", "j")
end)
localfunctionwindow_index_from_tab_info(tab_info)
foridx, windowinpairs(wezterm.gui.gui_windows()) doiftab_info.window_id==window:window_id() thenreturnidx-- lua indices are 1-based, but we want 0-basedendendreturn0-- didn't find it, guess?endwezterm.on('format-window-title', function(tab, pane, tabs, panes, config)
localindex=window_index_from_tab_info(tab)
return"[" ..index.."] " ..tab.active_pane.titleend)
wezterm.on('open-uri', function(window, pane, uri)
print(uri)
localstart, match_end=uri:find'edit:'ifstart==1thenlocalfile_and_loc=uri:sub(match_end+1)
locali1=file_and_loc:find':'localfile=file_and_loc:sub(1, i1-1)
localloc=file_and_loc:sub(i1+1, file_and_loc:len())
locali2=loc:find':'localline=loc:sub(1, i2-1)
print(file, line)
for_, pinipairs(pane:tab():panes()) doprint("scanning", p:pane_id())
ifp:pane_id() ~=pane:pane_id() thenprint("sending keys")
p:send_text("\x1b")
p:send_text(string.format(":e +%s %s\n", line, file))
p:send_text("zz")
returnfalseendendreturnfalseendend)
return {
-- font = wezterm.font 'Fira Code',-- You can specify some parameters to influence the font selection;-- for example, this selects a Bold, Italic font variant.enable_tab_bar=true,
term="xterm-256color",
font=wezterm.font('JetBrainsMono Nerd Font', { weight='Regular' }),
font_size=16,
leader= { key='Space', mods='CTRL', timeout_milliseconds=1000 },
keys= {
{
key='s',
mods='LEADER',
action=wezterm.action.SplitVertical { domain='CurrentPaneDomain' },
},
{
key='v',
mods='LEADER',
action=wezterm.action.SplitHorizontal { domain='CurrentPaneDomain' },
},
{
key='g',
mods='LEADER',
action=wezterm.action.SpawnCommandInNewTab {
args= { 'lazygit' },
},
},
{
key='k',
mods='LEADER',
action=wezterm.action.CloseCurrentTab {
confirm=true,
},
},
{
key='c',
mods='LEADER',
action=act.SpawnTab'CurrentPaneDomain',
},
{
key='r',
mods='CMD|SHIFT',
action=wezterm.action.ReloadConfiguration,
},
{
key='1',
mods='CMD|ALT',
action=wezterm.action.ActivateWindow(0),
},
{
key='2',
mods='CMD|ALT',
action=wezterm.action.ActivateWindow(1),
},
{
key='3',
mods='CMD|ALT',
action=wezterm.action.ActivateWindow(2),
},
{
key='4',
mods='CMD|ALT',
action=wezterm.action.ActivateWindow(3),
},
{
key='5',
mods='CMD|ALT',
action=wezterm.action.ActivateWindow(4),
},
{ key="h", mods="CTRL", action=wezterm.action({ EmitEvent="move-left" }) },
{ key="l", mods="CTRL", action=wezterm.action({ EmitEvent="move-right" }) },
{ key="k", mods="CTRL", action=wezterm.action({ EmitEvent="move-up" }) },
{ key="j", mods="CTRL", action=wezterm.action({ EmitEvent="move-down" }) },
{
key='w',
mods='CTRL|SHIFT|ALT',
action=act.CloseCurrentPane { confirm=false },
},
},
color_scheme="Builtin Solarized Light",
-- window_decorations = "TITLE",hyperlink_rules= {
-- Linkify things that look like URLs and the host has a TLD name.-- Compiled-in default. Used if you don't specify any hyperlink_rules.
{
regex='\\S*:\\d+:\\d+\\b',
format='edit:$0',
},
-- Make task numbers clickable-- The first matched regex group is captured in $1.
{
regex=[[\b[tT](\d+)\b]],
format='https://example.com/tasks/?t=$1',
},
}
}
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
Similar to
ActivatePaneDirection
it would be awesome to haveActivatePaneOrWindowDirection
- it is very handy when using multiple monitors and could be a killer feature in these situations.Describe the solution you'd like
One option is to implement a bare minimum in wezterm and allow users to take it from there. See #3006 and lua config attached below.
The bare minimum:
gui_window:get_position()
- allows finding window relative to the current, seefind_window_direction
function belowtab:get_pane_direction(direction)
- gets pane in the given direction in the current tab or returns nil if there is noneDescribe alternatives you've considered
I've tried to implement it in lua without changes to wezterm but it turns out we are not exposing enough API to do it.
Additional context
Here is screen recording of me using
Ctrl-hjkl
to navigate between windows.And here is config:
The text was updated successfully, but these errors were encountered: