zellij-autolock icon indicating copy to clipboard operation
zellij-autolock copied to clipboard

Feature Request: Support sub-commands/arguments

Open HirschBerge opened this issue 1 year ago • 2 comments

I'm not sure if this is a feature request or I just need help understanding the best way to set up a capture for my usecase.

I have a layout for rust development that has

pane command="nix" size="60%" {
   args "develop" "-c" "v" "src/main.rs"
}

i use a Nix flake, so my command is just nix develop -c v src/main.rs where 'v' is my custom build of neovim. Running the command directly locks just as expected, and everything is great. Obviously, i'd like to use zellij layouts to their full potential. Adding "nix" to my watchlist locks, but I also have nix develop -c bacon run and nix develop -c bacon clippy in my layout and, I don't want them captured. Is there something I'm missing, or is this possible to implement?

HirschBerge avatar Jul 13 '24 04:07 HirschBerge

I look at quick look at the code, and it might be possible to add an option for watch_argument or something of the like, and instead of comparing to just the command in the first column after terminal_0 you could apply the same logic to each subsequent columns as well?

For debugging purposes, here is the output of zellij action list-clients from

File: ~/layout.log # This is where it's broken
Size: 95 B
CLIENT_ID ZELLIJ_PANE_ID RUNNING_COMMAND
1         terminal_0     nix develop -c v src/main.rs

File:~/manual.log # This is where it works properly
CLIENT_ID ZELLIJ_PANE_ID RUNNING_COMMAND
1         terminal_0     /run/current-system/sw/bin/v -u /nix/store/8kmqwjfjp62x1820p8q0bwcjcpx09vs4-init.lua --cmd lua vim.g.loaded_node_provider=0;vim.g.loaded_perl_provider=0;vim.g.loaded_python_provider=0;vim.g.python3_host_prog='/nix/store/mjgv4wh4kvia6sn9rpwj4fym0v4j5ic5-neov
im-0.10.0/bin/myNixModuleNvim-python3';vim.g.ruby_host_prog='/nix/store/mjgv4wh4kvia6sn9rpwj4fym0v4j5ic5-neovim-0.10.0/bin/myNixModuleNvim-ruby';vim.g[ [[nixCats-special-rtp-entry-nvimLuaEnv]] ] = [[/nix/store/2p94fz12hid7yl59v1zs6c2brg44y5lw-luajit-2.1.1713773202-env]] --cmd set p
ackpath^=/nix/store/f7r8krbw3c016vppx7r1q7cbkcsml8qa-vim-pack-dir --cmd set rtp^=/nix/store/f7r8krbw3c016vppx7r1q7cbkcsml8qa-vim-pack-dir --cmd lua vim.g[ [[nixCats-special-rtp-entry-vimPackDir]] ] = [[/nix/store/f7r8krbw3c016vppx7r1q7cbkcsml8qa-vim-pack-dir]] src/main.rs
# Ignore all the gibberish after the first column

For the timebeing, i've simply put my command into a small shellscript wrapper and that works just fine, so there is absolutely zero rust to respond.

HirschBerge avatar Jul 13 '24 04:07 HirschBerge

Yeah, this is a limitation I'm willing to accept for now. Thanks for sharing the workaround of using a shell script.

I would accept an implementation that used the existing trigger syntax, e.g.:

triggers "nvim|vim|nix develop -c v|nix develop -c nv"

fresh2dev avatar Sep 17 '24 03:09 fresh2dev

Just published v0.2.0 of this plugin which takes advantage of the new Zellij API enhancements. You should be able to achieve the desired behavior by specifying this plugins triggers like so:

triggers "nvim|vim|nix develop -c v|nix develop -c nv"

Please update and confirm.

fresh2dev avatar Nov 07 '24 23:11 fresh2dev

Hello! I've updated and tried adding the suggested trigger and this does not work. I have tried matching identically for nix develop -c v src/main.rs and just up through v I'm not too bummed, my workaround is perfectly fine for me for now. I am seeing the same thing when i run zellij action list-clients FWIW

HirschBerge avatar Nov 08 '24 00:11 HirschBerge

Hmmm, thanks for trying. I tested with nano README.md and it had the desired effect. If you enable print_to_log and view the Zellij log, it should contain the full commands observed by this plugin, which you can use to populate the set of triggers.

fresh2dev avatar Nov 08 '24 00:11 fresh2dev