Closed prabirshrestha closed 3 years ago
Regarding detection, wezterm
sets TERM_PROGRAM=WezTerm
in the environment.
For spawning a new tab, some of the plumbing exists in the multiplexer protocol, but it hasn't been exposed to the wezterm cli
subcommand as of yet, so some local changes to your config and some engineering would be required:
wezterm cli list
command will enumerate and show your windows/tabsIf you set up vim to emit OSC 7 for the directory containing the file when you eg: BufEnter
then spawning a new tab will use that directory.
actually this could be lot easier if wezterm supports subcommand to split.
silent call system('tmux split-window -h \; send-keys "cd ''' . l:dir . ''' && clear" C-m')
system
is a command to execute shell commands in vim.
Wezterm would need a sub command to open new tab, split tab horizontally or vertically and send keys.
wezterm split-tab -h \; send-keys "cd '/home'" && clear
@basbebe since I don't use those tools, I don't know what sorts of features should be prioritized. I'd appreciate it if you could identify the key things that would help unlock those workflows here in the wezterm issue tracker so that I can prioritize.
What I mean by that is: eg: tmux
has lots of functions and commands, so literally saying something like "more functions like tmux" doesn't help me figure out which are the top 5 (for example) functions that make it possible to enable a feature in some other tool, so I'd love concrete feedback on that!
Regarding this particular issue: the title talks about creating a tab, but the example was using panes. Current master (as of about a week ago) now supports running wezterm cli split-pane
even if you haven't explicitly configured a mux server, so that part of this issue is "done". split-pane
has parameters to set the current working directory (but inherits it from the pane that it is run in) and spawn a specific command.
@prabirshrestha what is left to do before you'd consider this closed?
@wez sorry for not being more specific.
kakoune
is an extensible modal texteditor that enables e.g. opening a new terminal pane or a REPL (or a fzf window or nnn or…) next to the editor. It doesn't do this within it's own window like vim but relies on the terminal or a multiplexer.
it therefore needs to open a new pane in the current window and execute a given command in it. It also offers the possibility to focus a given client (pane).
nnn
is a file manager which has a few plugins, one of which is called preview-tui.
Here, a new pane is being opened to run a script to show a preview of the currently selected item. When the new pane is being opened, the focus stays within the first pane.
So I think most of the needed functionality probably would now be there.
Panes were not supported when I filed this issue hence I mentioned new tabs. I personally prefer opening in new pane.
I will try this on weekend.
@wez wondering if you have instead thought of running lua script instead adding these new commands to console. This way instead of adding new commands you get the full lua api support.
$ wezterm --run "wezterm.newtab()"
Finally got time to work on this. Sent a pr to vim-gtfo at https://github.com/justinmk/vim-gtfo/pull/55.
I'm closing this for now.
Regarding detection, wezterm sets TERM_PROGRAM=WezTerm in the environment.
That does not work over ssh or in WSL without extra work and TERM is a special variable which is treated special by a lot of software. So this should only be used as a fallback and not by default.
How about we have wezterm set or otherwise update WSLENV to include something like TERM:TERM_PROGRAM:TERM_PROGRAM_VERSION
if it looks like it is running on windows or inside wsl?
I think that would be a good idea.
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
I use vim-gtfo which allows me to use
got
which opens a new terminal pane in the current directory of the file. Is there similar commands to detect and open tabs in wezterm. People use$TMUX
environment variable to detect it is running inside tmux and then usetmux split-window
. Would be good if wezterm has something similarwezterm split-window
.This feature might be better once https://github.com/wez/wezterm/issues/157 is implemented.