Skip to content

Instantly share code, notes, and snippets.

@wwalker
Created August 8, 2016 23:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wwalker/c2677ec6dfef31cdaecad855e3f4df60 to your computer and use it in GitHub Desktop.
Save wwalker/c2677ec6dfef31cdaecad855e3f4df60 to your computer and use it in GitHub Desktop.
#!/bin/bash
# version 0.0.1
LOCALHISTFILE=/tmp/$USER.history.$$;
read -d '' RUN << EOF
export HISTFILE=$LOCALHISTFILE;
export HISTTIMEFORMAT='%F %T - '
bash -i;
awk '{print \"HIST \"\$0}' \$HISTFILE;
EOF
ssh $1 "cat > $LOCALHISTFILE" < ~/.bash_history-$1
ssh -t $1 "$RUN" | tee /tmp/$USER-remote-history
grep '^HIST ' /tmp/$USER-remote-history | sed -e 's/^HIST //' -e 's/ //' > ~/.bash_history-$1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment