fresh2dev / zellij-autolock

autolock Zellij when certain processes open.
MIT License
38 stars 2 forks source link

Feature Request: Support sub-commands/arguments #4

Open HirschBerge opened 1 month ago

HirschBerge commented 1 month ago

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 commented 1 month ago

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.