dotfiles/bin/am
2024-03-02 17:23:58 +01:00

49 lines
934 B
Bash
Executable File

#!/bin/bash -e
# TODO
# mount all partitions by selecting disk
# usage
# support for /mnt
function get_row() {
local row _col
IFS=';' read -sdR -p $'\e[6n' row _col
echo "${row#??}"
}
ROW="$(($(get_row) + 1))"
function clear_output() {
local row
row="$(get_row)"
for _ in $(seq "$ROW" "$row"); do
printf '\e[1A\e[K'
done
}
function main() {
while true; do
readarray -t LSBLK <<< "$(lsblk -n --paths --list | grep part)"
COLUMNS=1
select dev in "${LSBLK[@]}"; do
if [ -z "$dev" ]; then
clear_output
break
fi
name="$(awk '{print $1}' <<< "$dev")"
clear_output
if mount | grep -q "$name"; then
umount "$name"
else
udisksctl mount -b "$name" > /dev/null
fi
break
done || exit
done
}
main "$@"