dotfiles/bin/am
2022-12-23 09:23:47 +01:00

38 lines
657 B
Bash
Executable File

#!/bin/bash
set -e
# TODO
# - mount all partitions by selecting disk
# - usage
# - support for /mnt
# - colors ?
function clear_output() {
local len="$1"
for _ in $(seq 0 "$len"); do
printf '\e[1A\e[K'
done
}
if ! [ -t 1 ]; then
exit 1
fi
COLUMNS=1
while true; do
readarray -t LSBLK <<< "$(lsblk -n --paths --list | grep part)"
select dev in "${LSBLK[@]}"; do
name="$(cut -f1 -d' ' <<< "$dev")"
if mount | grep -q "$name"; then
umount "$name"
else
udisksctl mount -b "$name" > /dev/null
fi
clear_output "${#LSBLK[@]}"
break
done || exit
done