Skip to content
Snippets Groups Projects
Commit 55238de7 authored by Montaño Sarria, Andres Felipe's avatar Montaño Sarria, Andres Felipe
Browse files

Add script to clean history

parent 76c95be1
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
sed ':start; /\\$/ { N; s/\\\n/\\\x00/; b start }' .zsh_history # join multiline commands
| nl -nrz # add line numbers so we can restore the original order
| tac | sort -t';' -u -k2 # sort and remove duplicate commands, keeping the last occurrence
| sort # sort on line numbers
| cut -d$'\t' -f2- # remove the line numbers
| tr '\000' '\n' # restore multiline commands
> .zsh_history_deduped
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment