Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set terminal window title #148

Open
donjan opened this issue Aug 31, 2023 · 1 comment
Open

Set terminal window title #148

donjan opened this issue Aug 31, 2023 · 1 comment

Comments

@donjan
Copy link

donjan commented Aug 31, 2023

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?

@donjan
Copy link
Author

donjan commented Sep 10, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant