148 lines
8.4 KiB
Bash
148 lines
8.4 KiB
Bash
#!/usr/bin/env bash
|
|
# ------------------------------------------------------------------------------
|
|
# Copyright (c) 2013-2026 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
|
# Protected by the BSD3 license. Please read bellow for details.
|
|
#
|
|
# * Redistribution and use in source and binary forms,
|
|
# * with or without modification, are permitted provided
|
|
# * that the following conditions are met:
|
|
# *
|
|
# * Redistributions of source code must retain the above
|
|
# * copyright notice, this list of conditions and the
|
|
# * following disclaimer.
|
|
# *
|
|
# * Redistributions in binary form must reproduce the above
|
|
# * copyright notice, this list of conditions and the following
|
|
# * disclaimer in the documentation and/or other materials
|
|
# * provided with the distribution.
|
|
# *
|
|
# * Neither the name of the copyright holder nor the names
|
|
# * of any other contributors may be used to endorse or
|
|
# * promote products derived from this software without
|
|
# * specific prior written permission.
|
|
# *
|
|
# * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
# * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
# * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
# * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
# * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
# * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
# * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
# * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
# * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
# * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
# * OF SUCH DAMAGE.
|
|
# ------------------------------------------------------------------------------
|
|
|
|
load_conf "help"
|
|
|
|
# Common helpers, then the ones private to this module (helpers/help.sh)
|
|
# shellcheck source=../helpers/common.sh
|
|
declare -F _profile_load_helpers >/dev/null || . "$(dirname -- "${BASH_SOURCE[0]}")/../helpers/common.sh"
|
|
_profile_load_helpers "${BASH_SOURCE[0]}"
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# Display list of commands and general informations
|
|
# Usage: help [command]
|
|
help()
|
|
{
|
|
# With a command name, delegate to its own --help output. Only shell
|
|
# functions are accepted: running an arbitrary external program with an
|
|
# option it may not understand could have side effects.
|
|
if [[ $# -gt 0 && "$1" != "--help" && "$1" != "-h" ]]; then
|
|
local cmd="$1"
|
|
if [[ $cmd == -* ]]; then
|
|
disp E "Invalid option: $cmd. Usage: help [command]"
|
|
return 1
|
|
elif declare -F -- "$cmd" >/dev/null 2>&1; then
|
|
"$cmd" --help
|
|
elif command -v -- "$cmd" >/dev/null 2>&1; then
|
|
disp E "'$cmd' is not a profile command: try \"$cmd --help\" or \"man $cmd\"."
|
|
return 1
|
|
else
|
|
disp E "Unknown command: $cmd"
|
|
return 1
|
|
fi
|
|
return
|
|
fi
|
|
|
|
# Bold title, without colour codes when NO_COLOR is set (like disp does)
|
|
if [[ -n ${NO_COLOR:-} ]]; then
|
|
printf "Welcome to your profile! Here is a list of available commands:\n\n"
|
|
else
|
|
# shellcheck disable=SC2154 # colour variables are defined by disp.sh
|
|
printf "%b%s%b\n\n" "$BIWhite" \
|
|
"Welcome to your profile! Here is a list of available commands:" "$DEFAULTCOL"
|
|
fi
|
|
printf "backtrace\tPrint the current call stack\n"
|
|
printf "busy\t\tMonitor /dev/urandom for a hex pattern — look busy\n"
|
|
printf "check_updates\tCheck for new versions of profile\n"
|
|
printf "clean\t\tErase backup files in given directories, optionally recursive\n"
|
|
printf "conf_dump\tDisplay the profile configuration file\n"
|
|
printf "conf_save\tSave or update a key=value pair in a profile configuration section\n"
|
|
printf "disp\t\tDisplay formatted info/warning/error/debug messages\n"
|
|
printf "dwl\t\tDownload a URL using curl, wget, or fetch transparently\n"
|
|
printf "expandlist\tExpand glob expressions into a quoted, separated list\n"
|
|
printf "fake_compile\tSimulate a long compilation process — look busy\n"
|
|
printf "file_stats\tDisplay file size statistics for a path\n"
|
|
printf "findbig\t\tFind the biggest files in the given or current directory\n"
|
|
printf "finddead\tFind dead symbolic links in the given or current directory\n"
|
|
printf "findzero\tFind empty files in the given or current directory\n"
|
|
printf "gacp\t\tAdd, commit and push changes (auto-pull if needed)\n"
|
|
printf "genpwd\t\tGenerate one or more random secure passwords with configurable constraints\n"
|
|
printf "get_pkgmgr\tDetect the package manager of the running distribution\n"
|
|
printf "ggraph\t\tDisplay decorated git history graph\n"
|
|
printf "gpid\t\tGive the list of PIDs matching the given process name(s)\n"
|
|
printf "gprune\t\tDelete local branches already merged, or after remote deletion (MR / PR)\n"
|
|
printf "greset\t\tReset branch to upstream (stash local, drop local commits)\n"
|
|
printf "groot\t\tDisplay repository root path (or cd to it with -g)\n"
|
|
printf "gsync\t\tFetch and rebase current branch onto upstream\n"
|
|
printf "gst\t\tDisplay short git status and branch tracking info\n"
|
|
printf "gwip\t\tCreate a quick WIP checkpoint commit\n"
|
|
printf "hack\t\tSimulate a dramatic hacking sequence — look dangerous\n"
|
|
printf "help\t\tDisplay this list, or the usage of a profile command (help <command>)\n"
|
|
printf "isipv4\t\tTell if the given parameter is a valid IPv4 address\n"
|
|
printf "isipv6\t\tTell if the given parameter is a valid IPv6 address\n"
|
|
printf "kt\t\tKill a process and all its children (kill tree)\n"
|
|
printf "ku\t\tKill all processes owned by the given user name or ID\n"
|
|
printf "locale_check\tTell whether a locale is installed (canonical name on stdout)\n"
|
|
printf "matrix\t\tConsole screensaver with Matrix-style digital rain (binary, kana, ascii charset)\n"
|
|
printf "mcd\t\tCreate a directory and immediately move into it\n"
|
|
printf "mdcat\t\tRender Markdown files in terminal with colors, tables and code frames\n"
|
|
printf "meteo\t\tDisplay weather forecast for the configured or given city\n"
|
|
printf "myextip\t\tGet information about your public IP address\n"
|
|
printf "pinfo\t\tDisplay system information read from /proc and /sys only\n"
|
|
printf "pkgf\t\tFind which installed package owns a given file (distro-aware)\n"
|
|
printf "pkgi\t\tInstall packages (distro-aware, sudo/doas when needed)\n"
|
|
printf "pkgr\t\tUninstall packages; -p purges configuration, -d removes unneeded dependencies\n"
|
|
printf "pkgs\t\tSearch for a pattern in installed package names (distro-aware)\n"
|
|
printf "ppg\t\tLook for the given pattern in running processes\n"
|
|
printf "ppn\t\tList processes matching an exact command name\n"
|
|
printf "ppu\t\tList processes owned by a specific user\n"
|
|
printf "profile_upgrade\tUpgrade profile to the latest version (git pull or archive)\n"
|
|
printf "pwdscore\tCalculate the strength score of a given password\n"
|
|
printf "rain\t\tConsole screensaver with falling-rain effect (multiple color themes)\n"
|
|
printf "rainbow\t\tFull-screen rainbow screensaver using background colors only\n"
|
|
printf "rmhost\t\tRemove host (name and IP) from SSH known_hosts; supports --all-users as root\n"
|
|
printf "rmspc\t\tReplace spaces in filenames with underscores (or a custom character)\n"
|
|
printf "setlocale\tSet console locale to any installed locale\n"
|
|
printf " * setc\tSet locale to standard C (POSIX)\n"
|
|
printf " * set*\tLocale shortcuts generated from SET_LOCALE in profile.conf\n"
|
|
printf "set_theme\tSwitch the prompt colour theme; no argument lists available themes\n"
|
|
printf "settrace\tActivate or deactivate ERR trap to display backtrace on script errors\n"
|
|
printf "showinfo\tDisplay welcome banner and system information (figlet + fastfetch/neofetch)\n"
|
|
printf "ssr\t\tSSH into a server as root, forwarding extra ssh options\n"
|
|
printf "taz\t\tCompress files and directories into a chosen archive format\n"
|
|
printf "term_set\tSet TERM to the best available terminal capability (auto-detect or honour config)\n"
|
|
printf "urlencode\tURL-encode a string\n"
|
|
printf "utaz\t\tSmartly uncompress archives (zip, tar.gz/bz2/xz/lz, rar, arj, lha, ace, 7z, zst, cpio, cab, deb, rpm)\n"
|
|
printf "ver\t\tDisplay the installed profile version\n"
|
|
|
|
printf "\nPlease use <command> --help or help <command> to obtain usage details.\n"
|
|
}
|
|
export -f help
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
# EOF
|