Access xterm's scrollback buffer as a file

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
8
down vote

favorite
2












Is it possible to, somehow, access xterm's scrollback buffer as a (read-only) file or a character device?



The core issue (to avoid x/y "problemming"), is this:
sometimes the command I've just executed creates non-deterministic output, and I'd like to use its output somehow without pre-thought of tee-ing it. Right now, the only way to do this (that I'm aware of) is to use the mouse to select the text into primary selection.







share|improve this question



















  • Alternative to using tee. Have you considered running script to create a log of all your commands to a file?
    – Stephen Quan
    Apr 30 at 0:16















up vote
8
down vote

favorite
2












Is it possible to, somehow, access xterm's scrollback buffer as a (read-only) file or a character device?



The core issue (to avoid x/y "problemming"), is this:
sometimes the command I've just executed creates non-deterministic output, and I'd like to use its output somehow without pre-thought of tee-ing it. Right now, the only way to do this (that I'm aware of) is to use the mouse to select the text into primary selection.







share|improve this question



















  • Alternative to using tee. Have you considered running script to create a log of all your commands to a file?
    – Stephen Quan
    Apr 30 at 0:16













up vote
8
down vote

favorite
2









up vote
8
down vote

favorite
2






2





Is it possible to, somehow, access xterm's scrollback buffer as a (read-only) file or a character device?



The core issue (to avoid x/y "problemming"), is this:
sometimes the command I've just executed creates non-deterministic output, and I'd like to use its output somehow without pre-thought of tee-ing it. Right now, the only way to do this (that I'm aware of) is to use the mouse to select the text into primary selection.







share|improve this question











Is it possible to, somehow, access xterm's scrollback buffer as a (read-only) file or a character device?



The core issue (to avoid x/y "problemming"), is this:
sometimes the command I've just executed creates non-deterministic output, and I'd like to use its output somehow without pre-thought of tee-ing it. Right now, the only way to do this (that I'm aware of) is to use the mouse to select the text into primary selection.









share|improve this question










share|improve this question




share|improve this question









asked Apr 29 at 16:20









John Z.

433




433











  • Alternative to using tee. Have you considered running script to create a log of all your commands to a file?
    – Stephen Quan
    Apr 30 at 0:16

















  • Alternative to using tee. Have you considered running script to create a log of all your commands to a file?
    – Stephen Quan
    Apr 30 at 0:16
















Alternative to using tee. Have you considered running script to create a log of all your commands to a file?
– Stephen Quan
Apr 30 at 0:16





Alternative to using tee. Have you considered running script to create a log of all your commands to a file?
– Stephen Quan
Apr 30 at 0:16











2 Answers
2






active

oldest

votes

















up vote
5
down vote



accepted










You could do this by telling xterm to print the data using the print-everything action (normally not bound to a key).



Alternatively, there's an escape sequence documented in XTerm Control Sequences:



CSI ? Pm i 
Media Copy (MC), DEC-specific.
Ps = 1 -> Print line containing cursor.
Ps = 4 -> Turn off autoprint mode.
Ps = 5 -> Turn on autoprint mode.
Ps = 1 0 -> Print composed display, ignores DECPEX.
Ps = 1 1 -> Print all pages.


which could be invoked as



printf '33[?11i'


But either approach (to write to a file) would need a printerCommand configured.






share|improve this answer























  • Is it possible to do that without restarting xterm? If it involves restarting xterm it is not really an answer as that would cause the output to be lost.
    – kasperd
    Apr 29 at 17:54










  • This is what I was looking for. Resources can be reloaded on the fly, and I'm OK to restart xterm. I've created a named fifo and configured it into printerCommand, have bound print-everything command to a key and it works exactly as I wanted it to.
    – John Z.
    May 18 at 18:18


















up vote
1
down vote













You can always use something like tmux which provides capture-pane that does what you want, along with splits (vertical and horizontal) and multiplexing, session support, and a slew of other things.



Or use a different terminal emulator xfce4-terminal is also lightweight and provides an easy Save Contents






share|improve this answer

















  • 1




    To me this does not sound like an answer to the question. None of those programs can magically capture output which at the moment exist only in an xterm window.
    – kasperd
    Apr 29 at 17:56










  • @kasperd a fair interpretation. He wants something that captures without pre-thought. I use tmux without prethought. Then I don't have this problem. If you can get in the habit of using tmux, you'll never have to think about this again (or a lot of other stuff).
    – Evan Carroll
    Apr 29 at 18:10











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',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f440752%2faccess-xterms-scrollback-buffer-as-a-file%23new-answer', 'question_page');

);

Post as a guest






























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
5
down vote



accepted










You could do this by telling xterm to print the data using the print-everything action (normally not bound to a key).



Alternatively, there's an escape sequence documented in XTerm Control Sequences:



CSI ? Pm i 
Media Copy (MC), DEC-specific.
Ps = 1 -> Print line containing cursor.
Ps = 4 -> Turn off autoprint mode.
Ps = 5 -> Turn on autoprint mode.
Ps = 1 0 -> Print composed display, ignores DECPEX.
Ps = 1 1 -> Print all pages.


which could be invoked as



printf '33[?11i'


But either approach (to write to a file) would need a printerCommand configured.






share|improve this answer























  • Is it possible to do that without restarting xterm? If it involves restarting xterm it is not really an answer as that would cause the output to be lost.
    – kasperd
    Apr 29 at 17:54










  • This is what I was looking for. Resources can be reloaded on the fly, and I'm OK to restart xterm. I've created a named fifo and configured it into printerCommand, have bound print-everything command to a key and it works exactly as I wanted it to.
    – John Z.
    May 18 at 18:18















up vote
5
down vote



accepted










You could do this by telling xterm to print the data using the print-everything action (normally not bound to a key).



Alternatively, there's an escape sequence documented in XTerm Control Sequences:



CSI ? Pm i 
Media Copy (MC), DEC-specific.
Ps = 1 -> Print line containing cursor.
Ps = 4 -> Turn off autoprint mode.
Ps = 5 -> Turn on autoprint mode.
Ps = 1 0 -> Print composed display, ignores DECPEX.
Ps = 1 1 -> Print all pages.


which could be invoked as



printf '33[?11i'


But either approach (to write to a file) would need a printerCommand configured.






share|improve this answer























  • Is it possible to do that without restarting xterm? If it involves restarting xterm it is not really an answer as that would cause the output to be lost.
    – kasperd
    Apr 29 at 17:54










  • This is what I was looking for. Resources can be reloaded on the fly, and I'm OK to restart xterm. I've created a named fifo and configured it into printerCommand, have bound print-everything command to a key and it works exactly as I wanted it to.
    – John Z.
    May 18 at 18:18













up vote
5
down vote



accepted







up vote
5
down vote



accepted






You could do this by telling xterm to print the data using the print-everything action (normally not bound to a key).



Alternatively, there's an escape sequence documented in XTerm Control Sequences:



CSI ? Pm i 
Media Copy (MC), DEC-specific.
Ps = 1 -> Print line containing cursor.
Ps = 4 -> Turn off autoprint mode.
Ps = 5 -> Turn on autoprint mode.
Ps = 1 0 -> Print composed display, ignores DECPEX.
Ps = 1 1 -> Print all pages.


which could be invoked as



printf '33[?11i'


But either approach (to write to a file) would need a printerCommand configured.






share|improve this answer















You could do this by telling xterm to print the data using the print-everything action (normally not bound to a key).



Alternatively, there's an escape sequence documented in XTerm Control Sequences:



CSI ? Pm i 
Media Copy (MC), DEC-specific.
Ps = 1 -> Print line containing cursor.
Ps = 4 -> Turn off autoprint mode.
Ps = 5 -> Turn on autoprint mode.
Ps = 1 0 -> Print composed display, ignores DECPEX.
Ps = 1 1 -> Print all pages.


which could be invoked as



printf '33[?11i'


But either approach (to write to a file) would need a printerCommand configured.







share|improve this answer















share|improve this answer



share|improve this answer








edited Apr 29 at 18:31


























answered Apr 29 at 16:29









Thomas Dickey

49.1k584154




49.1k584154











  • Is it possible to do that without restarting xterm? If it involves restarting xterm it is not really an answer as that would cause the output to be lost.
    – kasperd
    Apr 29 at 17:54










  • This is what I was looking for. Resources can be reloaded on the fly, and I'm OK to restart xterm. I've created a named fifo and configured it into printerCommand, have bound print-everything command to a key and it works exactly as I wanted it to.
    – John Z.
    May 18 at 18:18

















  • Is it possible to do that without restarting xterm? If it involves restarting xterm it is not really an answer as that would cause the output to be lost.
    – kasperd
    Apr 29 at 17:54










  • This is what I was looking for. Resources can be reloaded on the fly, and I'm OK to restart xterm. I've created a named fifo and configured it into printerCommand, have bound print-everything command to a key and it works exactly as I wanted it to.
    – John Z.
    May 18 at 18:18
















Is it possible to do that without restarting xterm? If it involves restarting xterm it is not really an answer as that would cause the output to be lost.
– kasperd
Apr 29 at 17:54




Is it possible to do that without restarting xterm? If it involves restarting xterm it is not really an answer as that would cause the output to be lost.
– kasperd
Apr 29 at 17:54












This is what I was looking for. Resources can be reloaded on the fly, and I'm OK to restart xterm. I've created a named fifo and configured it into printerCommand, have bound print-everything command to a key and it works exactly as I wanted it to.
– John Z.
May 18 at 18:18





This is what I was looking for. Resources can be reloaded on the fly, and I'm OK to restart xterm. I've created a named fifo and configured it into printerCommand, have bound print-everything command to a key and it works exactly as I wanted it to.
– John Z.
May 18 at 18:18













up vote
1
down vote













You can always use something like tmux which provides capture-pane that does what you want, along with splits (vertical and horizontal) and multiplexing, session support, and a slew of other things.



Or use a different terminal emulator xfce4-terminal is also lightweight and provides an easy Save Contents






share|improve this answer

















  • 1




    To me this does not sound like an answer to the question. None of those programs can magically capture output which at the moment exist only in an xterm window.
    – kasperd
    Apr 29 at 17:56










  • @kasperd a fair interpretation. He wants something that captures without pre-thought. I use tmux without prethought. Then I don't have this problem. If you can get in the habit of using tmux, you'll never have to think about this again (or a lot of other stuff).
    – Evan Carroll
    Apr 29 at 18:10















up vote
1
down vote













You can always use something like tmux which provides capture-pane that does what you want, along with splits (vertical and horizontal) and multiplexing, session support, and a slew of other things.



Or use a different terminal emulator xfce4-terminal is also lightweight and provides an easy Save Contents






share|improve this answer

















  • 1




    To me this does not sound like an answer to the question. None of those programs can magically capture output which at the moment exist only in an xterm window.
    – kasperd
    Apr 29 at 17:56










  • @kasperd a fair interpretation. He wants something that captures without pre-thought. I use tmux without prethought. Then I don't have this problem. If you can get in the habit of using tmux, you'll never have to think about this again (or a lot of other stuff).
    – Evan Carroll
    Apr 29 at 18:10













up vote
1
down vote










up vote
1
down vote









You can always use something like tmux which provides capture-pane that does what you want, along with splits (vertical and horizontal) and multiplexing, session support, and a slew of other things.



Or use a different terminal emulator xfce4-terminal is also lightweight and provides an easy Save Contents






share|improve this answer













You can always use something like tmux which provides capture-pane that does what you want, along with splits (vertical and horizontal) and multiplexing, session support, and a slew of other things.



Or use a different terminal emulator xfce4-terminal is also lightweight and provides an easy Save Contents







share|improve this answer













share|improve this answer



share|improve this answer











answered Apr 29 at 16:44









Evan Carroll

4,48683472




4,48683472







  • 1




    To me this does not sound like an answer to the question. None of those programs can magically capture output which at the moment exist only in an xterm window.
    – kasperd
    Apr 29 at 17:56










  • @kasperd a fair interpretation. He wants something that captures without pre-thought. I use tmux without prethought. Then I don't have this problem. If you can get in the habit of using tmux, you'll never have to think about this again (or a lot of other stuff).
    – Evan Carroll
    Apr 29 at 18:10













  • 1




    To me this does not sound like an answer to the question. None of those programs can magically capture output which at the moment exist only in an xterm window.
    – kasperd
    Apr 29 at 17:56










  • @kasperd a fair interpretation. He wants something that captures without pre-thought. I use tmux without prethought. Then I don't have this problem. If you can get in the habit of using tmux, you'll never have to think about this again (or a lot of other stuff).
    – Evan Carroll
    Apr 29 at 18:10








1




1




To me this does not sound like an answer to the question. None of those programs can magically capture output which at the moment exist only in an xterm window.
– kasperd
Apr 29 at 17:56




To me this does not sound like an answer to the question. None of those programs can magically capture output which at the moment exist only in an xterm window.
– kasperd
Apr 29 at 17:56












@kasperd a fair interpretation. He wants something that captures without pre-thought. I use tmux without prethought. Then I don't have this problem. If you can get in the habit of using tmux, you'll never have to think about this again (or a lot of other stuff).
– Evan Carroll
Apr 29 at 18:10





@kasperd a fair interpretation. He wants something that captures without pre-thought. I use tmux without prethought. Then I don't have this problem. If you can get in the habit of using tmux, you'll never have to think about this again (or a lot of other stuff).
– Evan Carroll
Apr 29 at 18:10













 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f440752%2faccess-xterms-scrollback-buffer-as-a-file%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Peggy Mitchell

Palaiologos

The Forum (Inglewood, California)