diff options
| author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-07-18 17:54:49 +0200 | 
|---|---|---|
| committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-07-18 17:54:49 +0200 | 
| commit | d5158bec4773adc8b08b85fd9dfbc517ab2450c9 (patch) | |
| tree | ba8d05b0974b0fe866b99bd72bcc495f293da88d /bin/common | |
| parent | 899c6a9227cea23cc226148bc0b6afaa2780d81d (diff) | |
added amount
Diffstat (limited to 'bin/common')
| -rwxr-xr-x | bin/common/amount | 36 | 
1 files changed, 36 insertions, 0 deletions
diff --git a/bin/common/amount b/bin/common/amount new file mode 100755 index 0000000..8d235e4 --- /dev/null +++ b/bin/common/amount @@ -0,0 +1,36 @@ +#!/bin/sh + +tmp="$(mktemp)" + +die () +{ +	echo "$1" >&2 +} + +clear +lsblk -o name,size,type,mountpoints +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" +	sudo mount --mkdir /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"  | 
