lsdisk - Uses udev's /etc/disk/ to list block devices with their LABEL, UUID and IDs
authorBernhard Tittelbach <bernhard@tittelbach.org>
Fri, 8 Jul 2011 11:32:28 +0000 (13:32 +0200)
committerMichael Prokop <mika@grml.org>
Thu, 21 Jul 2011 08:56:58 +0000 (10:56 +0200)
doc/grmlzshrc.t2t
etc/zsh/zshrc

index 1d810ab..09311ea 100644 (file)
@@ -699,6 +699,9 @@ directory.
 Prints specified range of (numbered) lines of a file.
 Usage: linenr <start>[,<end>] <file>
 
+: **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.
index c1b4955..9c6fd94 100644 (file)
@@ -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