dotfiles/.local/bin/scripts/moul

9 lines
388 B
Bash
Executable File

#!/bin/sh -e
# Mount a partition by label or device identifier automatically
#test "$1" = "-u" && umount "$mountpoint"; exit $?
mountpoint="${2:-${XDG_RUNTIME_DIR:-/mnt}/$1}"
case "$1" in (sd*|loop*) partition="/dev/$1";; (*) partition="-L $1";; esac
mountpoint "$mountpoint" >/dev/null || sudo mount -v -o users,X-mount.mkdir $partition "$mountpoint" "${@:3}"
cd $mountpoint
exec $SHELL