forked from spencertipping/cd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcd-dev
30 lines (25 loc) · 723 Bytes
/
cd-dev
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
#!/bin/bash
# Single-user /dev/X mounting | Spencer Tipping
# Licensed under the terms of the MIT source code license
# You can use syntax like /dev/sda1::foo to mount the "foo" subvolume, in cases
# where this applies (e.g. btrfs).
cd_on '([-/]dev[-/].*)' cd_dev_mount cd_dev_umount
function cd_dev_mount {
if [[ "$1" =~ ::(.*)$ ]]; then
if [[ -n $ZSH_VERSION ]]; then
local opts="-o subvol=${match[1]}"
local device="${1%::*}"
else
local opts="-o subvol=${BASH_REMATCH[1]}"
local device="${1%::*}"
fi
else
local device="$1"
local opts=''
fi
shift
cd_mount "cd_as_root mount $opts" "$device" "$@"
}
function cd_dev_umount {
cd_umount "cd_as_root umount" "$@"
}