I'm using Ubuntu 16.04
I want to open multiple terminal tabs, run commands and set title. I can open multiple tabs with this command:
gnome-terminal --tab -e "command1" --tab -e "command2" but cannot use --title option as it is not available in this version.
I know mate-terminal can do this, but I want to use gnome-terminal.
I've applied solution posted here and it worked but when i run
gnome-terminal --tab -e "bash -c 'set-title 99;ping 192.168.7.99'" It shows:
bash: set-title: command not found PING 192.168.7.99 (192.168.7.99) 56(84) bytes of data. 64 bytes from 192.168.7.99: icmp_seq=1 ttl=128 time=0.425 ms 64 bytes from 192.168.7.99: icmp_seq=2 ttl=128 time=0.353 ms 64 bytes from 192.168.7.99: icmp_seq=3 ttl=128 time=0.335 ms I also applied the solution suggested here on Unix & Linux SE
I've also read this post setting-terminal-tab-titles but the accepted answer did not solve my issue in 16.04 os or gnome-terminal version 3.18.3 and other solution provides to use other terminal xterm and I want to use gnome-terminal.
1 Answer
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.