I run a python script on konsole to print long logging for few hours, then I realized I want to save its output with color, but it's too late to run either script or screen -L to save the output as color text by keeping ANSI escape code.

I tried this trick but no luck, i.e. LD_PRELOAD=./libisatty.so xclip -o -selection clipboard > midnight.log

Is it possible select existing terminal session and save its existing output with ANSI escape code ?

1 Answer 1


no - it's too late. konsole doesn't have a way to get the contents of the screen as characters. That's why you would have to rely upon other programs (such as script) to capture the information.

  • My konsole settings is "Unlimited scrollback" which claims that "scrollback data will be written unencrypted to temporary files.". And I noticed there are big binary file ~161MB /tmp/konsole-k16137.history exists, is it impossible to convert to actual content since it's unencrypted ?
    – 林果皞
    Aug 17, 2019 at 0:25
  • 1
    Good luck with that (see source). It seems that they're storing data structures there rather than ANSI text (you'd need a tool for this, and KDE developers tend to not provide that). Aug 17, 2019 at 1:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.