]> git.tuebingen.mpg.de Git - gsu.git/blobdiff - subcommand
gui: Remember menu position.
[gsu.git] / subcommand
index 817486dba0c43564701095b49f2069498da9ee6b..d37481cdbdccb5b62268d3b788de84b61a2ab347 100644 (file)
@@ -684,7 +684,21 @@ com_help()
                                y/\n/'"$tab"'/
 
                                # and print the sucker
-                               p'
+                               p
+                       ' | {
+                               local -a cmds=() descs=()
+                               local -i i maxlen=1
+                               local cmd desc
+                               while read cmd desc; do
+                                       ((maxlen < ${#cmd})) && maxlen=${#cmd}
+                                       cmds[${#cmds[@]}]=$cmd
+                                       descs[${#descs[@]}]=$desc
+                               done
+                               for ((i = 0; i < ${#cmds[@]}; i++)); do
+                                       printf '%-*s %s\n' $maxlen ${cmds[$i]} \
+                                               "${descs[$i]}"
+                               done
+                       }
                printf "\n# Try %s help <command> for info on <command>, or %s help -a to see\n" \
                        "$gsu_name" "$gsu_name"
                printf '# also the subcommands which are automatically generated by gsu.\n'