My build of nnn with minor changes
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

52 строки
1.4 KiB

  1. #!/usr/bin/env sh
  2. # Description: Use named bookmarks using symlinks
  3. #
  4. # Dependencies: fzf
  5. #
  6. # Usage:
  7. # 1. Create a $BOOKMARKS_DIR directory
  8. # By default, $BOOKMARKS_DIR is set to: ${XDG_CACHE_HOME:-$HOME/.cache}/nnn/bookmarks
  9. #
  10. # 2. Create symlinks to directories
  11. # `cd $BOOKMARKS_DIR`
  12. # `ln -s /path/to/useful/directory bookmark_name`
  13. # `ln -s $XDG_CONFIG_HOME/nnn/plugins nnn_plugins"
  14. # `ln -s /path/to/documents docs`
  15. # `ln -s /path/to/media media`
  16. # `ln -s /path/to/movies movies`
  17. #
  18. # Bonus tip: Add `$BOOKMARKS_DIR` to your `$CDPATH`
  19. #
  20. # TODO:
  21. # 1. Remove `fzf` dependency
  22. #
  23. # Shell: POSIX compliant
  24. # Author: Todd Yamakawa
  25. BOOKMARKS_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/nnn/bookmarks"
  26. # Check if NNN_PIPE is set
  27. [ -z "$NNN_PIPE" ] && { echo 'NNN_PIPE is not set'; exit 2; }
  28. # Get all directory symlinks
  29. get_links() {
  30. for entry in "$1"/*; do
  31. # Skip unless directory symlink
  32. [ -h "$entry" ] || continue
  33. [ -d "$entry" ] || continue
  34. echo "$(basename "$entry") -> $(readlink -f "$entry")"
  35. done | column -t
  36. }
  37. # Choose symlink with fzf
  38. cddir="$(get_links "$BOOKMARKS_DIR" | fzf | awk 'END { print "'"$BOOKMARKS_DIR"'/"$1 }')"
  39. # Writing result to NNN_PIPE will change nnn's active directory
  40. # https://github.com/jarun/nnn/tree/master/plugins#send-data-to-nnn
  41. context=0
  42. printf "%s" "${context}c$(readlink -f "$cddir")" > "$NNN_PIPE"