Logging every command output #5713
Replies: 6 comments 1 reply
-
I don't understand your motivation for this, you can simply use the
existing scrollback, which you can save to a file at anytime you like by
pressing ctrl+shift+h and then using the save command in less.
However if you really want to save commands and outputs, it's not that
hard, you just need to save from the first prompt line before the last
output start. See for example how dump_lines_with_attrs works. Prompt
start and output start are attrs. You can send a PR to add a function to
get the last prompt just like there is one to the get last output.
As for doing it automatically, you will need to use remote control. But
given that remote control has capability based security you can lock it
down as tightly as you need.
|
Beta Was this translation helpful? Give feedback.
-
Thank you for the response. The main motivation is that during security assessments (Red Teaming, Thanks for the pointer, it has been a long time since I have touched C, The kitten code is available here, if anyone is interested: I will then take a look at the automation via remote control. Thank you. |
Beta Was this translation helpful? Give feedback.
-
Isn't the script command designed for exactly this? It even has
scriptreplay. Anyway glad you got something that works for you.
|
Beta Was this translation helpful? Give feedback.
-
Yes, I dug a little into script but it handles poorly the TUI applications |
Beta Was this translation helpful? Give feedback.
-
I've been looking for this recently, and the best option I've come up with after trying several is to simply use 'script' as a backup, in case I forget to save it via The following dumps a text file in the current directory with a filename of the current time, and you can see everything you typed and the program output (logged all stdin & stdout).
Should be built in on most Linux machines and maybe MacOS. Ideally the tool I'm using would do the logging itself, but this is sufficiently useful that it gets me where I want to go. |
Beta Was this translation helpful? Give feedback.
-
I recently realized that I might need this feature as well: sometimes the terminal suddenly loses its history, and the mouse scrollback only goes through the command history, not the buffer. In this situation, I can hardly find any way to retrieve the historical output information. |
Beta Was this translation helpful? Give feedback.
-
Hello everyone,
I'd like to be able to log every command output automatically to files. This would be helpful so that one does not need to take note of everything and yet be able to retrieve any piece of information. In the end, a filter may be implemented to limit which command is logged, to what file you save the output, and so on.
I first though of using a ZSH plugin, however it does not seem that simple, since I do not want to mess with any redirection and all from the command line.
So I decided to look into building a new kitten. I figured by using the output type of input to the kitten I am able to retrieve the content of the last command and then do whatever I want with it. However I did not manage to retrieve the command line from the kitten (the command that was actually run). Do you know any solution to also retrieve the last command info? (from the shell extension probably)
Finally, I would love to have the kitten run each time a command finishes, and not just when I press a shortcut. Do you think it is possible? Would I have to enable the remote control of Kitty? I am kind of reluctant to use such thing as it would increase the attack surface of Kitty.
Thank you, and thank you kovidgoyal and al. for this great tool!
Beta Was this translation helpful? Give feedback.
All reactions