My build of nnn with minor changes
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

42 lines
1.0 KiB

  1. #!/usr/bin/env sh
  2. # Description: Toggle mount status of a device using pmount
  3. # If the device is not mounted, it will be mounted.
  4. # If the device is mounted, it will be unmounted and powered down.
  5. #
  6. # Note: The script uses Linux-specific lsblk to list block devices. Alternatives:
  7. # macOS: "diskutil list"
  8. # BSD: "geom disk list"
  9. #
  10. # Shell: POSIX compliant
  11. # Author: Arun Prakash Jana
  12. lsblk
  13. echo
  14. echo "Make sure you aren't still in the mounted device."
  15. echo -n "device (e.g. sdc2): "
  16. read dev
  17. while ! [ -z "$dev" ]
  18. do
  19. if grep -qs "$dev " /proc/mounts; then
  20. sync
  21. pumount "$dev"
  22. if [ "$?" -eq "0" ]; then
  23. echo "$dev" unmounted.
  24. udisksctl power-off -b /dev/"$dev"
  25. if [ "$?" -eq "0" ]; then
  26. echo "$dev" ejected.
  27. fi
  28. fi
  29. else
  30. pmount "$dev"
  31. echo "$dev" mounted to "$(lsblk -n /dev/"$dev" | rev | cut -d' ' -f1 | rev)".
  32. fi
  33. echo
  34. echo -n "next device: "
  35. read dev
  36. done