X-Git-Url: https://git.grml.org/?a=blobdiff_plain;f=usr_share_grml%2Fzsh%2Ffunctions%2Flsdisk;fp=usr_share_grml%2Fzsh%2Ffunctions%2Flsdisk;h=ef0a64e24ddd2872d4d36a123459c844a129ab8c;hb=919ba75cf1d271284dbef293bf372cf279914bcf;hp=0000000000000000000000000000000000000000;hpb=cc1840a8fd17bb909345c234abb8769f52dfcbd2;p=grml-etc-core.git diff --git a/usr_share_grml/zsh/functions/lsdisk b/usr_share_grml/zsh/functions/lsdisk new file mode 100644 index 0000000..ef0a64e --- /dev/null +++ b/usr_share_grml/zsh/functions/lsdisk @@ -0,0 +1,40 @@ +# show labels and uuids of disk devices +emulate -L zsh +setopt extendedglob + +local -a -U disks +local -A mountinfo + +disks=( /dev/disk/by-id/*(N@:A) ) + +if (( ${#disks} == 0 )); then + printf 'No disks detected.\n' + return 1 +fi + +if [[ -r /proc/mounts ]]; then + for cline in "${(f)$(}/${dev:t}/size(N) + do + print -f " Size: %.3f GiB (%d Byte)\n" \ + $(($(<$sysdevsize)/(2.0*1024.0*1024.0))) \ + $(($(<$sysdevsize)*512)) + done + + print -f " Id: %s\n" /dev/disk/by-id/*(@e/'[[ ${REPLY:A} == $dev ]]'/N:t) +done