-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to set size of terminal for job with PTY #11476
Comments
You need a terminal to get the size of. A PTY is not a terminal, it's a way to connect sockets. You don't say why you are even trying to do this, perhaps if you say what you actually want to do someone can give you hints. |
Whoops, I must have gotten some terminology wrong. That was based on Neovim's help regarding PTYs, where you can set width and height "of the pty terminal" (https://neovim.io/doc/user/builtin.html#jobstart()):
Neovim seems to pull this off by calling Anyway, my goal is to be able to run a job in the background, save its output, and possibly write this output to a terminal buffer later on. Some commands (e.g. the Ninja build system) truncate lines of output depending on the width of the underlying terminal, and I was hoping to have such commands output lines that can fit in the terminal buffer I'm writing this output to. |
@cdelledonne So I think I just ran into exactly the same problem as you had described. So now both |
@nyngwang that's not correct, at least with Neovim v0.8.2 the settings of let g:out = []
let opts = {'pty': 1, 'on_stdout': {c, d, n -> add(g:out, d)}, 'width': 85, 'height': 25}
let job = jobstart(['./winsize.out'], opts)
call jobwait([job])
echomsg g:out You should get
|
@cdelledonne Yeah, I just confirmed it earlier today. But I tested it with API
Did you find any new insights on this part (after months later)? |
I suspect that the PTY master, managed by the terminal emulator, resets the job's size again when running a new command. That's why, when I want to control the width of the output, I do not launch a terminal emulator.
No new insights unfortunately. As I said, some programs rely on the width of the terminal to output properly formatted lines (for instance, I guess your |
Steps to reproduce
winsize.c
, it will be used to get the size of the terminal. Then compile the above C file, e.g.gcc winsize.c -o winsize.out
winsize.out
to obtain the PTY's sizeExpected behaviour
I would expect the
COLUMNS
environment variable to set the job PTY's width, as suggested in:help terminal-unix
. When I run./winsize.out
in a:terminal
, I get something likeVersion of Vim
9.0.720
Environment
tmux-256color
Logs and stack traces
No response
The text was updated successfully, but these errors were encountered: