|
|
- #!/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
|