remote_sync 400 B

12345678910111213
  1. #!/bin/bash
  2. # version 0.0.1
  3. LOCALHISTFILE=/tmp/$USER.history.$$;
  4. read -d '' RUN << EOF
  5. export HISTFILE=$LOCALHISTFILE;
  6. export HISTTIMEFORMAT='%F %T - '
  7. bash -i;
  8. awk '{print \"HIST \"\$0}' \$HISTFILE;
  9. EOF
  10. ssh $1 "cat > $LOCALHISTFILE" < ~/.bash_history-$1
  11. ssh -t $1 "$RUN" | tee /tmp/$USER-remote-history
  12. grep '^HIST ' /tmp/$USER-remote-history | sed -e 's/^HIST //' -e 's/^M//' > ~/.bash_history-$1