Commit Graph

90 Commits

Author SHA1 Message Date
Yukai Huang
97a50a2352
pass pane-id to wezterm cli 2024-02-15 18:22:10 +08:00
Johannes Altmanninger
1ce639f2f9 rc windowing: with-option to restore option value also after error
Today "with-option foo bar command-that-fails" fails with

	Error: 1:1: 'evaluate-commands': 1:1: 'with-option': 2:5: 'evaluate-commands': 4:9: 'evaluate-commands': 1:2: 'no-such-command': no such command

but leaks the option value. Fix this by resetting the option and
rethrowing the error.  Unfortunately the original stack trace is lost
(questionable behavior inherited from C++?).
2023-12-16 12:13:20 +01:00
Johannes Altmanninger
746e0d032f rc windowing: allow to configure windowing system and window placement in new/terminal commands
Today I can control "terminal" and "new" by changing the terminal
alias but I always need to choose a concrete implementation, like
"tmux-terminal-horizontal", even when there is otherwise no need to
mention tmux in my config.

Allow to configure windowing system and window placement independently
by introducing dedicated options.

This allows to create mappings that work in any windowing system like

	map global user c   %{:with-option windowing_placement window new<ret>}
	map global user '"' %{:with-option windowing_placement vertical new<ret>}
	map global user '%' %{:with-option windowing_placement horizontal new<ret>}

For windowing systems that don't support all placements, you can wrap
the above in try/catch to fall back on the "window" variant which is
defined for all windowing systems.

When using multiple (nested) windowing systems, you might want to
add mappings like

	map global user t %{:with-option windowing_module tmux new<ret>}
	map global user T %{:with-option windowing_module wayland new<ret>}

---

This changes the default "terminal" alias for some modules. In
particular, instead of delegating to

    iterm-terminal-vertical
    screen-terminal-vertical
    tmux-terminal-horizontal
    wezterm-terminal-vertical

it will now by default delegate to the respective "-window" variant.
We could maintain backwards compatiblity here by setting the
"windowing_placement" option accordingly, but the new behavior seems
more logical?

Also, this removes the "terminal-tab" alias which was only defined
by the kitty module.

We could try to keep the alias approach and implement a "with-alias"
command, however that approach can only capture both dimensions
(windowing system and placement) if we add tons of commands
like "terminal-horizontal" (with implied windowing system) and
"tmux-terminal" (with implied placement).

Side thought: we could also get rid of the "focus" alias and instead
define

    define-command focus %{
        "%opt{windowing_module}-focus"
    }

Closes #3943, #4425
2023-11-13 22:54:49 +01:00
Johannes Altmanninger
e7218ca301 rc windowing: fix docstrings 2023-11-13 22:54:49 +01:00
Johannes Altmanninger
4258f2d7b2 rc windowing sway: add sway-terminal-tab
Not sure about this one, the implementation seems hacky so I'm not
sure if it always does what the user expects.
2023-11-13 22:54:49 +01:00
Johannes Altmanninger
efdc57cef7 rc windowing sway: add sway-terminal-{vertical/horizontal} 2023-11-13 22:54:49 +01:00
Bob Qi
117f12dbd6 pass cwd for wezterm terminal 2023-07-27 13:28:37 +08:00
Maxime Coste
4106791adc Fix windowing detection echoing last module error if none matched
Display a more general message in the debug buffer.
2023-06-13 17:08:42 +10:00
Bob Qi
365fe58826 fix arg quoting 2023-06-09 17:57:48 +08:00
Bob Qi
b64dce3e95 rc/windowing/wezterm.kak 2023-06-09 15:43:07 +08:00
Maxime Coste
e74424d889 Merge remote-tracking branch 'Frojdholm/rc-windowing-kitty-window-id' 2023-05-10 19:54:12 +10:00
Johannes Altmanninger
94e3ea9687 rc windowing wayland/x11: do not pollute terminal environment
The x11-terminal command spawns a potentially long-lived terminal
process. The terminal can is completely independent of the Kakoune
session that created it.
Due to how it's implemented, the spawned terminals will have
environment variables "kak_opt_termcmd" and  "kak_quoted_reg_a"
set.  This can be surprising, especially since, by convention, the
environment contains no lowercase variables. Let's stop exporting them.
2023-05-09 11:32:37 +02:00
Hampus Fröjdholm
7c54de2334 Match against kitty window id directly when using kitty @ launch
When launch matches using `id` kitty tries to match against tab id
before matching windows. When there are multiple tabs it's likely to
match a tab before matching a window.

Use `window_id` directly to avoid any possiblity of matching tabs.

This is only needed for `kitty @ launch` for other commands there is
no specific `window_id` field.
2023-05-07 17:06:09 +02:00
Maxime Coste
58ead47fb4 Merge remote-tracking branch 'krobelus/tmux' 2023-03-13 21:33:31 +11:00
Bob Qi
4f0334c476 add zellij-action command 2023-02-26 07:29:39 +08:00
Bob Qi
02bc786fb7 remove the option and provide session name explictly 2023-02-24 12:21:16 +08:00
Bob Qi
f33126c2a9 give up to wrap command into a shell to avoid conflict with connect.kak 2023-02-22 15:57:22 +08:00
Bob
4ff5de6273 Create zellij.kak 2023-02-22 13:17:04 +08:00
Marco Rebhan
5530f49c14 Deduplicate iterm2 escaping code
This fixes PATH and TMPDIR not being escaped in the iterm-terminal-window and
iterm-terminal-tab commands.
2022-11-20 14:00:34 +01:00
Marco Rebhan
c57805a926 Handle spawning iTerm and screen commands with arguments containing newlines
Before, sed would add quotes to every line of the single multiline argument,
causing the final quoted argument to "split ... command" or screen to contain
unquoted newlines such as this (from kakoune-cr):

	tell application "iTerm"
	    tell current session of current window
	        tell (split vertically with same profile command "env PATH='...' 'sh' '-c' ''
	'    export KAKOUNE_SESSION=$1'
	'    export KAKOUNE_CLIENT=$2'
	'    shift 3'
	''
	'    [ $# = 0 ] && set \"$SHELL\"'
	''
	'    \"sh\"'
	'  ' '--' '51909' 'client0' 'terminal' ") to select
	    end tell
	end tell

Instead of using sed to do this which operates on single lines at a time, simply
use printf to insert ' quotes before and after the entire argument.
2022-11-20 14:00:09 +01:00
Johannes Altmanninger
f69d8c3e12 rc repl tmux: always spawn repl in calling client
Just like the parent commit but for tmux-repl-* commands.

Note that tmux-repl-set-pane without arguments is kind of broken; it
increments the current pane ID, which only works in the most basic
scenarios. We should probably replace it with something better,
with menu completions etc.
2022-11-19 15:21:38 +01:00
Johannes Altmanninger
cfea884cf2 rc windowing tmux: always spawn tmux-terminal-window in calling client
The tmux-terminal-window command always spawns windows in the tmux
session where the Kakoune session was started - even if the calling
Kakoune client lives in a different tmux session.

Fix this by always creating the window in the tmux
session of the calling client. We already do the same for
tmux-terminal-{horizontal,vertical}.

I call tmux-terminal-impl with "new-window -a" (instead of
"new-window"), so make sure the fix works for my use case.

I considered retrieving the tmux session ID from the $TMUX environment
variable but the tmux manpage only specifies that $TMUX contains
"some internal data".
2022-11-19 15:21:38 +01:00
Johannes Altmanninger
37dcba9089 rc repl tmux: do not record repl session/window since pane might move
A pane's ID is immutable for the lifetime of the tmux server.
Same with window/session IDs.
When creating a new tmux repl, we record all three IDs to later use
them to send text to the repl.
The window/session IDs can be invalidating when a pane is moved to
a different window/session (via "tmux move-pane", "tmux move-window"
etc). This will cause repl-send-text to fail.
Fix this by dropping the redundant and potentially incorrect
window/session IDs.  The immutable pane ID is enough.
2022-11-19 15:21:38 +01:00
Johannes Altmanninger
9891f11157 rc repl tmux: remove bashisms 2022-11-19 15:21:38 +01:00
Johannes Altmanninger
79db90349d rc repl tmux: show error when the repl pane is gone
tmux-send-text would silently fail when the repl is no more.  Let's
instead print an error, pointing the user to the *debug* buffer which
has tmux' stderr.
2022-11-19 15:21:38 +01:00
Maxime Coste
e83dbdcd2c Merge remote-tracking branch 'krobelus/embrace-menu-2' 2022-07-28 21:34:31 +10:00
Maxime Coste
ab20fa9360 Merge remote-tracking branch 'krobelus/tmux-repl-completion' 2022-07-28 21:23:30 +10:00
Johannes Altmanninger
3e9ca0e5c3 rc windowing: use menu behavior for focus
We can complete every possible client argument.
2022-07-21 16:48:44 +02:00
Johannes Altmanninger
9190fa9b5f rc repl: complete tmux-repl with shell commands, not Kakoune commands 2022-07-21 16:48:44 +02:00
Jeroen de Haas
5a1b0ac2cb Also escape path and tmpdir in iterm.kak
This fixes an issue with where paths containing spaces would
break iterm support
2022-07-16 16:07:42 +02:00
DixiE
0048e9f488 Support focus Within Sway WM
While Wayland offers nothing general to help us support `focus` on all
window managers, WM-specific implementations are generally possible.
Sway is a tiling window manager that mimics i3, and has a reasonably
powerful CLI that can help us achieve this.

In addition to supporting `focus` for Sway, this change paves the way
for additional WM-specific Wayland functionality by adding a detection
step to wayland.kak, in a similar fashion to detection.kak.
2022-06-02 10:57:28 +01:00
Maxime Coste
7061001728 Add a complete-command command to configure command completion
This makes it possible to change command completion in hooks and
paves the way to more flexibility in how custom commands can be
completed
2022-03-06 10:13:14 +11:00
Maxime Coste
00080f8337 Remove explicit fail in new command
That fail prevents the real error message from being displayed
2022-01-24 21:41:43 +11:00
Maxime Coste
a361020632 Recognize foot as a wayland terminal 2022-01-24 21:16:45 +11:00
Maxime Coste
13eb5a677f Merge remote-tracking branch 'StatPal/master' into HEAD 2021-08-28 13:55:11 +10:00
Maxime Coste
b4c994c4ea Merge remote-tracking branch 'listentolist/x11-repl' into HEAD 2021-08-28 13:54:38 +10:00
Subrata
25ffbacb70 In the tmux-repl, it tackles the situations where there is already some other tmux pane open
and we want to send text (or do other works) in that specific pane.
2021-08-22 09:57:09 -05:00
Tilman List
0d74268451 add module dtach-repl 2021-08-21 18:42:29 +02:00
Maxime Coste
94388dc51e Merge remote-tracking branch 'alexherbo2/fix-typos' 2021-08-17 08:48:47 +10:00
Nulo
b13e0598e2
Spawn a shell when using xfce4-terminal
Previously, commands like repl broke because of this
2021-07-08 01:44:17 +00:00
Taupiqueur
3fe4367ce0 Fix windowing detection priority 2021-06-21 16:05:09 +02:00
Taupiqueur
ad1dc79789 Fix typos 2021-06-13 04:12:03 +02:00
Girish Kumar
95d224a21d fix: iterm focus client from different tab or window
currently focus client doesn't work if target pane of the client is in different tab or window from current one.
select window, select tab should be triggered in order to select a pane on a currently not focused tab or window.
2021-06-02 12:05:03 +05:30
eli
453cb7f367 Fix issue with tmux.kak setting empty TMPDIR variable 2021-04-24 17:59:13 +01:00
Johannes Altmanninger
3ab2b98ec3 rc: remove spurious tabs
This makes it easier to be consistent.

Also replace "<<-EOF" by "<<EOF", since the former only does trims
tabs, not spaces.
2021-04-17 20:56:23 +02:00
Maxime Coste
c507863a00 Merge remote-tracking branch 'Eluminae/wayland' 2021-03-23 21:50:27 +11:00
Reed Wade
feab20260a
Permit usage on wayland environments.
Some wayland wm will not setup a DISPLAY environment variable. Kakoune
should allow x11 windowing toolkit for those wm also.
2021-03-21 13:41:40 +01:00
basbebe
1183e716bc
make kitty repl command consistent with other kitty commands 2021-03-11 10:40:14 +01:00
basbebe
8d5d0d7d90
use kitty launch command, make commands consistent
`new-window` is a legacy command (see https://github.com/kovidgoyal/kitty/issues/2708).
`KITTY_WINDOW_ID` should be set for any kitty window anyways.
2021-03-11 10:36:30 +01:00
Maxime Coste
bdee3abd88 Match on kitty window id when available
This ensures new window are created in the same os window as the
current client instead of the default one.

Closes #4009
2021-03-01 08:47:09 +11:00