+export gsu_prefs_txt="
+Print the current preferences.
+
+Usage: prefs [-e]
+
+If -e is given, the config file is opened with the default editor. Without
+options, the command prints out a list of all cmt config variables, together
+with their current value and the default value."
+_com_prefs()
+{
+ local i conf="${gsu_config_file:=$HOME/.$gsu_name.rc}"
+
+ if [[ "$1" = "-e" ]]; then
+ ret=-$E_GSU_MKDIR
+ result="${conf%/*}"
+ mkdir -p "$result"
+ [[ $? -ne 0 ]] && return
+ ret=-$E_GSU_EDITOR
+ result="${EDITOR:-vi}"
+ "$result" "$conf"
+ [[ $? -ne 0 ]] && return
+ ret=$GSU_SUCCESS
+ return
+ fi
+
+ for ((i=0; i < ${#gsu_options[@]}; i++)); do
+ local name= option_type= default_value= required=
+ local description= help_text=
+ eval "${gsu_options[$i]}"
+ eval val='"$'${gsu_config_var_prefix}_$name'"'
+ case "$required" in
+ true|yes)
+ printf "# required"
+ ;;
+ *)
+ printf "# optional"
+ ;;
+ esac
+ printf " $option_type: $description"
+ if [[ "$required" != "yes" && "$required" != "true" ]]; then
+ printf " [$default_value]"
+ fi
+ echo
+ [[ -n "$help_text" ]] && sed -e '/^[ ]*$/d; s/^[ ]*/# /g' <<< "$help_text"
+ printf "$name=$val"
+ [[ "$val" == "$default_value" ]] && printf " # default"
+ echo
+ done
+}
+export -f _com_prefs
+