My build of nnn with minor changes
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

45 lignes
1.2 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:
  7. # - The script uses Linux-specific lsblk to list block devices. Alternatives:
  8. # macOS: "diskutil list"
  9. # BSD: "geom disk list"
  10. # - The script uses udisksctl (from udisks2) to pwoer down devices. This is also Linux-specific.
  11. # Users on non-Linux platforms can comment it and use an alterntive to power-down disks.
  12. #
  13. # Shell: POSIX compliant
  14. # Author: Arun Prakash Jana
  15. lsblk
  16. echo
  17. echo "Make sure you aren't still in the mounted device."
  18. echo -n "device (e.g. sdc2): "
  19. read dev
  20. while ! [ -z "$dev" ]
  21. do
  22. if grep -qs "$dev " /proc/mounts; then
  23. sync
  24. pumount "$dev"
  25. if [ "$?" -eq "0" ]; then
  26. echo "$dev" unmounted.
  27. udisksctl power-off -b /dev/"$dev"
  28. if [ "$?" -eq "0" ]; then
  29. echo "$dev" ejected.
  30. fi
  31. fi
  32. else
  33. pmount "$dev"
  34. echo "$dev" mounted to "$(lsblk -n /dev/"$dev" | rev | cut -d' ' -f1 | rev)".
  35. fi
  36. echo
  37. echo -n "next device: "
  38. read dev
  39. done