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

48 строки
1.3 KiB

  1. #!/usr/bin/env sh
  2. # Description: Splits the file passed as argument or joins selection
  3. #
  4. # Note: Adds numeric suffix to split files
  5. # Adds '.out suffix to the first file to be joined and saves as output file for join
  6. #
  7. # Shell: POSIX compliant
  8. # Authors: Arun Prakash Jana, ath3
  9. selection=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection
  10. resp=s
  11. if [ -s "$selection" ]; then
  12. echo -n "press 's' (split current file) or 'j' (join selection): "
  13. read resp
  14. fi
  15. if [ "$resp" = "j" ]; then
  16. if [ -s "$selection" ]; then
  17. arr=$(tr '\0' '\n' < "$selection")
  18. if [ "$(echo "$arr" | wc -l)" -lt 2 ]; then
  19. echo "joining needs at least 2 files"
  20. exit
  21. fi
  22. for entry in $arr
  23. do
  24. if [ -d "$entry" ]; then
  25. echo "cant join directories"
  26. exit
  27. fi
  28. done
  29. file="$(basename "$(echo "$arr" | sed -n '1p' | sed -e 's/[0-9][0-9]$//')")"
  30. sort -z < "$selection" | xargs -0 -I{} cat {} > "${file}.out"
  31. fi
  32. elif [ "$resp" = "s" ]; then
  33. if [ -n "$1" ] && [ -f "$1" ]; then
  34. # a single file is passed
  35. echo -n "split size in MB: "
  36. read size
  37. if [ -n "$size" ]; then
  38. split -d -b "$size"M "$1" "$1"
  39. fi
  40. fi
  41. fi