Bash script for instant CLI to cheat sheet

Here is code I working on that scans the hestia/bin dir and captures data and creates a hestiacp.cheat file formatted for navi (with variables for input options).

cd /usr/local/hestia/bin || exit
echo “% HestiaCP” > “$cheat_file”
for file in *; do
info=$(awk ‘/^# info:/ { sub("^# info: ", “”, $0); print $0; }’ “$file”)
options=$(awk ‘/^# options:/ { sub("^# options: ", “”, $0); print $0; }’ “$file”)
formatted_options=$(grep -oE ‘[^[][A-Z_]+[^]]’ <<< “$options”)
formatted_options=$(sed -E ‘s/([A-Z_]+)/<\L\1>/g’ <<< “$formatted_options”)
formatted_options=$(tr -s ’ ’ <<< “$formatted_options”)
formatted_options=$(tr -d ‘\n’ <<< “$formatted_options”)
echo “# $info” >> “$cheat_file”
echo “$file $formatted_options” >> “$cheat_file”
echo >> “$cheat_file”

It works almost perfect. Like 99% accurate.
options that were in [ ] in the bash file are phrased without a space.


# change user nameservers
v-change-user-ns <user> <ns>1 <ns>2<ns>3<ns>4<ns>5<ns>6<ns>7<ns>8

it did not interpret this line right

# options: USER NS1 NS2 [NS3] [NS4] [NS5] [NS6] [NS7] [NS8]

# update system ip
v-update-sys-ip <none>
# options: NONE

It needs to ignore the use of NONE

# archive directory
v-add-fs-archive <user> <archive> <source> <source>.

I think this is more a hetis cli script issue with…

Can anyone fix the last few issues? I’ve got to my limit of my skills at this point. (I’ve only started learning how to write bash scripts less then a month. Figured its time to get better at it then just running basic commands) So please forgive me if the answer is something stupid easy.

I think if the last few things were fixed this would be a great help for the community. Or even useful if made part of hestia’s installer. When you install or upgrade a up to date cheatsheet in left for you to optionally use… Please tell me i’m not the only one who can’t remember all the CLI commands and has to look them up? with Navi and the way this formats you can select the command, fill in the option variables hit enter and done!

Here is repo

while you put some effort in… you probably could simnply have a look into the documention:

also, just running the command without any input will usually give you the syntax. you sure you want to search through a cheat sheet with nearly 480 commands? :wink: :wink:


Because it’s a setup for the one called Navi on GitHub. My script converts the files into cheat sheet for it. Which means that it gives you variables. Basically you type in your search term for what you’re wanting and you can quickly find it such as delete user. Would find the CLI command when you click enter it’ll ask you to type in a couple things if there’s variables such as username account name website whatever it is and then it runs the command already printed out with everything in it. So it’s actually quite easier than going on the website to find it