Skip to content

Instantly share code, notes, and snippets.

@mak3r
Last active January 24, 2020 02:18
Show Gist options
  • Select an option

  • Save mak3r/2f804b0cb8bc4f686ab057815313e55b to your computer and use it in GitHub Desktop.

Select an option

Save mak3r/2f804b0cb8bc4f686ab057815313e55b to your computer and use it in GitHub Desktop.
Capture the command history before moving between projects
#!/bin/sh
#run this in all open terminals
history -a
# run this in the terminal where history (raw and sorted) is being captured
history -a; history -c; history -r
# capture the history to a file
# because sometimes order of operations matters
history > raw.hist
# sort the history by command because sometimes
# we are just looking for a form of a command
cat raw.hist | sed 's/^[ 0-9]*[ ]*//g' | sort -s -u > sorted.hist
# it would be interesting to implement a search
# feature which allowed me to use a line found in
# the sorted file and troll the raw file for pre-history
# I think this command should be called 'big-history'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment