So, I'm trying to find an actual solution to another question on here that doesn't really have one. However, I'm running into a problem with backgrounding/foregrounding behaviour.
I need to background any processes spawned from the shell inside the terminal. So far, I have the following assembled:
function! s:terminal_clear()
let l:scrollback = &scrollback
set scrollback=1
" Background any child-process. (No idea why <C-z> doesn't work.)
let l:children = systemlist('pgrep -P '.b:terminal_job_pid)
for pid in l:children[1:]
call jobstart(['kill', '-STOP', pid])
endfor
" Space at the start of the command, plus additional space-return, prevents this from being added
" to shell history. Requires `setopt histignorespace`.
call chansend(&channel, " printf '\\n%.0s' {1..200}\<CR> \<CR>")
call feedkeys("i\<C-l>")
sleep 1000m
for pid in l:children
call jobstart(['kill', '-CONT', pid])
endfor
exec "set scrollback=".l:scrollback
endfunction
Unfortunately, the for
-loop at the end, calling kill -CONT ...
on each backgrounded PID, isn't functioning.
I can resume the suspended processes manually, using fg
; but that's a bit of a nonstarter (doing so in the terminal-emulator-in-question, almost no matter what I do, leaves an fg
entry in the shell-history — completely defeating all the work I've been doing here in the first place to prevent precisely that.)
Does anybody know why kill -CONT
might not work on a process inside Vim's terminal emulator? What am I doing incorrectly, here?
HISTIGNORE
with value "fg" that command shouldn't be saved in your history. (Multiple commands can be added by separating them with:
, e.g.export HISTIGNORE=fg:bg
)