p-e-w / argos

Create GNOME Shell extensions in seconds

Home Page:https://extensions.gnome.org/extension/1176/argos/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Set terminal window title

donjan opened this issue · comments

I'd like to be able to customise the title of the GNOME terminal window launched when clicking on an Argos entry that contains a bash action.

As a side note, the gnome-terminal has a --title arg which doesn't seem to work in 2023.

Instead, setting the terminal title works well with a helper function such as shown here:
https://unix.stackexchange.com/questions/177572/how-to-rename-terminal-tab-title-in-gnome-terminal

But I've unsuccessfully tried an Argos line such as:

bash='ORIG=$PS1; TITLE='\[\e]2;test\a\]'; PS1=${ORIG}${TITLE}; echo hello world}'

or escaped:

bash='ORIG=\$PS1; TITLE=\'\\[\\e]2;test\\a\\]\'; PS1=\${ORIG}\${TITLE}; echo hello world}'

and various in-between versions, none of which works.

Neither does having the set-title function in ~/.bash.testing and

bash='source ~/.bash.testing; set-title test'

Can this be done with current Argos?

Managed to get it to work for my use case (blocking processes with GNOME terminal). The trick is to launch a secondary terminal and exit the current one:

bash='gnome-terminal -t \"my_title\" -- my_command && exit'

For blocking processes, this has the additional advantage of closing the window once the process is interrupted.
For non-blocking processes, this doesn't work because the window closes immediately.

Maybe this knowledge should be extracted to somewhere before closing this issue.

Side notes:

  • the reason the PS1 and set_title approaches didn't work might be due to environment encapsulation: a child process can't change PS1 of the parent.
  • the reason gnome-terminal -t "doesn't" work (it does, just for a microsecond) on its own is because most users have a PS1 in their ~/.bashrc that resets it immediately. The -- command syntax seems to bypass this.