I created a bash script that automatically populates a lua config file with ssh-mux settings according to my input. The populated config file looks like this:
ssh_domains.lua
local M = {}
M.ssh_domains = {
-- AUTO GENERATED BELOW THIS LINE
{
name = 'SSHMUX:server01',
remote_address = 'server01.brand.loc.p.company.com',
username = 'process',
remote_wezterm_path = "/home/process/test/user/repo-b/.local/bin/wezterm",
},
{
name = 'SSHMUX:server02',
remote_address = 'server02.company.com',
username = 'process',
remote_wezterm_path = "/home/process/test/user/repo-b/.local/bin/wezterm"
},
{
name = 'SSHMUX:server15',
remote_address = 'server15.company.com',
username = 'process',
remote_wezterm_path = "/home/process/test/user/repo-b/.local/bin/wezterm-bootstrap.bash"
},
{
name = 'SSHMUX:server16',
remote_address = 'server16.par.cz.t.company.com',
username = 'process',
remote_wezterm_path = "/home/user/test/user/repo-b/.local/bin/bootstrap-wezterm.bash"
},
}
return M
The settings are automatically inserted as a substituted heredoc with sed and not checked for syntactical correctness. It's brittle but it works.
However, now I wanted to implement the inverse logic that removes the respective configuration from the file. This is a lot more involved, since I would have to make even more assumptions and make it even more brittle.
That's why I was wondering if I could remove a whole config block (array element) in a more robust way by removing it from the abstract syntax tree directly. Could this be done with treesitter from a bash script?