From 6b3f9c2a769f2bf6a4b6a5c813d28bf55810f3db Mon Sep 17 00:00:00 2001 From: oddlama Date: Fri, 13 May 2022 22:55:15 +0200 Subject: [PATCH] feat: reduce length of device names if under /dev/disk/by-id/ --- configure | 18 ++++++++++++------ scripts/utils.sh | 5 +++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/configure b/configure index 1ea64f4..8ae5c83 100755 --- a/configure +++ b/configure @@ -909,10 +909,12 @@ function PARTITIONING_BOOT_TYPE_menu() { function PARTITIONING_BOOT_DEVICE_tag() { echo " ├ Boot Device"; } function PARTITIONING_BOOT_DEVICE_label() { + local devshort=$PARTITIONING_BOOT_DEVICE + devshort=$(shorten_device "$devshort") if [[ -e "$PARTITIONING_BOOT_DEVICE" ]]; then - echo " ├ ($PARTITIONING_BOOT_DEVICE)" + echo " ├ ($devshort)" else - echo " ├ (\Z1$PARTITIONING_BOOT_DEVICE\Zn)" + echo " ├ (\Z1$devshort\Zn)" fi } function PARTITIONING_BOOT_DEVICE_show() { [[ $PARTITIONING_SCHEME != "custom" ]] && one_of "$PARTITIONING_SCHEME" "existing_partitions"; } @@ -957,10 +959,12 @@ function PARTITIONING_SWAP_menu() { function PARTITIONING_SWAP_DEVICE_tag() { echo " │ └ Swap Device"; } function PARTITIONING_SWAP_DEVICE_label() { local dev=${PARTITIONING_SWAP_DEVICE:-/dev/sdB} + local devshort + devshort=$(shorten_device "$dev") if [[ -e "$dev" ]]; then - echo " │ └ ($dev)" + echo " │ └ ($devshort)" else - echo " │ └ (\Z1$dev\Zn)" + echo " │ └ (\Z1$devshort\Zn)" fi } function PARTITIONING_SWAP_DEVICE_show() { [[ $PARTITIONING_SCHEME != "custom" ]] && is_on "$PARTITIONING_USE_SWAP" && one_of "$PARTITIONING_SCHEME" "existing_partitions"; } @@ -1087,10 +1091,12 @@ function PARTITIONING_BTRFS_RAID_TYPE_menu() { function PARTITIONING_DEVICE_tag() { echo " └ Device"; } function PARTITIONING_DEVICE_label() { + local devshort=$PARTITIONING_DEVICE + devshort=$(shorten_device "$devshort") if [[ -e "$PARTITIONING_DEVICE" ]]; then - echo " └ ($PARTITIONING_DEVICE)" + echo " └ ($devshort)" else - echo " └ (\Z1$PARTITIONING_DEVICE\Zn)" + echo " └ (\Z1$devshort\Zn)" fi } function PARTITIONING_DEVICE_show() { [[ $PARTITIONING_SCHEME != "custom" ]] && one_of "$PARTITIONING_SCHEME" "classic_single_disk" "existing_partitions"; } diff --git a/scripts/utils.sh b/scripts/utils.sh index 39e23c5..151de1b 100644 --- a/scripts/utils.sh +++ b/scripts/utils.sh @@ -239,6 +239,11 @@ function create_resolve_entry_device() { DISK_ID_TO_RESOLVABLE[$id]="device:$dev" } +# Returns the basename of the device, if its path starts with /dev/disk/by-id/ +function shorten_dev() { + echo -n "${1#/dev/disk/by-id/}" +} + # Return matching device from /dev/disk/by-id/ if possible, # otherwise return the parameter unchanged. function canonicalize_device() {