I would put something like this in my ~/.vimrc or a file with the .vim extension in ~/.vim/plugin/:
command! FW call FilterToNewWindow('myscript')
function! FilterToNewWindow(script)
let TempFile = tempname()
let SaveModified = &modified
exe 'w ' . TempFile
let &modified = SaveModified
exe 'split ' . TempFile
exe '%! ' . a:script
endfunction
Then you can just do ":FW
".
It might be a good idea to change the command definition to require a filter script name argument to pass to the function instead of "hard coding" it.
Each tmux pane is an interface for a single pty (pseudo tty). Non-split windows have a single pane; split windows have multiple panes.
tmux does not supply a way to add extra processes to a pane once it has been started with its initial command. It is up to that initial command’s process (usually a shell) to supply job control1 for that terminal.
If you want to clobber whatever is currently running in the pane, you can use respawn-pane -k
to kill the existing command and replace it with a new one (e.g., respawn-pane -t sessionname:0.4 -k 'some -new command'
).
But, if you want to maintain whatever is currently running in the pane, then there may be no better option that simply “typing at it” with send-keys
.
You might script it like this (attach last, because otherwise the script will just wait for you to detach before continuing):
session=whatever
window=${session}:0
pane=${window}.4
tmux send-keys -t "$pane" C-z 'some -new command' Enter
tmux select-pane -t "$pane"
tmux select-window -t "$window"
tmux attach-session -t "$session"
Note that, on the send-keys
command, you should actually type the letters
E n t e r,
to tell tmux
to send a newline key to the window.
(Naturally, every command ends with the Enter key.)
1Job control is the arbitration between multiple process groups of a single session that uses the tty as its controlling terminal. I.e., the Ctrl+Z suspend key, and the jobs
, fg
, and bg
shell commands.
Best Answer
You can read stdin