diff --git a/dockerfiles/scripts/clean_history.bash b/dockerfiles/scripts/clean_history.bash
new file mode 100644
index 0000000000000000000000000000000000000000..ae1769f567ea6f386c4f4f41c33ee5525d6a5192
--- /dev/null
+++ b/dockerfiles/scripts/clean_history.bash
@@ -0,0 +1,9 @@
+#!/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