News for hackers. Stuff that matters.
Re:Show HN: Private cloud shell history. Open source server ... by ajphdiv on Monday February 10, 2020 @11:50AM (#22290777)
I always find my history not complete when using tmux. I started using these functions in my profile to collect everything. I don't remember the source of the functions.

  log_bash_persistent_history()
  {
      [[
          $(history 1) =~ ^\ *[0-9]+\ +([^\ ]+\ [^\ ]+)\ +(.*)$
      ]]
      local date_part="${BASH_REMATCH[1]}"
      local command_part="${BASH_REMATCH[2]}"
      if [ "$command_part" != "$PERSISTENT_HISTORY_LAST" ]
      then
          echo $date_part "|" "$command_part" >> ~/.persistent_history
          export PERSISTENT_HISTORY_LAST="$command_part"
      fi
  }

  run_on_prompt_command()
  {
      log_bash_persistent_history
  }


  alias phgrep='cat ~/.persistent_history|grep --color'
I like the idea of a hub, as I do a lot of work inside docker containers and vms -- so this could be tailored to help me collect all my history.
Re:Show HN: Private cloud shell history. Open source server ... by jdevera on Monday February 10, 2020 @03:00PM (#22292634)
Re:Show HN: Private cloud shell history. Open source server ... by masukomi on Monday February 10, 2020 @12:18PM (#22291036)
not sure if this is your problem but i think most shells (like bash) don't add the history in their buffer to the common history until you close the session. thus recent history in one window is different than another. That _may_ be what you're dealing with. I believe there are ways to tweak it to always write everything to the common history immediately.