My build of nnn with minor changes
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.
 
 
 
 
 
 

33 lines
766 B

  1. #!/usr/bin/env sh
  2. # Description: Allows for creation of multiple files/directories at the same time.
  3. # Plugin opens a temp file where each entry is to be written on a separate line
  4. #
  5. # Note: Only relative paths are supported. Absolute paths are ignored
  6. # Leading and trailing whitespace in path names is also ignored
  7. #
  8. # Shell: POSIX compliant
  9. # Author: KlzXS
  10. EDITOR="${EDITOR:-vi}"
  11. TMPDIR="${TMPDIR:-/tmp}"
  12. printf "'f'ile / 'd'ir? "
  13. read -r resp
  14. if [ "$resp" = "f" ]; then
  15. #shellcheck disable=SC2016
  16. cmd='mkdir -p "$(dirname "{}")" && touch "{}"'
  17. elif [ "$resp" = "d" ]; then
  18. cmd='mkdir -p {}'
  19. else
  20. exit 1
  21. fi
  22. tmpfile=$(mktemp "$TMPDIR/.nnnXXXXXX")
  23. $EDITOR "$tmpfile"
  24. sed "/^\//d" "$tmpfile" | xargs -n1 -I{} sh -c "$cmd"
  25. rm "$tmpfile"