Another copy of my dotfiles. Because I don't completely trust GitHub.
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.

44 lines
985 B

  1. #!/usr/bin/env sh
  2. cleanup() {
  3. rm -r "$LF_UEBERZUG_TEMPDIR" 2>/dev/null
  4. kill $ueberzugpid 2>/dev/null
  5. }
  6. export LF_UEBERZUG_TEMPDIR="$(mktemp -d -t lf-ueberzug-XXXXXX)"
  7. trap cleanup INT
  8. export LF_UEBERZUG_FIFO="$LF_UEBERZUG_TEMPDIR/fifo"
  9. mkfifo "$LF_UEBERZUG_FIFO"
  10. tail -f "$LF_UEBERZUG_FIFO" | ueberzug layer --silent &
  11. ueberzugpid=$!
  12. last_dir="$([ ! -f $XDG_RUNTIME_DIR/lf-last-dir ] || cat $XDG_RUNTIME_DIR/lf-last-dir)"
  13. fid="$(mktemp)"
  14. prev=$(pwd)
  15. cd $last_dir
  16. lf -command '$printf $id > '"$fid"'' -last-dir-path=$XDG_RUNTIME_DIR/lf-last-dir "$@"
  17. cd $prev
  18. id="$(cat "$fid")"
  19. archivemount_dir="$XDG_RUNTIME_DIR/__lf_archivemount_$id"
  20. if [ -f "$archivemount_dir" ]; then
  21. cat "$archivemount_dir" | \
  22. while read -r line; do
  23. sudo umount "$line"
  24. rmdir "$line"
  25. done
  26. rm -f "$archivemount_dir"
  27. fi
  28. if [ -f "$tmp" ]; then
  29. dir="$(cat "$tmp")"
  30. rm -f "$tmp"
  31. if [ -d "$dir" ]; then
  32. if [ "$dir" != "$(pwd)" ]; then
  33. cd "$dir"
  34. fi
  35. fi
  36. fi
  37. cleanup