From: Bernhard Tittelbach Date: Fri, 8 Jul 2011 11:32:28 +0000 (+0200) Subject: lsdisk - Uses udev's /etc/disk/ to list block devices with their LABEL, UUID and IDs X-Git-Tag: v0.4.00~27 X-Git-Url: http://git.grml.org/?a=commitdiff_plain;ds=sidebyside;h=515cabf5944aa1d1b31e71393d0cf38adc97782d;p=grml-etc-core.git lsdisk - Uses udev's /etc/disk/ to list block devices with their LABEL, UUID and IDs --- diff --git a/doc/grmlzshrc.t2t b/doc/grmlzshrc.t2t index 1d810ab..09311ea 100644 --- a/doc/grmlzshrc.t2t +++ b/doc/grmlzshrc.t2t @@ -699,6 +699,9 @@ directory. Prints specified range of (numbered) lines of a file. Usage: linenr [,] +: **lsdisk()** +Uses udev's /dev/disk to list block devices with their LABEL, UUID and IDs. + : **makereadable()** Creates a PostScript and a PDF file (basename as first argument) from source code files. diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index c1b4955..9c6fd94 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -3573,6 +3573,20 @@ purge() { fi } +#f5# show labels and uuids of disk devices +if is439 && [[ -d /dev/disk/by-id/ ]]; then + lsdisk() { + emulate -L zsh + setopt extendedglob + local -a -U disks + disks=( /dev/disk/by-id/*(@:A) ) + for dev in "$disks[@]"; do + print ${fg_bold[red]}${dev}${reset_color} /dev/disk/by-label/*(@e/'[[ ${REPLY:A} == $dev ]] && REPLY=${fg[blue]}LABEL=${REPLY:t}${reset_color}'/N) /dev/disk/by-uuid/*(@e/'[[ ${REPLY:A} == $dev ]] && REPLY=${fg[green]}UUID=${REPLY:t}${reset_color}'/N) + print -f " %s\n" /dev/disk/by-id/*(@e/'[[ ${REPLY:A} == $dev ]]'/N:t) + done + } +fi + # Translate DE<=>EN # 'translate' looks up fot a word in a file with language-to-language # translations (field separator should be " : "). A typical wordlist looks