Is there a "good" way to rename the terminal buffer in neovim?

I know that renaming is possible with the :file command, and that works fine for current session.

The problem with this approach is that it breaks :mksession. If you change the terminal window name with :file and save the session, upon restore it will no longer create a terminal window, but a regular file buffer instead.

I want to avoid this.


From :h terminal-start:

When the terminal starts, the buffer contents are updated and the buffer is named in the form of term://{cwd}//{pid}:{cmd}. This naming scheme is used by |:mksession| to restore a terminal buffer (by restarting the {cmd}).

Therefore you can not do this, unless you manually "swap" buffer names before :mksession and on autocmd SessionLoadPost. But I don't believe such oversophisticated scheme is worth.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.