Skip to content
Advertisement

PuTTY: Linux window – How to update the window title during a function?

I’m accessing a Linux machine from a Windows 10 PC via PuTTY. I’ve set the PuTTY (Bash) window title to ‘$PWD’ by setting $PS1 as below:

JavaScript

This works well – whenever I change the directory in the shell, the title updates straight away:

Enter image description here

However, if I change directory in a function (as below) the title doesn’t update until after the function completes:

JavaScript

Enter image description here Enter image description here

Is there a way to get the title to update during the script?

ANSWER: Final version of the script:

JavaScript

Advertisement

Answer

You are changing the title by using PuTTY’s automatic title from the prompt. Unfortunately, the prompt will usually take effect once your prompt is visible again, which means not before your function or script ends.

If you want to change the title dynamically I would recommend this solution instead.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement