Set title for each terminal tab in gnome-terminal using a bash script
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.
16.04 command-line bash gnome-terminal
add a comment |
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.
16.04 command-line bash gnome-terminal
3
Possible duplicate of Setting Terminal tab titles
– John N
Dec 13 '16 at 8:16
Please note, that the core of the problem was that OP wanted to use a function defined in~/.bashrc
within custom script. Thus, the question is only tangentially related to the link John N provided. IMHO this is not a strict duplicate
– Sergiy Kolodyazhnyy
Dec 29 '16 at 5:27
add a comment |
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.
16.04 command-line bash gnome-terminal
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.
16.04 command-line bash gnome-terminal
16.04 command-line bash gnome-terminal
edited 5 mins ago
d a i s y
asked Dec 13 '16 at 8:05
d a i s yd a i s y
3,32282344
3,32282344
3
Possible duplicate of Setting Terminal tab titles
– John N
Dec 13 '16 at 8:16
Please note, that the core of the problem was that OP wanted to use a function defined in~/.bashrc
within custom script. Thus, the question is only tangentially related to the link John N provided. IMHO this is not a strict duplicate
– Sergiy Kolodyazhnyy
Dec 29 '16 at 5:27
add a comment |
3
Possible duplicate of Setting Terminal tab titles
– John N
Dec 13 '16 at 8:16
Please note, that the core of the problem was that OP wanted to use a function defined in~/.bashrc
within custom script. Thus, the question is only tangentially related to the link John N provided. IMHO this is not a strict duplicate
– Sergiy Kolodyazhnyy
Dec 29 '16 at 5:27
3
3
Possible duplicate of Setting Terminal tab titles
– John N
Dec 13 '16 at 8:16
Possible duplicate of Setting Terminal tab titles
– John N
Dec 13 '16 at 8:16
Please note, that the core of the problem was that OP wanted to use a function defined in
~/.bashrc
within custom script. Thus, the question is only tangentially related to the link John N provided. IMHO this is not a strict duplicate– Sergiy Kolodyazhnyy
Dec 29 '16 at 5:27
Please note, that the core of the problem was that OP wanted to use a function defined in
~/.bashrc
within custom script. Thus, the question is only tangentially related to the link John N provided. IMHO this is not a strict duplicate– Sergiy Kolodyazhnyy
Dec 29 '16 at 5:27
add a comment |
1 Answer
1
active
oldest
votes
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 "33]0;TEST107"; sleep 7'"
--tab -e "bash -c 'printf "33]0;TEST207"; ping -c 4 8.8.8.8'"
Instead of bash function, this uses printf
and escape sequences directly. Please be mindful of the backslashes.
It opens terminal, run command but not set title.
– d a i s y
Dec 14 '16 at 7:54
2
@Lucy try this function instead :setTitle() { echo -e "33]0;$@07" }
– Sergiy Kolodyazhnyy
Dec 14 '16 at 7:56
means to put this in .bashrc file & remove that old function?
– d a i s y
Dec 14 '16 at 7:58
@Lucy yes. Or you can put both there, just use different names. I just tested it with my own gnome-terminal, works. imgur.com/a/Dto82
– Sergiy Kolodyazhnyy
Dec 14 '16 at 7:59
1
@Lucy perfect ! Well, congrats , we've solved your question. Also final note: you don't have to use it as function, you probably could simply useecho -e "33]0;TITLE TEXT07"
in your `gnome-terminal command directly. I will make a small addition to my answer, please see it later. Thx
– Sergiy Kolodyazhnyy
Dec 14 '16 at 8:15
|
show 10 more comments
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f860145%2fset-title-for-each-terminal-tab-in-gnome-terminal-using-a-bash-script%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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 "33]0;TEST107"; sleep 7'"
--tab -e "bash -c 'printf "33]0;TEST207"; ping -c 4 8.8.8.8'"
Instead of bash function, this uses printf
and escape sequences directly. Please be mindful of the backslashes.
It opens terminal, run command but not set title.
– d a i s y
Dec 14 '16 at 7:54
2
@Lucy try this function instead :setTitle() { echo -e "33]0;$@07" }
– Sergiy Kolodyazhnyy
Dec 14 '16 at 7:56
means to put this in .bashrc file & remove that old function?
– d a i s y
Dec 14 '16 at 7:58
@Lucy yes. Or you can put both there, just use different names. I just tested it with my own gnome-terminal, works. imgur.com/a/Dto82
– Sergiy Kolodyazhnyy
Dec 14 '16 at 7:59
1
@Lucy perfect ! Well, congrats , we've solved your question. Also final note: you don't have to use it as function, you probably could simply useecho -e "33]0;TITLE TEXT07"
in your `gnome-terminal command directly. I will make a small addition to my answer, please see it later. Thx
– Sergiy Kolodyazhnyy
Dec 14 '16 at 8:15
|
show 10 more comments
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 "33]0;TEST107"; sleep 7'"
--tab -e "bash -c 'printf "33]0;TEST207"; ping -c 4 8.8.8.8'"
Instead of bash function, this uses printf
and escape sequences directly. Please be mindful of the backslashes.
It opens terminal, run command but not set title.
– d a i s y
Dec 14 '16 at 7:54
2
@Lucy try this function instead :setTitle() { echo -e "33]0;$@07" }
– Sergiy Kolodyazhnyy
Dec 14 '16 at 7:56
means to put this in .bashrc file & remove that old function?
– d a i s y
Dec 14 '16 at 7:58
@Lucy yes. Or you can put both there, just use different names. I just tested it with my own gnome-terminal, works. imgur.com/a/Dto82
– Sergiy Kolodyazhnyy
Dec 14 '16 at 7:59
1
@Lucy perfect ! Well, congrats , we've solved your question. Also final note: you don't have to use it as function, you probably could simply useecho -e "33]0;TITLE TEXT07"
in your `gnome-terminal command directly. I will make a small addition to my answer, please see it later. Thx
– Sergiy Kolodyazhnyy
Dec 14 '16 at 8:15
|
show 10 more comments
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 "33]0;TEST107"; sleep 7'"
--tab -e "bash -c 'printf "33]0;TEST207"; ping -c 4 8.8.8.8'"
Instead of bash function, this uses printf
and escape sequences directly. Please be mindful of the backslashes.
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 "33]0;TEST107"; sleep 7'"
--tab -e "bash -c 'printf "33]0;TEST207"; ping -c 4 8.8.8.8'"
Instead of bash function, this uses printf
and escape sequences directly. Please be mindful of the backslashes.
edited Dec 14 '16 at 8:34
answered Dec 14 '16 at 7:12
Sergiy KolodyazhnyySergiy Kolodyazhnyy
71.5k9147313
71.5k9147313
It opens terminal, run command but not set title.
– d a i s y
Dec 14 '16 at 7:54
2
@Lucy try this function instead :setTitle() { echo -e "33]0;$@07" }
– Sergiy Kolodyazhnyy
Dec 14 '16 at 7:56
means to put this in .bashrc file & remove that old function?
– d a i s y
Dec 14 '16 at 7:58
@Lucy yes. Or you can put both there, just use different names. I just tested it with my own gnome-terminal, works. imgur.com/a/Dto82
– Sergiy Kolodyazhnyy
Dec 14 '16 at 7:59
1
@Lucy perfect ! Well, congrats , we've solved your question. Also final note: you don't have to use it as function, you probably could simply useecho -e "33]0;TITLE TEXT07"
in your `gnome-terminal command directly. I will make a small addition to my answer, please see it later. Thx
– Sergiy Kolodyazhnyy
Dec 14 '16 at 8:15
|
show 10 more comments
It opens terminal, run command but not set title.
– d a i s y
Dec 14 '16 at 7:54
2
@Lucy try this function instead :setTitle() { echo -e "33]0;$@07" }
– Sergiy Kolodyazhnyy
Dec 14 '16 at 7:56
means to put this in .bashrc file & remove that old function?
– d a i s y
Dec 14 '16 at 7:58
@Lucy yes. Or you can put both there, just use different names. I just tested it with my own gnome-terminal, works. imgur.com/a/Dto82
– Sergiy Kolodyazhnyy
Dec 14 '16 at 7:59
1
@Lucy perfect ! Well, congrats , we've solved your question. Also final note: you don't have to use it as function, you probably could simply useecho -e "33]0;TITLE TEXT07"
in your `gnome-terminal command directly. I will make a small addition to my answer, please see it later. Thx
– Sergiy Kolodyazhnyy
Dec 14 '16 at 8:15
It opens terminal, run command but not set title.
– d a i s y
Dec 14 '16 at 7:54
It opens terminal, run command but not set title.
– d a i s y
Dec 14 '16 at 7:54
2
2
@Lucy try this function instead :
setTitle() { echo -e "33]0;$@07" }
– Sergiy Kolodyazhnyy
Dec 14 '16 at 7:56
@Lucy try this function instead :
setTitle() { echo -e "33]0;$@07" }
– Sergiy Kolodyazhnyy
Dec 14 '16 at 7:56
means to put this in .bashrc file & remove that old function?
– d a i s y
Dec 14 '16 at 7:58
means to put this in .bashrc file & remove that old function?
– d a i s y
Dec 14 '16 at 7:58
@Lucy yes. Or you can put both there, just use different names. I just tested it with my own gnome-terminal, works. imgur.com/a/Dto82
– Sergiy Kolodyazhnyy
Dec 14 '16 at 7:59
@Lucy yes. Or you can put both there, just use different names. I just tested it with my own gnome-terminal, works. imgur.com/a/Dto82
– Sergiy Kolodyazhnyy
Dec 14 '16 at 7:59
1
1
@Lucy perfect ! Well, congrats , we've solved your question. Also final note: you don't have to use it as function, you probably could simply use
echo -e "33]0;TITLE TEXT07"
in your `gnome-terminal command directly. I will make a small addition to my answer, please see it later. Thx– Sergiy Kolodyazhnyy
Dec 14 '16 at 8:15
@Lucy perfect ! Well, congrats , we've solved your question. Also final note: you don't have to use it as function, you probably could simply use
echo -e "33]0;TITLE TEXT07"
in your `gnome-terminal command directly. I will make a small addition to my answer, please see it later. Thx– Sergiy Kolodyazhnyy
Dec 14 '16 at 8:15
|
show 10 more comments
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f860145%2fset-title-for-each-terminal-tab-in-gnome-terminal-using-a-bash-script%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
Possible duplicate of Setting Terminal tab titles
– John N
Dec 13 '16 at 8:16
Please note, that the core of the problem was that OP wanted to use a function defined in
~/.bashrc
within custom script. Thus, the question is only tangentially related to the link John N provided. IMHO this is not a strict duplicate– Sergiy Kolodyazhnyy
Dec 29 '16 at 5:27