Set title for each terminal tab in gnome-terminal using a bash script
If you want to use a function stored in ~/.bashrc
then source that file in your command:
gnome-terminal --tab -e "bash -c 'source ~/.bashrc;set-title 99;ping 192.168.7.99'"
You've mentioned in the comments that you plan to use this in a shell script and with multiple gnome-terminal
tabs. As a proof of concept, you can use the following script as example:
#!/bin/bash
gnome-terminal --tab -e "bash -c 'printf \"\033]0;TEST1\007\"; sleep 7'" \
--tab -e "bash -c 'printf \"\033]0;TEST2\007\"; ping -c 4 8.8.8.8'" \
Instead of bash function, this uses printf
and escape sequences directly. Please be mindful of the backslashes.