r/neovim•
opensrc0

termopen: how to set terminal buffer name?

Anyone knows whether there is a way to set terminal buffer name when calling termopen function? We have a use case of using vifm as a file picker inside nvim. Given various options provided, the default terminal buffer name created by nvim becomes very long. Also, it is visible on screen, so I would like to avoid it by changing the buffer name to something more meaningful.

Anyone knows how to do it with the termopen call? Alternatively, we tried to use :file to change the name afterwards, yet the :file command would create a unlisted buffer to hold the cumbersome buffer name.

Posted Nov 1, 2018, 5:03 PM UTC

74
sylvain_soliman•

I don't think it is possible to change the name afterwards, OTOH you can :e term://foo where foo is a script somewhere on your PATH that will call vifm (whatever that is) with all options you need, and then only term://.//PID//foo should be used as name.

Sorry, that's the best I got. HTH.

1
I60R•

I too have this use case in application which uses neovims buffer as a pager. It sets buffer name through msgpack-api which seems like uses :file command behind and this surprisingly creates problems on non-term buffers.

Maybe we should create a feature request for that?

1
opensrc0OP•

I did a little more research. The neovim design is to have the buffer name "roundtrippable and safe", so a session can recover the terminal buffer if needed: https://github.com/neovim/neovim/pull/3181.

Maybe a local variable can be used to store the command information, and give user an option to set terminal names.

2
I60R•

I'd prefer using the buffer alias feature which was mentioned in the thread. Current workaround works only for :term buffer and feels like a hack for me.

1