Is it possible to obtain the current name of the xterm window?Opening a usable xterm window through bash...
Caro-Kann c4-c5 push
Would an object shot from earth fall into the sun?
Is there a way to remove Smite from a weapon?
Can I bring this power bank on board the aircraft?
How dangerous is a very out-of-true disc brake wheel?
Why such a singular place for bird watching?
Drawing Maps; flat distortion
Why do popular TCP-using services have UDP as well as TCP entries in /etc/services?
Could Boris Johnson face criminal charges for illegally proroguing Parliament?
Is there anything on the ISS that would be destroyed if that object were returned to Earth?
Knights and Knaves: What does C say?
Wondering why they used ultrafast diodes in a 50 or 60Hz bridge?
Is "weekend warrior" derogatory?
How to write a chemical equation for an reaction that is still fitting inside the document?
How to say "respectively" in German when listing (enumerating) things
Giving a good fancy look to a simple table
If I travelled back in time to invest in X company to make a fortune, roughly what is the probability that it would fail?
Disable all sound permanently
When Vesuvan Shapeshifter copies turn face up replacement effects, why do they work?
Replace zeros in a list with last nonzero value
Realistically, how much do you need to start investing?
Is there a pattern for handling conflicting function parameters?
Can anyone give me the reason why music is taught this way?
GPLv3 forces us to make code available, but to who?
Is it possible to obtain the current name of the xterm window?
Opening a usable xterm window through bash scriptHow do I make the Xterm window title switch between the current running command and the current path?xterm window positioningIn xterm, what is “Icon Name”?Xterm Set Title?Launch xterm to current directory through thunarUnable to see the menu in xtermxterm not loading config with -nameHow to keep `CLIPBOARD` content from XTerm after closing it? (Like Firefox or Leafpad does for example.)
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{
margin-bottom:0;
}
This LDP Howto demonstrates how to change the title of an xterm.
I know that this is also possible using the xtitle
command.
Before invoking a long-running action, my script uses such techniques to change the title of its xterm window.
I would like to extract the name of the xterm window prior to changing it so that, once the long-running action is completed, I can restore the title to its previous value.
It would sort of be an inverse to xtitle... Is this even possible?
xterm
add a comment
|
This LDP Howto demonstrates how to change the title of an xterm.
I know that this is also possible using the xtitle
command.
Before invoking a long-running action, my script uses such techniques to change the title of its xterm window.
I would like to extract the name of the xterm window prior to changing it so that, once the long-running action is completed, I can restore the title to its previous value.
It would sort of be an inverse to xtitle... Is this even possible?
xterm
Related stackoverflow question. It looks likexterm
has a stack for window title, if you can figure out how to use it.
– jw013
Jan 7 '12 at 3:36
add a comment
|
This LDP Howto demonstrates how to change the title of an xterm.
I know that this is also possible using the xtitle
command.
Before invoking a long-running action, my script uses such techniques to change the title of its xterm window.
I would like to extract the name of the xterm window prior to changing it so that, once the long-running action is completed, I can restore the title to its previous value.
It would sort of be an inverse to xtitle... Is this even possible?
xterm
This LDP Howto demonstrates how to change the title of an xterm.
I know that this is also possible using the xtitle
command.
Before invoking a long-running action, my script uses such techniques to change the title of its xterm window.
I would like to extract the name of the xterm window prior to changing it so that, once the long-running action is completed, I can restore the title to its previous value.
It would sort of be an inverse to xtitle... Is this even possible?
xterm
xterm
asked Jan 7 '12 at 3:09
TheGeeko61TheGeeko61
2,5413 gold badges13 silver badges17 bronze badges
2,5413 gold badges13 silver badges17 bronze badges
Related stackoverflow question. It looks likexterm
has a stack for window title, if you can figure out how to use it.
– jw013
Jan 7 '12 at 3:36
add a comment
|
Related stackoverflow question. It looks likexterm
has a stack for window title, if you can figure out how to use it.
– jw013
Jan 7 '12 at 3:36
Related stackoverflow question. It looks like
xterm
has a stack for window title, if you can figure out how to use it.– jw013
Jan 7 '12 at 3:36
Related stackoverflow question. It looks like
xterm
has a stack for window title, if you can figure out how to use it.– jw013
Jan 7 '12 at 3:36
add a comment
|
4 Answers
4
active
oldest
votes
Use xtitle
script.
There are many variants on internet, however, I tend to use one which depends on xprop
http://www.shelldorado.com/scripts/cmds/xtitle
Excellent! This is EXACTLY what I was hoping for... and it not only works for xterm but (unlike other solutions) also works for gnome-terminal. Thank YOU!
– TheGeeko61
Jan 7 '12 at 19:02
Do note though that obtaining the title via the X protocol, which is whatxtitle
does, only works for local sessions.
– ak2
Jan 7 '12 at 20:07
add a comment
|
There is a control sequence for querying the current title, but it's usually disabled for security reasons. That's because it allows a malicious program or even just a catted text file to insert arbitrary character sequences as if typed on the keyboard, by first setting the title and then asking to have it reported back. Hence the title stack was introduced instead.
The following command will save the current window and icon titles onto the stack:
echo -ne 'e[22t'
This will set the title to my title
:
echo -ne 'e]0;my title07'
And this will restore the prior window and icon titles:
echo -ne 'e[23t'
add a comment
|
For the trivial, (and probably most common case), where one might wish to query the prompt for the current xterm, simply use xprop -id $WINDOWID WM_NAME
. If you want to extract the value for manipulation in a shell script, you can do something a bit more expensive such as:
curtitle=`xprop -id $WINDOWID WM_NAME|awk '{print $3}'|xargs echo`
Using bash alone (to avoid the invocation of awk and xargs):
curtitle=`xprop -id $WINDOWID WM_NAME`
curtitle=`eval echo ${x##*=}`
The xargs echo in the first example and the eval in the second example is simply there to strip off the quotes that xprop puts around the value.
Replace WM_NAME with WM_ICON if you want to obtain the icon name rather than the string in the title-bar.
add a comment
|
If I understand your question right, you should be able to get the current xterm title by inspecting the $PROMPT_COMMAND
variable, e.g:
$ echo $PROMPT_COMMAND
printf "33]0;%s@%s:%s07" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"
and you can set it like (linebreak for readability):
PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "33]
0;%s@%s%s07" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
ThePROMPT_COMMAND
is not the most authoritative way to get the title since it is not always set, and any command you run could change the title between prompts. For the most accuracy, terminal emulator specific control sequences are probably the way to go.
– jw013
Jan 7 '12 at 17:39
This would not work for cases where other apps are setting the title.
– TheGeeko61
Jan 7 '12 at 18:55
The$PROMPT_COMMAND
is not the window title. They are unrelated.
– JamesThomasMoon1979
3 hours ago
add a comment
|
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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/4.0/"u003ecc by-sa 4.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%2funix.stackexchange.com%2fquestions%2f28500%2fis-it-possible-to-obtain-the-current-name-of-the-xterm-window%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
Use xtitle
script.
There are many variants on internet, however, I tend to use one which depends on xprop
http://www.shelldorado.com/scripts/cmds/xtitle
Excellent! This is EXACTLY what I was hoping for... and it not only works for xterm but (unlike other solutions) also works for gnome-terminal. Thank YOU!
– TheGeeko61
Jan 7 '12 at 19:02
Do note though that obtaining the title via the X protocol, which is whatxtitle
does, only works for local sessions.
– ak2
Jan 7 '12 at 20:07
add a comment
|
Use xtitle
script.
There are many variants on internet, however, I tend to use one which depends on xprop
http://www.shelldorado.com/scripts/cmds/xtitle
Excellent! This is EXACTLY what I was hoping for... and it not only works for xterm but (unlike other solutions) also works for gnome-terminal. Thank YOU!
– TheGeeko61
Jan 7 '12 at 19:02
Do note though that obtaining the title via the X protocol, which is whatxtitle
does, only works for local sessions.
– ak2
Jan 7 '12 at 20:07
add a comment
|
Use xtitle
script.
There are many variants on internet, however, I tend to use one which depends on xprop
http://www.shelldorado.com/scripts/cmds/xtitle
Use xtitle
script.
There are many variants on internet, however, I tend to use one which depends on xprop
http://www.shelldorado.com/scripts/cmds/xtitle
answered Jan 7 '12 at 12:55
Nikhil MulleyNikhil Mulley
6,63622 silver badges45 bronze badges
6,63622 silver badges45 bronze badges
Excellent! This is EXACTLY what I was hoping for... and it not only works for xterm but (unlike other solutions) also works for gnome-terminal. Thank YOU!
– TheGeeko61
Jan 7 '12 at 19:02
Do note though that obtaining the title via the X protocol, which is whatxtitle
does, only works for local sessions.
– ak2
Jan 7 '12 at 20:07
add a comment
|
Excellent! This is EXACTLY what I was hoping for... and it not only works for xterm but (unlike other solutions) also works for gnome-terminal. Thank YOU!
– TheGeeko61
Jan 7 '12 at 19:02
Do note though that obtaining the title via the X protocol, which is whatxtitle
does, only works for local sessions.
– ak2
Jan 7 '12 at 20:07
Excellent! This is EXACTLY what I was hoping for... and it not only works for xterm but (unlike other solutions) also works for gnome-terminal. Thank YOU!
– TheGeeko61
Jan 7 '12 at 19:02
Excellent! This is EXACTLY what I was hoping for... and it not only works for xterm but (unlike other solutions) also works for gnome-terminal. Thank YOU!
– TheGeeko61
Jan 7 '12 at 19:02
Do note though that obtaining the title via the X protocol, which is what
xtitle
does, only works for local sessions.– ak2
Jan 7 '12 at 20:07
Do note though that obtaining the title via the X protocol, which is what
xtitle
does, only works for local sessions.– ak2
Jan 7 '12 at 20:07
add a comment
|
There is a control sequence for querying the current title, but it's usually disabled for security reasons. That's because it allows a malicious program or even just a catted text file to insert arbitrary character sequences as if typed on the keyboard, by first setting the title and then asking to have it reported back. Hence the title stack was introduced instead.
The following command will save the current window and icon titles onto the stack:
echo -ne 'e[22t'
This will set the title to my title
:
echo -ne 'e]0;my title07'
And this will restore the prior window and icon titles:
echo -ne 'e[23t'
add a comment
|
There is a control sequence for querying the current title, but it's usually disabled for security reasons. That's because it allows a malicious program or even just a catted text file to insert arbitrary character sequences as if typed on the keyboard, by first setting the title and then asking to have it reported back. Hence the title stack was introduced instead.
The following command will save the current window and icon titles onto the stack:
echo -ne 'e[22t'
This will set the title to my title
:
echo -ne 'e]0;my title07'
And this will restore the prior window and icon titles:
echo -ne 'e[23t'
add a comment
|
There is a control sequence for querying the current title, but it's usually disabled for security reasons. That's because it allows a malicious program or even just a catted text file to insert arbitrary character sequences as if typed on the keyboard, by first setting the title and then asking to have it reported back. Hence the title stack was introduced instead.
The following command will save the current window and icon titles onto the stack:
echo -ne 'e[22t'
This will set the title to my title
:
echo -ne 'e]0;my title07'
And this will restore the prior window and icon titles:
echo -ne 'e[23t'
There is a control sequence for querying the current title, but it's usually disabled for security reasons. That's because it allows a malicious program or even just a catted text file to insert arbitrary character sequences as if typed on the keyboard, by first setting the title and then asking to have it reported back. Hence the title stack was introduced instead.
The following command will save the current window and icon titles onto the stack:
echo -ne 'e[22t'
This will set the title to my title
:
echo -ne 'e]0;my title07'
And this will restore the prior window and icon titles:
echo -ne 'e[23t'
edited 27 mins ago
RalfFriedl
6,1014 gold badges13 silver badges26 bronze badges
6,1014 gold badges13 silver badges26 bronze badges
answered Jan 7 '12 at 9:43
ak2ak2
9,5731 gold badge13 silver badges9 bronze badges
9,5731 gold badge13 silver badges9 bronze badges
add a comment
|
add a comment
|
For the trivial, (and probably most common case), where one might wish to query the prompt for the current xterm, simply use xprop -id $WINDOWID WM_NAME
. If you want to extract the value for manipulation in a shell script, you can do something a bit more expensive such as:
curtitle=`xprop -id $WINDOWID WM_NAME|awk '{print $3}'|xargs echo`
Using bash alone (to avoid the invocation of awk and xargs):
curtitle=`xprop -id $WINDOWID WM_NAME`
curtitle=`eval echo ${x##*=}`
The xargs echo in the first example and the eval in the second example is simply there to strip off the quotes that xprop puts around the value.
Replace WM_NAME with WM_ICON if you want to obtain the icon name rather than the string in the title-bar.
add a comment
|
For the trivial, (and probably most common case), where one might wish to query the prompt for the current xterm, simply use xprop -id $WINDOWID WM_NAME
. If you want to extract the value for manipulation in a shell script, you can do something a bit more expensive such as:
curtitle=`xprop -id $WINDOWID WM_NAME|awk '{print $3}'|xargs echo`
Using bash alone (to avoid the invocation of awk and xargs):
curtitle=`xprop -id $WINDOWID WM_NAME`
curtitle=`eval echo ${x##*=}`
The xargs echo in the first example and the eval in the second example is simply there to strip off the quotes that xprop puts around the value.
Replace WM_NAME with WM_ICON if you want to obtain the icon name rather than the string in the title-bar.
add a comment
|
For the trivial, (and probably most common case), where one might wish to query the prompt for the current xterm, simply use xprop -id $WINDOWID WM_NAME
. If you want to extract the value for manipulation in a shell script, you can do something a bit more expensive such as:
curtitle=`xprop -id $WINDOWID WM_NAME|awk '{print $3}'|xargs echo`
Using bash alone (to avoid the invocation of awk and xargs):
curtitle=`xprop -id $WINDOWID WM_NAME`
curtitle=`eval echo ${x##*=}`
The xargs echo in the first example and the eval in the second example is simply there to strip off the quotes that xprop puts around the value.
Replace WM_NAME with WM_ICON if you want to obtain the icon name rather than the string in the title-bar.
For the trivial, (and probably most common case), where one might wish to query the prompt for the current xterm, simply use xprop -id $WINDOWID WM_NAME
. If you want to extract the value for manipulation in a shell script, you can do something a bit more expensive such as:
curtitle=`xprop -id $WINDOWID WM_NAME|awk '{print $3}'|xargs echo`
Using bash alone (to avoid the invocation of awk and xargs):
curtitle=`xprop -id $WINDOWID WM_NAME`
curtitle=`eval echo ${x##*=}`
The xargs echo in the first example and the eval in the second example is simply there to strip off the quotes that xprop puts around the value.
Replace WM_NAME with WM_ICON if you want to obtain the icon name rather than the string in the title-bar.
answered Jun 29 '15 at 16:55
Keith HanlanKeith Hanlan
1213 bronze badges
1213 bronze badges
add a comment
|
add a comment
|
If I understand your question right, you should be able to get the current xterm title by inspecting the $PROMPT_COMMAND
variable, e.g:
$ echo $PROMPT_COMMAND
printf "33]0;%s@%s:%s07" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"
and you can set it like (linebreak for readability):
PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "33]
0;%s@%s%s07" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
ThePROMPT_COMMAND
is not the most authoritative way to get the title since it is not always set, and any command you run could change the title between prompts. For the most accuracy, terminal emulator specific control sequences are probably the way to go.
– jw013
Jan 7 '12 at 17:39
This would not work for cases where other apps are setting the title.
– TheGeeko61
Jan 7 '12 at 18:55
The$PROMPT_COMMAND
is not the window title. They are unrelated.
– JamesThomasMoon1979
3 hours ago
add a comment
|
If I understand your question right, you should be able to get the current xterm title by inspecting the $PROMPT_COMMAND
variable, e.g:
$ echo $PROMPT_COMMAND
printf "33]0;%s@%s:%s07" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"
and you can set it like (linebreak for readability):
PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "33]
0;%s@%s%s07" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
ThePROMPT_COMMAND
is not the most authoritative way to get the title since it is not always set, and any command you run could change the title between prompts. For the most accuracy, terminal emulator specific control sequences are probably the way to go.
– jw013
Jan 7 '12 at 17:39
This would not work for cases where other apps are setting the title.
– TheGeeko61
Jan 7 '12 at 18:55
The$PROMPT_COMMAND
is not the window title. They are unrelated.
– JamesThomasMoon1979
3 hours ago
add a comment
|
If I understand your question right, you should be able to get the current xterm title by inspecting the $PROMPT_COMMAND
variable, e.g:
$ echo $PROMPT_COMMAND
printf "33]0;%s@%s:%s07" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"
and you can set it like (linebreak for readability):
PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "33]
0;%s@%s%s07" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
If I understand your question right, you should be able to get the current xterm title by inspecting the $PROMPT_COMMAND
variable, e.g:
$ echo $PROMPT_COMMAND
printf "33]0;%s@%s:%s07" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"
and you can set it like (linebreak for readability):
PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "33]
0;%s@%s%s07" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
answered Jan 7 '12 at 10:41
user13742
ThePROMPT_COMMAND
is not the most authoritative way to get the title since it is not always set, and any command you run could change the title between prompts. For the most accuracy, terminal emulator specific control sequences are probably the way to go.
– jw013
Jan 7 '12 at 17:39
This would not work for cases where other apps are setting the title.
– TheGeeko61
Jan 7 '12 at 18:55
The$PROMPT_COMMAND
is not the window title. They are unrelated.
– JamesThomasMoon1979
3 hours ago
add a comment
|
ThePROMPT_COMMAND
is not the most authoritative way to get the title since it is not always set, and any command you run could change the title between prompts. For the most accuracy, terminal emulator specific control sequences are probably the way to go.
– jw013
Jan 7 '12 at 17:39
This would not work for cases where other apps are setting the title.
– TheGeeko61
Jan 7 '12 at 18:55
The$PROMPT_COMMAND
is not the window title. They are unrelated.
– JamesThomasMoon1979
3 hours ago
The
PROMPT_COMMAND
is not the most authoritative way to get the title since it is not always set, and any command you run could change the title between prompts. For the most accuracy, terminal emulator specific control sequences are probably the way to go.– jw013
Jan 7 '12 at 17:39
The
PROMPT_COMMAND
is not the most authoritative way to get the title since it is not always set, and any command you run could change the title between prompts. For the most accuracy, terminal emulator specific control sequences are probably the way to go.– jw013
Jan 7 '12 at 17:39
This would not work for cases where other apps are setting the title.
– TheGeeko61
Jan 7 '12 at 18:55
This would not work for cases where other apps are setting the title.
– TheGeeko61
Jan 7 '12 at 18:55
The
$PROMPT_COMMAND
is not the window title. They are unrelated.– JamesThomasMoon1979
3 hours ago
The
$PROMPT_COMMAND
is not the window title. They are unrelated.– JamesThomasMoon1979
3 hours ago
add a comment
|
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- 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%2funix.stackexchange.com%2fquestions%2f28500%2fis-it-possible-to-obtain-the-current-name-of-the-xterm-window%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
Related stackoverflow question. It looks like
xterm
has a stack for window title, if you can figure out how to use it.– jw013
Jan 7 '12 at 3:36