Search the Mabox Forum.
With this very simple script it is possible to search the Mabox forum from terminal.
search-mabox-forum.sh
#!/bin/bash
# Array of forums
FORUMS=(
"Endevouros|https://forum.endeavouros.com"
"Manjaro|https://forum.manjaro.org"
"Mabox|https://forum.maboxlinux.org"
)
# Set viewer to bat if available, otherwise fallback to cat
if command -v bat &>/dev/null; then
cat="bat"
else
cat="cat"
fi
HISTORY_FILE="$HOME/.cache/mabox_forum_search.log"
# Colors
BOLD=$(tput bold)
NORMAL=$(tput sgr0)
GREEN=$(tput setaf 2)
CYAN=$(tput setaf 6)
RED=$(tput setaf 1)
YELLOW=$(tput setaf 3)
BLUE=$(tput setaf 4)
ORANGE=$(tput setaf 208)
show_header() {
clear
echo -e "${BOLD}${GREEN}
ββββ ββββ ββββββ βββββββ βββββββ βββ βββ
βββββ ββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββ βββ ββββββ
ββββββββββββββββββββββββββββββ βββ ββββββ
βββ βββ ββββββ ββββββββββββββββββββββββ βββ
βββ ββββββ ββββββββββ βββββββ βββ βββ
${NORMAL}"
echo -e "${CYAN}${BOLD} Mabox|Manjaro Forum Search Tool${NORMAL}\n"
echo -e "${YELLOW}Usage:${NORMAL}"
echo -e " π Type search terms and hit Enter"
echo -e " βΉ Use multiple words for better accuracy"
echo -e " π§ Terms are cumulative β add more as you go"
echo -e " π Use ${BOLD}--history${NORMAL} to show past searches"
echo -e " β¨οΈ Press ${BOLD}Ctrl+C${NORMAL} to quit\n"
}
# Show search history
if [[ "$1" == "--history" ]]; then
echo -e "${YELLOW}π Search History:${NORMAL}"
[[ -f "$HISTORY_FILE" ]] && "$cat" "$HISTORY_FILE" || echo "No history yet."
exit 0
fi
search_terms=""
trap "echo -e '\n${RED}β Exiting...${NORMAL}'; exit" INT
show_header
while true; do
echo -e ""
echo -e "${CYAN}Current search terms:${NORMAL} ${BOLD}${ORANGE}$search_terms${NORMAL}"
echo -e "π‘ Type ${YELLOW}!new${NORMAL} to start a clean search"
read -rp "${ORANGE}π Add keyword(s) (or press Enter to repeat): ${NORMAL}" input
if [[ "$input" == "!new" ]]; then
search_terms=""
show_header
echo -e "${GREEN}π Starting a new search...${NORMAL}\n"
continue
fi
[[ -n "$input" ]] && search_terms="$search_terms $input"
search_terms="$(echo "$search_terms" | xargs)" # trim
if [[ -z "$search_terms" ]]; then
show_header
echo -e "${RED}β No search terms entered yet.${NORMAL}"
continue
fi
echo "$(date '+%F %T') - $search_terms" >> "$HISTORY_FILE"
encoded_keyword=$(echo "$search_terms" | sed 's/ /+/g')
echo -e "\n${CYAN}β³ Fetching results for: '${search_terms}'...${NORMAL}"
# Prepare a hit counter summary
echo -e "\n${BOLD}π Quick summary of hits:${NORMAL}"
declare -A HITS
declare -A RESPONSES
for entry in "${FORUMS[@]}"; do
NAME="${entry%%|*}"
URL="${entry##*|}"
SEARCH_URL="$URL/search.json"
response=$(curl -s "${SEARCH_URL}?q=${encoded_keyword}")
RESPONSES["$NAME"]="$response"
if [[ -z "$response" || "$response" == "null" ]]; then
echo -e "${RED}β οΈ $NAME: Error fetching data.${NORMAL}"
continue
fi
hits=$(echo "$response" | jq '.topics | length')
HITS["$NAME"]=$hits
echo -e "${YELLOW}- $NAME:${NORMAL} ${GREEN}${hits} result(s)${NORMAL}"
done
# Show detailed results
for entry in "${FORUMS[@]}"; do
NAME="${entry%%|*}"
URL="${entry##*|}"
hits="${HITS[$NAME]}"
response="${RESPONSES[$NAME]}"
echo -e "\n${CYAN}π $NAME forum (${hits} result(s)):${NORMAL}"
if [[ "$hits" -eq 0 || "$hits" == "null" ]]; then
echo -e "${YELLOW}βΉοΈ No results found.${NORMAL}"
continue
fi
echo "$response" | jq -r --arg BASE "$URL" '
.topics[] |
{
title: .title,
link: ($BASE + "/t/" + .slug + "/" + (.id|tostring)),
created: (.created_at | split("T") | join(" ") | sub("Z$"; ""))
} |
[.title, .link, .created] |
@tsv
' | while IFS=$'\t' read -r title link created; do
# Conditional coloring based on forum name
if [[ "$NAME" == "Mabox" ]]; then
LINK_COLOR="${GREEN}"
elif [[ "$NAME" == "Manjaro" ]]; then
LINK_COLOR="${BLUE}"
elif [[ "$NAME" == "Endevouros" ]]; then
LINK_COLOR="${ORANGE}"
fi
echo -e "\n${RED}β’${YELLOW} ${BOLD}${title}${NORMAL}"
echo -e " ${LINK_COLOR}${link}${NORMAL}"
echo -e " Created at: $created"
done
done
done
How to see search history.
$ search-mabox-forum.sh --history