Dotfiles, utilities, and other apparatus.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

17 lines
596 B

#!/bin/sh
# This will ensure that entries only appear once (for the most
# recent time in the sequence) in ~/.directory_history. This
# loses a lot of history, so be sure it's what you want. For
# the moment, my use case for that file is basic the h() function
# in ~/.sh_common for navigating dirs, so this is fine.
# Will totally break if a filename contains a newline.
# See moreutils for sponge(1).
# reverse order,
# print only the first instance of a line,
# reverse order again,
# write back to the file
tac ~/.directory_history | unsorted-unique | tac | sponge ~/.directory_history