I expect history to be the same as at the time of closing the terminal together with session.
Created attachment 9553 Restore scrollback history on save session I've always wanted xfce4-terminals to preserve scrollback history across reboots/logouts. Sometimes I omit powering off my machine only due to the fact that I will lose history across terminals as I have many of them. Unfortunately this is not green at all. Moreover if I do shutdown my machine the next day it's pretty hard to restart my work the way it was prior to shutdown. Yes, there are instruments like tmux/screen (and yes I use them myself) but they may be a burden for ordinary users. Please consider the following patch. It basically does: 1) Scrollback history is saved across logouts/reboots if enabled via xfce4-terminal's preferences and if 'Save session for future logins' is checked. 2) Environment variable TAB_ID is exported in every terminal screen. It's a 16 character version of a SHA256 checksum. A seed identical to role-id is used for the generation of the checksum. 3) Scrollbacks are private to the user itself. They're stored in ~/.cache/xfce4/terminal/. They're GZIP compressed as well. Saving is done immediately on logging out which is tied to the 'save-session' event. 4) On logging in and after restoration scrollback files are deleted. 5) Since such histories may expose sensitive data everything is configurable and can be disabled thus no scrollback files will be saved at all. 6) It's up to the user to decide what fits him/her best and if this violates security or other implications user can omit using it. As a future work, I think shell history may be tied per terminal. When time permits I can go and investigate this idea further. I think this will be a nice add-on to this feature. Please share your opinions and provide some code review if you're positively inclined to incorporating this feature. Regards, Boris
Hi Boris, thanks for your effort and putting together a patch, that's greatly appreciated! The feature itself, however... I'm not quite sure it should be implemented as part of the terminal. I think security concerns are very high with this kind of a feature. Even if the feature is disabled by default, I could totally see a user, having enabled it once and forgotten about that, find their sensitive data in jeopardy some day. In fact, I'm pretty sure I've seen a request like for gnome-terminal/vte that has been declined. I cannot seem to find it right now for some reason, though.
Hello, Igor, Thanks for the reply. //The feature itself, however... I'm not quite sure it should be implemented as part of the terminal. Here's my point of view and what made me put some effort and get involved in writing this feature in xfce4-terminal itself. I use tmux with plugins like resurrect and continuum to have this feature and yet it's not as convenient as I would like (mouse capturing on purpose or not, clipboard...clipboards over ssh are not the same as on desktop machine and many many more nagging hurdles). Yet tmux is super and I will continue using it. But In my opinion tmux costs lots of efforts to setup whereas when done in the terminal as done in the patch users can optionally configure it and take full advantage and optimize their work across day to day reboots without setting up any additional tools. It may sound laughable but I don't shutdown any machines because time is precious to resurrect terminals and their history and details and continue working after a reboot. Now I can easily continue working having a brief history where I'd stopped prior to the reboot. This improves organization. There are lots of terminals out there and yet none has this feature and I consider it valuable as it ease transition across day to day reboots. To me this makes xfce4-terminal not just a terminal like anyone else out there but a terminal with a better user experience. I think I saw this feature in a OSX environment and thought to myself - I will have this on my linux deskop and here it is. I don't claim however it's the best approach to writing it. I'm open to reviews and suggestions however. //I think security concerns are very high with this kind of a feature. I can't but agree with you here and yet.. //Even if the feature is disabled by default, I could totally see a user, having enabled it once and forgotten about that, find their sensitive data in jeopardy some day. Saving data is done only across saving a session - i.e logging out/a reboot/a shutdown. Nothing is persisted at all if the save session option is not checked on the logout menu. More over it can be fully disabled from the preferences menu as you'd seen in the patch. It's just my point of view that if user wants to use it then let it be this way. Moreover files are gzip compressed and given 600 permissions hence only the user itself can read it. Well, if home directory gets compromised that's another story but it's not just these files in there. As a matter of facts encrypting home directories is very common these days. Bash history for example is totally visible as well and it's enabled by default. What I put emphasis here is that it's configurable and it's up to user's decision whether or not to use it. For sure disabled by default is the right approach. //In fact, I'm pretty sure I've seen a request like for gnome-terminal/vte that has been declined. I cannot seem to find it right now for some reason, though. I'm interested in this topic and yet optimizing working process and user experience matter as well. I would like you to not take this reply as something offensive it's just my point of view and my attempt to make user (my) life easier. Best regards
Boris, your patch sound good. I did not try it yet, because I am not used to building Xfce software from source. Another approach is that terminal has its own session management independent of xfce session like many web browsers do, so it would remember tabs, current directories and history for each tab. Possibly user could save several sessions and open them. Maybe that would not work well together with xfce session, though.
(In reply to Boris Astardzhiev from comment #1) > As a future work, I think shell history may be tied per terminal. When time > permits I can go and investigate this idea further. I think this will be a > nice add-on to this feature. Why not tie history per terminal tab? I guess shells HISTFILE variable could be used for that.
Hello Jarno, > Boris, your patch sound good. I did not try it yet, because I am not used to building Xfce software from source. > Another approach is that terminal has its own session management independent of xfce session like > many web browsers do, so it would remember tabs, current directories and history for each tab. > Possibly user could save several sessions and open them. Maybe that would not work well together > with xfce session, though. Thanks for the reply. To be honest I've tried to rely as much as possible on existing code. > Why not tie history per terminal tab? I guess shells HISTFILE variable could be used for that. Thanks for the idea. I tried it further and at first glance it seems to work pretty well - now I have shell history per terminal/tab along with the scrollback history and all of this is restored across reboots. And this by simply adding a small snippet to .bashrc: PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND" if [ ! -z "$TAB_ID" ]; then HISTFILE_DIR=$HOME/shell_history HISTFILE_ARCHIVE_DIR=$HISTFILE_DIR/archive mkdir -m 700 -p $HISTFILE_DIR mkdir -m 700 -p $HISTFILE_ARCHIVE_DIR HISTFILE_DEST=$HISTFILE_DIR/$TAB_ID HISTFILE_ARCHIVE_DEST=$HISTFILE_ARCHIVE_DIR/$TAB_ID function pop_shell_history { if [ -f "$HISTFILE_ARCHIVE_DEST" ]; then # revive from archive mv $HISTFILE_ARCHIVE_DEST $HISTFILE_DEST elif [ ! -f $HISTFILE_DEST ]; then # combine history from all existing tabs # or we'll start with an empty list but # it's slightly better to have history from # recent tabs for hist in $(find $HISTFILE_DIR -maxdepth 1 -type f) do cat $hist >> $HISTFILE_DEST done fi HISTFILE=$HISTFILE_DEST } # peek at archive pop_shell_history function push_shell_history { history -a; mv $HISTFILE_DEST $HISTFILE_ARCHIVE_DIR } # on exit save shell history in the archive trap push_shell_history EXIT fi A rough edge is that archive are not deleted if a terminal is closed. This may be easily adapted to other shells. Apart from the edges it's nice to fully restore your workspace across reboots! No engineer throws workspace at the end of the day just to start from scratch tomorrow. Regards
-- GitLab Migration Automatic Message -- This bug has been migrated to xfce.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.xfce.org/apps/xfce4-terminal/-/issues/19. Please create an account or use an existing account on one of our supported OAuth providers. If you want to fork to submit patches and merge requests please continue reading here: https://docs.xfce.org/contribute/dev/git/start#gitlab_forks_and_merge_requests Also feel free to reach out to us on the mailing list https://mail.xfce.org/mailman/listinfo/xfce4-dev