blob: 9053b62bc31b600526c1eb5b326e4589b43ae46f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#!/bin/sh
tmp="$(mktemp)"
die ()
{
echo "$1" >&2
}
clear
lsblk -o name,size,type,mountpoint
die "───────────────────────────────────"
lsblk --ascii -o name,mountpoint |
grep '^.-' |
while read line
do
words="$(printf "$line" | wc -w)"
test $words -gt 1 && continue
i=$((${i:-0}+1))
printf "%s. %s\n" "$i" "$(printf "$line" | cut -f 2- -d '-')"
done | tee "$tmp"
read -p '>' choice
dev="$(grep "^$choice\." "$tmp" | cut -f 2- -d ' ')"
if test -n "$dev"
then
die "mounting /dev/$dev on /media/$dev"
test "$(id -u)" != "0" && sudo="sudo"
mkdir -p /media/$dev
$sudo mount /dev/$dev /media/$dev > /dev/null 2>&1 &&
die 'Mounted succesfully.' ||
die 'Failed to mount.'
die 'Press [Enter] to continue.'
head -n 1 > /dev/null
fi
rm -f "$tmp"
|