Modify Title in REPL window

Is it possible to change the title of the REPL window (in case it is a standalone window)?
Something equivalent to the command to set the title of an Blink-Electron-Window:

using Blink

hdl_win = Window();
title(hdl_win, "Hello World!")

EDIT: this works for me (well I don’t have Windows to test tat part):

change_title(title) = Sys.iswindows() ? run(`cmd /C 'title '"$str_shell_title"`) : print("\033]0;$title\007")

No, there’s seemingly nothing, portable, that works. At least this didn’t work for me:

kde plasma - Renaming a Konsole session from commandline after ssh - Stack Overflow

You can use XTerm escape sequences to change the title via:

remotehost $ echo -ne "\033]0;Custom Window Title\007"

You can also change the individual tab title via:

remotehost $ echo -ne “\033]30;Custom Tab Title\007”

Neither [EDIT: at first, then only one] worked for me, but you can try. It seems by design:

GNOME Terminal 3.16.2 says Option "--title" is no longer supported in this version of gnome-terminal.

I wasn’t really expecting to be able to change the title, since terminals are ancient stuff, from when there was a screen and not title, and even before that on paper. But yes, of course since then extended capabilities, but then this one dropped.

For me, the title shows useful stuff, e.g. machine and directory I’m at, so I think it’s by design to no allow overwriting it, also not too misleading the user, might be a security issue. I’m not sure it should be under program control rather than the terminal (or the user). If it’s important to you you could install an alternative terminal, e.g. just an older version.

I’m running Linux Mint (Ubuntu, and most other Linux, and I guess macOS should be similar). Historically Windows had different terminal windows, or called them console. The do now have XTerm. You could try, please tell me if it works for you, and which terminal (on Windows) you use then.

What you could do if it’s not just important for you but your users, is e.g. using Blink and somehow get a terminal/REPL into it, it’s seems like a lot of work, but not impossible. Then “your” terminal wouldn’t change, rather a new one would pop up. This would however neither be fully portable, e.g. when I log in remotely I expect a terminal, and not that it can open a GUI windows on my local machine. That most likely would try to run it on the remote machine. Now that’s a solved problem with XWindows, for Linux/Unix, but (likely) wouldn’t work out of the box for Windows and macOS…

1 Like

Thanks for the answer!
Currently I am running 5 REPL in parallel, on each long-lasting operations.
It would be nice to put some information on the top of these windows.
My OS are Kubuntu and MS Windows.

So did this work for you (in Kubuntu)? I think just print("\033]30;Custom Tab Title\007"); [in case of Windows].

For Windows and running in Julia from CMD/PowerShell/Windows-Terminal this works:

julia> run(`cmd /C 'title Some new title'`)

Thanks oheil,

this works fine on windows! Do you have a suggestion how to make it dynamic?
e.g. something similar:

str_shell_title = "New Title"
run(`cmd /C 'title ' * str_shell_title `)
run(`cmd /C 'title '"$str_shell_title"`)
1 Like

Cool, I experiment now for more than 30 min with different combinations of \$ \$\( Cmd(…) …
Thanks :slight_smile:

For Linux/Unix alike it’s a bit complicated as it depends on shell and terminal emulation. Which type of shell are you using?
I assume bash as this is most common, am I right?
In your Julia window, what do you see as title?
When you exit Julia with exit() is the window closed or are you at the shell prompt?
And if it is a shell prompt, what title do you see now?
(I don’t have a kubuntu at hand right now)

Probably those didn’t work, because bash is overwriting it instantly again with what is defined for the command prompt. You can check in bash, by switching this temporarily off with setting a minimal prompt:

PS1='$ '

Now you may be able to change the title with:

echo -ne "\033]0;Custom Window Title\007"

And another variable (in bash) which interferes is PROMPT_COMMAND. Setting this changes the title too, but is also overwritten if PS1 is set to change the title.
This may work for a test:

PS1='$ '
PROMPT_COMMAND='echo -ne "\033]0;NEW TITLE\007"'


PS1='$ '
echo -ne "\033]0;NEW TITLE\007"
1 Like

Yes, worked for me! Wow, of course bsh needs to update the title somehow, since it included the path (in hindsight obvious) and either my eyesight wasn’t fast enough :slight_smile: or the terminal just that much faster. I suppose not instant, while I could never see it blink.

It’s best to not mess with that one, since you wanted this in the REPL anyway, and then when you exit you get your old prompt. Also setting any ENV in the Julia REPL wouldn’t do anything (unless you then invoke e.g. bash, and when you exit those ENVs would be destroyed. Also you don’t want to rely on bas or other shell like PowerShell.

Feel free to make a package with this one line:

change_title(title) = Sys.iswindows() ? run(`cmd /C 'title '"$str_shell_title"`) : print("\033]0;$title\007")

For me at least now this (and echo in shell) changes the window title (as documented), but also the tab title, but the echo for tab title (or documented for) changes neither, so I strike it out in my original answer).

1 Like

These are only tests, to see why echo-ing doesn’t change the title.

It’s not visible, there is no blink or a short change to new and back again.

1 Like

Currently I am not in front of my private linux PC, therefore, the test on linux has to wait.
Does the solution for MAC OS looks the same as for linux?
Is there also a chance to figure out, if the function is called from either within VScode-Editor or VScode-REPL?

Yup, this works on Mac:

change_title(title) = print("\033]0;$title\007")

On linux it seems to be tricky. In the terminal emulator “Xfce Terminal” it works, but in the default terminal emulator of Kubuntu “Konsole” it fails :frowning:

You have to enable custom titles with
SettingsConfigure Konsole... → General → Show window title on the titlebar.