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.
 
 
 
 
 
 

36 lines
901 B

  1. #!/usr/bin/env bash
  2. # Description: Splits the file passed as argument or joins selection
  3. #
  4. # Note: Adds numeric suffix to split files
  5. # Adds '.join' suffix to the first file to be joined and saves as output file for join
  6. #
  7. # Shell: Bash
  8. # Author: Arun Prakash Jana
  9. selection=~/.config/nnn/.selection
  10. echo -n "press 's' (split current file) or 'j' (join selection): "
  11. read resp
  12. if [ "$resp" = "j" ]; then
  13. if [ -s "$selection" ]; then
  14. arr=$(cat $selection | tr '\0' '\n')
  15. { read -r file; } <<< "$arr"
  16. file=$(basename "$file").out
  17. cat "$selection" | sort -z | xargs -0 -i cat {} > "$file"
  18. fi
  19. elif [ "$resp" = "s" ]; then
  20. if ! [ -z "$1" ] && [ -f "$1" ] ; then
  21. # a single file is passed
  22. echo -n "split size in MB: "
  23. read size
  24. if ! [ -z "$size" ]; then
  25. split -d -b "$size"M "$1" "$1"
  26. fi
  27. fi
  28. fi