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

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