aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.zsh.after/udisks.zsh422
1 files changed, 212 insertions, 210 deletions
diff --git a/.zsh.after/udisks.zsh b/.zsh.after/udisks.zsh
index 36f8e78..784c616 100644
--- a/.zsh.after/udisks.zsh
+++ b/.zsh.after/udisks.zsh
@@ -1,3 +1,5 @@
+#!/usr/bin/env bash
+
# udisks_functions: https://bbs.archlinux.org/viewtopic.php?id=109307
# last modified: 2012/08/05
# functions: sdm, sdu, mcm, mcu, srm, sru, fdm, and fdu.
@@ -12,8 +14,8 @@ enable_device_aliases="true"
enable_mmc_aliases="true"
# mount commands:
-mount="sudo udisksctl mount -b"
-unmount="sudo udisksctl unmount -b"
+mount="udisksctl mount -b"
+unmount="udisksctl unmount -b"
# partitions:
device_partition="[1-9]*"
@@ -33,236 +35,236 @@ floppy="fd[0-2]"
# device aliases:
if [[ $enable_device_aliases = true && $enable_device = true ]]; then
- for a in {b..j}; do
- alias sd"$a"m="sdm sd$a"
- alias sd"$a"u="sdu sd$a"
- done
+ for a in {b..j}; do
+ alias sd"$a"m="sdm sd$a"
+ alias sd"$a"u="sdu sd$a"
+ done
fi
# mmc aliases:
if [[ $enable_mmc_aliases = true && $enable_mmc = true ]]; then
- for a in {0..9}; do
- alias mc"$a"m="mcm mmcblk$a"
- alias mc"$a"u="mcu mmcblk$a"
- done
+ for a in {0..9}; do
+ alias mc"$a"m="mcm mmcblk$a"
+ alias mc"$a"u="mcu mmcblk$a"
+ done
fi
# device functions:
if [[ $enable_device = true ]]; then
- sdm() {
- if [ "$2" ]; then
- if [[ "$1" = ?d* ]]; then
- if [[ -b /dev/"$1$2" ]]; then
- $mount /dev/"$1$2"
- fi
- fi
- elif [ "$1" ]; then
- if [[ "$1" = ?d* ]]; then
- if [[ -b /dev/"$1"1 ]]; then
- if [[ "$1" = ????* ]]; then
- $mount /dev/"$1"
- else
- for a in /dev/"$1"$device_partition; do
- $mount "$a"
- done
- fi
- else
- if [[ -b /dev/"$1" ]]; then
- $mount /dev/"$1"
- fi
- fi
- fi
- else
- for a in /dev/$device; do
- if [[ -b "$a"1 ]]; then
- for b in "$a"$device_partition; do
- $mount "$b"
- done
- else
- $mount "$a"
- fi
- done
- fi
- }
+sdm() {
+ if [[ -n "$2" ]]; then
+ if [[ "$1" = ?d* ]]; then
+ if [[ -b /dev/"$1$2" ]]; then
+ $=mount /dev/"$1$2"
+ fi
+ fi
+ elif [[ -n "$1" ]]; then
+ if [[ "$1" = ?d* ]]; then
+ if [[ -b /dev/"$1"1 ]]; then
+ if [[ "$1" = ????* ]]; then
+ $=mount /dev/"$1"
+ else
+ for a in /dev/"$1"$device_partition; do
+ $=mount "$a"
+ done
+ fi
+ else
+ if [[ -b /dev/"$1" ]]; then
+ $=mount /dev/"$1"
+ fi
+ fi
+ fi
+ else
+ for a in /dev/$device; do
+ if [[ -b "$a"1 ]]; then
+ for b in "$a"$device_partition; do
+ $=mount "$b"
+ done
+ else
+ $=mount "$a"
+ fi
+ done
+ fi
+ }
- sdu() {
- if [ "$2" ]; then
- if [[ "$1" = ?d* ]]; then
- if [[ -b /dev/"$1$2" ]]; then
- $unmount /dev/"$1$2"
- fi
- fi
- elif [ "$1" ]; then
- if [[ "$1" = ?d* ]]; then
- if [[ -b /dev/"$1"1 ]]; then
- if [[ "$1" = ????* ]]; then
- $unmount /dev/"$1"
- else
- for a in /dev/"$1"$device_partition; do
- $unmount "$a"
- done
- fi
- else
- if [[ -b /dev/"$1" ]]; then
- $unmount /dev/"$1"
- fi
- fi
- fi
- else
- for a in /dev/$device; do
- if [[ -b "$a"1 ]]; then
- for b in "$a"$device_partition; do
- $unmount "$b"
- done
- else
- $unmount "$a"
- fi
- done
- fi
- }
+ sdu() {
+ if [[ -n "$2" ]]; then
+ if [[ "$1" = ?d* ]]; then
+ if [[ -b /dev/"$1$2" ]]; then
+ $=unmount /dev/"$1$2"
+ fi
+ fi
+ elif [[ -n "$1" ]]; then
+ if [[ "$1" = ?d* ]]; then
+ if [[ -b /dev/"$1"1 ]]; then
+ if [[ "$1" = ????* ]]; then
+ $=unmount /dev/"$1"
+ else
+ for a in /dev/"$1"$device_partition; do
+ $=unmount "$a"
+ done
+ fi
+ else
+ if [[ -b /dev/"$1" ]]; then
+ $=unmount /dev/"$1"
+ fi
+ fi
+ fi
+ else
+ for a in /dev/$device; do
+ if [[ -b "$a"1 ]]; then
+ for b in "$a"$device_partition; do
+ $=unmount "$b"
+ done
+ else
+ $=unmount "$a"
+ fi
+ done
+ fi
+ }
fi
# mmc functions:
if [[ $enable_mmc = true ]]; then
- mcm() {
- if [ "$2" ]; then
- if [[ "$1" = mmcblk* ]]; then
- if [[ -b /dev/"$1$2" ]]; then
- $mount /dev/"$1$2"
- fi
- fi
- elif [ "$1" ]; then
- if [[ "$1" = mmcblk* ]]; then
- if [[ -b /dev/"$1"p0 ]]; then
- if [[ "$1" = ???????* ]]; then
- $mount /dev/"$1"
- else
- for a in /dev/"$1"$mmc_partition; do
- $mount "$a"
- done
- fi
- else
- if [[ -b /dev/"$1" ]]; then
- $mount /dev/"$1"
- fi
- fi
- fi
- else
- for a in /dev/$mmc; do
- if [[ -b "$a"p0 ]]; then
- for b in "$a"$mmc_partition; do
- $mount "$b"
- done
- else
- $mount "$a"
- fi
- done
- fi
- }
+ mcm() {
+ if [[ -n "$2" ]]; then
+ if [[ "$1" = mmcblk* ]]; then
+ if [[ -b /dev/"$1$2" ]]; then
+ $=mount /dev/"$1$2"
+ fi
+ fi
+ elif [[ -n "$1" ]]; then
+ if [[ "$1" = mmcblk* ]]; then
+ if [[ -b /dev/"$1"p0 ]]; then
+ if [[ "$1" = ???????* ]]; then
+ $=mount /dev/"$1"
+ else
+ for a in /dev/"$1"$mmc_partition; do
+ $=mount "$a"
+ done
+ fi
+ else
+ if [[ -b /dev/"$1" ]]; then
+ $=mount /dev/"$1"
+ fi
+ fi
+ fi
+ else
+ for a in /dev/$mmc; do
+ if [[ -b "$a"p0 ]]; then
+ for b in "$a"$mmc_partition; do
+ $=mount "$b"
+ done
+ else
+ $=mount "$a"
+ fi
+ done
+ fi
+ }
- mcu() {
- if [ "$2" ]; then
- if [[ "$1" = mmcblk* ]]; then
- if [[ -b /dev/"$1$2" ]]; then
- $unmount /dev/"$1$2"
- fi
- fi
- elif [ "$1" ]; then
- if [[ "$1" = mmcblk* ]]; then
- if [[ -b /dev/"$1"p0 ]]; then
- if [[ "$1" = ???????* ]]; then
- $unmount /dev/"$1"
- else
- for a in /dev/"$1"$mmc_partition; do
- $unmount "$a"
- done
- fi
- else
- if [[ -b /dev/"$1" ]]; then
- $unmount /dev/"$1"
- fi
- fi
- fi
- else
- for a in /dev/$mmc; do
- if [[ -b "$a"p0 ]]; then
- for b in "$a"$mmc_partition; do
- $unmount "$b"
- done
- else
- $unmount "$a"
- fi
- done
- fi
- }
+ mcu() {
+ if [[ -n "$2" ]]; then
+ if [[ "$1" = mmcblk* ]]; then
+ if [[ -b /dev/"$1$2" ]]; then
+ $=unmount /dev/"$1$2"
+ fi
+ fi
+ elif [[ -n "$1" ]]; then
+ if [[ "$1" = mmcblk* ]]; then
+ if [[ -b /dev/"$1"p0 ]]; then
+ if [[ "$1" = ???????* ]]; then
+ $=unmount /dev/"$1"
+ else
+ for a in /dev/"$1"$mmc_partition; do
+ $=unmount "$a"
+ done
+ fi
+ else
+ if [[ -b /dev/"$1" ]]; then
+ $=unmount /dev/"$1"
+ fi
+ fi
+ fi
+ else
+ for a in /dev/$mmc; do
+ if [[ -b "$a"p0 ]]; then
+ for b in "$a"$mmc_partition; do
+ $=unmount "$b"
+ done
+ else
+ $=unmount "$a"
+ fi
+ done
+ fi
+ }
fi
# optical functions:
if [[ $enable_optical = true ]]; then
- srm() {
- if [ "$1" ]; then
- if [[ "$1" = ? ]]; then
- if [[ -b /dev/sr"$1" ]]; then
- $mount /dev/sr"$1"
- fi
- fi
- else
- for a in /dev/$optical; do
- if [[ -b "$a" ]]; then
- $mount "$a"
- fi
- done
- fi
- }
+ srm() {
+ if [[ -n "$1" ]]; then
+ if [[ "$1" = ? ]]; then
+ if [[ -b /dev/sr"$1" ]]; then
+ $=mount /dev/sr"$1"
+ fi
+ fi
+ else
+ for a in /dev/$optical; do
+ if [[ -b "$a" ]]; then
+ $=mount "$a"
+ fi
+ done
+ fi
+ }
- sru() {
- if [ "$1" ]; then
- if [[ "$1" = ? ]]; then
- if [[ -b /dev/sr"$1" ]]; then
- $unmount /dev/sr"$1"
- fi
- fi
- else
- for a in /dev/$optical; do
- if [[ -b "$a" ]]; then
- $unmount "$a"
- fi
- done
- fi
- }
+ sru() {
+ if [[ -n "$1" ]]; then
+ if [[ "$1" = ? ]]; then
+ if [[ -b /dev/sr"$1" ]]; then
+ $=unmount /dev/sr"$1"
+ fi
+ fi
+ else
+ for a in /dev/$optical; do
+ if [[ -b "$a" ]]; then
+ $=unmount "$a"
+ fi
+ done
+ fi
+ }
fi
# floppy functions:
if [[ $enable_floppy = true ]]; then
- fdm() {
- if [ "$1" ]; then
- if [[ "$1" = ? ]]; then
- if [[ -b /dev/fd"$1" ]]; then
- $mount /dev/fd"$1"
- fi
- fi
- else
- for a in /dev/$floppy; do
- if [[ -b "$a" ]]; then
- $mount "$a"
- fi
- done
- fi
- }
+ fdm() {
+ if [[ -n "$1" ]]; then
+ if [[ "$1" = ? ]]; then
+ if [[ -b /dev/fd"$1" ]]; then
+ $=mount /dev/fd"$1"
+ fi
+ fi
+ else
+ for a in /dev/$floppy; do
+ if [[ -b "$a" ]]; then
+ $=mount "$a"
+ fi
+ done
+ fi
+ }
- fdu() {
- if [ "$1" ]; then
- if [[ "$1" = ? ]]; then
- if [[ -b /dev/fd"$1" ]]; then
- $unmount /dev/fd"$1"
- fi
- fi
- else
- for a in /dev/$floppy; do
- if [[ -b "$a" ]]; then
- $unmount "$a"
- fi
- done
- fi
- }
+ fdu() {
+ if [[ -n "$1" ]]; then
+ if [[ "$1" = ? ]]; then
+ if [[ -b /dev/fd"$1" ]]; then
+ $=unmount /dev/fd"$1"
+ fi
+ fi
+ else
+ for a in /dev/$floppy; do
+ if [[ -b "$a" ]]; then
+ $=unmount "$a"
+ fi
+ done
+ fi
+ }
fi