From eac69531505644c2606a85efc7bd09f6bbaa12db Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Tue, 1 Feb 2022 01:15:42 +0100 Subject: [PATCH] zsh:autoload:crypt-*mount: Get basename natively Use zsh's builtin history expansion modifiers `:t` to get the basename of the block device. --- .config/zsh/zshrc.d/40-functions.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.config/zsh/zshrc.d/40-functions.zsh b/.config/zsh/zshrc.d/40-functions.zsh index af6268b..1c3b439 100644 --- a/.config/zsh/zshrc.d/40-functions.zsh +++ b/.config/zsh/zshrc.d/40-functions.zsh @@ -258,7 +258,7 @@ crypt-mount() { [[ -b "$1" ]] local name mount_point - name=crypt_"${1##*/}" + name=crypt_"${1:t}" sudo cryptsetup open "$1" "$name" udisksctl mount -b /dev/mapper/"$name" @@ -285,7 +285,7 @@ crypt-umount() { sync local name mount_point - name=crypt_"${1##*/}" + name=crypt_"${1:t}" mount_point="$( findmnt -lo SOURCE,TARGET \ | grep -F /dev/mapper/"$name" \