Is there any function in C++ on Linux such as SetConsoleTitle(const) in Windows? Maybe there is any library includes the same or very similar functions.
Asked
Active
Viewed 2,741 times
0
-
I can't test it right now, but according to [Set screen-title from shellscript](https://stackoverflow.com/questions/1687642) it should work in the same way you would change the color. – t.niese Mar 01 '18 at 13:46
-
Yes and no. You will find a way on any Linux system running XWindow through XWindow primitives. But it is completely unrelated to Linux: you can find XWindow on non Linux system, and you can setup a Linux system with no XWindow server (it is common for servers). Anyway the common way is through [control sequences](http://tldp.org/HOWTO/Xterm-Title-3.html) processed by XTerm emulator and derivatives. – Serge Ballesta Mar 01 '18 at 13:51
1 Answers
4
For a console application (whether C++ or otherwise) you would typically use an escape sequence to set the console title. The docs are here:
So for a C++ app you might use something like:
std::cout << "\033]0;" << title << "\007";
This escape sequence will be interpreted by the shell and in tern the console app, and change the title accordingly.

gavinb
- 19,278
- 3
- 45
- 60