feat(ui): Comprehensive UI improvements - colors, syntax, and interactive enhancements
- Fix ASCII banner color display (no more escape code leakage) - Add syntax display to all modes (explain, interactive, direct) - Update COMMANDS array with syntax for all 84 commands - Enhance interactive mode with syntax preview in fzf - Improve show_flags() to match explain mode format with SYNTAX section - Enhance filter logic to search both flag names and descriptions - Update list_commands() to show syntax alongside descriptions - Consistent color-coded display across all modes - Better user experience with clear syntax and command reference Format: cmd:Description | Syntax Example: ls:List directory contents | ls [OPTION]... [FILE]... All modes now show: - Command name - Syntax/usage pattern - Description - Detailed flags with improved filtering
This commit is contained in:
+228
-114
@@ -17,13 +17,12 @@ NC='\033[0m' # No Color
|
|||||||
|
|
||||||
# ASCII Banner
|
# ASCII Banner
|
||||||
show_banner() {
|
show_banner() {
|
||||||
echo -e "${CYAN}"
|
echo -e "${CYAN} ____ __ ____ __ __"
|
||||||
echo " ____ __ ____ __ __"
|
echo -e " / __ )____ ______/ /_ / __ )__ ______/ /___/ /_ __"
|
||||||
echo " / __ )____ ______/ /_ / __ )__ ______/ /___/ /_ __"
|
echo -e " / __ / __ \`/ ___/ __ \\ / __ / / / / __ / __ / / / /"
|
||||||
echo " / __ / __ \`/ ___/ __ \\ / __ / / / / __ / __ / / / /"
|
echo -e " / /_/ / /_/ (__ ) / / / / /_/ / /_/ / /_/ / /_/ / /_/ /"
|
||||||
echo " / /_/ / /_/ (__ ) / / / / /_/ / /_/ / /_/ / /_/ / /_/ /"
|
echo -e "/_____/\\__,_/____/_/ /_/ /_____/\\__,_/\\__,_/\\__,_/\\__, /"
|
||||||
echo "/_____/\\__,_/____/_/ /_/ /_____/\\__,_/\\__,_/\\__,_/\\__, /"
|
echo -e " /____/${NC}"
|
||||||
echo " /____/"
|
|
||||||
echo -e "${YELLOW} Your Intelligent CLI Assistant for Bash${NC}"
|
echo -e "${YELLOW} Your Intelligent CLI Assistant for Bash${NC}"
|
||||||
echo ""
|
echo ""
|
||||||
}
|
}
|
||||||
@@ -477,25 +476,83 @@ mode_explain() {
|
|||||||
echo -e "${BLUE}═══════════════════════════════════════════════════════════${NC}"
|
echo -e "${BLUE}═══════════════════════════════════════════════════════════${NC}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Get quick syntax for a command
|
||||||
|
get_quick_syntax() {
|
||||||
|
local cmd="$1"
|
||||||
|
local syntax=""
|
||||||
|
|
||||||
|
if type "$cmd" 2>/dev/null | grep -q "shell builtin"; then
|
||||||
|
syntax=$(help "$cmd" 2>/dev/null | head -1 | sed 's/^[[:space:]]*//' | cut -c1-60)
|
||||||
|
else
|
||||||
|
# Try to get first line from man page SYNOPSIS
|
||||||
|
syntax=$(man "$cmd" 2>/dev/null | col -b | sed -n '/^SYNOPSIS/,/^DESCRIPTION/p' | sed -n '2p' | sed 's/^[[:space:]]*//' | cut -c1-60)
|
||||||
|
|
||||||
|
if [ -z "$syntax" ]; then
|
||||||
|
# Fallback to --help
|
||||||
|
syntax=$("$cmd" --help 2>&1 | grep -i "usage" | head -1 | sed 's/^[Uu]sage: //' | cut -c1-60)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$syntax" ]; then
|
||||||
|
syntax="$cmd [options]"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$syntax"
|
||||||
|
}
|
||||||
|
|
||||||
show_flags() {
|
show_flags() {
|
||||||
CMD_NAME=$1
|
CMD_NAME=$1
|
||||||
FILTER=$2
|
FILTER=$2
|
||||||
|
|
||||||
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
||||||
echo -e "${YELLOW}Flags for: ${GREEN}$CMD_NAME${NC}"
|
echo -e "${YELLOW}Command Details: ${GREEN}$CMD_NAME${NC}"
|
||||||
if [ -n "$FILTER" ]; then
|
if [ -n "$FILTER" ]; then
|
||||||
echo -e "${YELLOW}Filter: ${GREEN}$FILTER${NC}"
|
echo -e "${YELLOW}Filter: ${GREEN}$FILTER${NC}"
|
||||||
fi
|
fi
|
||||||
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
# Display SYNTAX section
|
||||||
|
if command -v "$CMD_NAME" &> /dev/null || type "$CMD_NAME" 2>/dev/null | grep -q "shell builtin"; then
|
||||||
|
echo -e "${CYAN}${BOLD}SYNTAX:${NC}"
|
||||||
|
|
||||||
|
if type "$CMD_NAME" 2>/dev/null | grep -q "shell builtin"; then
|
||||||
|
# For builtins, get the first line of help
|
||||||
|
local syntax=$(help "$CMD_NAME" 2>/dev/null | head -1 | sed 's/^[[:space:]]*//')
|
||||||
|
if [ -n "$syntax" ]; then
|
||||||
|
echo -e " ${GREEN}$syntax${NC}"
|
||||||
|
else
|
||||||
|
echo -e " ${GREEN}$CMD_NAME [options]${NC}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# For regular commands, extract SYNOPSIS section from man page
|
||||||
|
local synopsis=$(man "$CMD_NAME" 2>/dev/null | col -b | sed -n '/^SYNOPSIS/,/^DESCRIPTION/p' | head -15 | tail -n +2 | head -n -1 | sed 's/^[[:space:]]*/ /')
|
||||||
|
if [ -n "$synopsis" ]; then
|
||||||
|
echo -e "${GREEN}$synopsis${NC}"
|
||||||
|
else
|
||||||
|
# Fallback: try to get usage from command itself
|
||||||
|
local usage=$("$CMD_NAME" --help 2>&1 | grep -i "usage" | head -1 | sed 's/^[Uu]sage: / /')
|
||||||
|
if [ -n "$usage" ]; then
|
||||||
|
echo -e " ${GREEN}$usage${NC}"
|
||||||
|
else
|
||||||
|
echo -e " ${GREEN}$CMD_NAME [options]${NC}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Display FLAGS/OPTIONS section
|
||||||
|
echo -e "${YELLOW}${BOLD}FLAGS/OPTIONS:${NC}"
|
||||||
|
echo ""
|
||||||
|
|
||||||
# Try to get flags from man page
|
# Try to get flags from man page
|
||||||
if type "$CMD_NAME" 2>/dev/null | grep -q "shell builtin"; then
|
if type "$CMD_NAME" 2>/dev/null | grep -q "shell builtin"; then
|
||||||
# Shell builtin - use help command
|
# Shell builtin - use help command
|
||||||
if [ -n "$FILTER" ]; then
|
if [ -n "$FILTER" ]; then
|
||||||
help "$CMD_NAME" 2>/dev/null | grep -E '^\s*-' | grep -i "$FILTER"
|
help "$CMD_NAME" 2>/dev/null | grep -iE "(^|\s)-.*$FILTER" | head -30
|
||||||
else
|
else
|
||||||
help "$CMD_NAME" 2>/dev/null | grep -E '^\s*-'
|
help "$CMD_NAME" 2>/dev/null | grep -E '^\s*-' | head -30
|
||||||
fi
|
fi
|
||||||
elif command -v "$CMD_NAME" &> /dev/null; then
|
elif command -v "$CMD_NAME" &> /dev/null; then
|
||||||
# External command - use man page
|
# External command - use man page
|
||||||
@@ -516,9 +573,10 @@ show_flags() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$FILTER" ]; then
|
if [ -n "$FILTER" ]; then
|
||||||
echo "$options_section" | grep -i "$FILTER" | head -30
|
# Improved filter logic: match flag name or description
|
||||||
|
echo "$options_section" | grep -iE "(^|\s)-.*$FILTER|$FILTER.*-" | head -40
|
||||||
else
|
else
|
||||||
echo "$options_section" | head -30
|
echo "$options_section" | head -40
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo -e "${RED}Could not find help for: $CMD_NAME${NC}"
|
echo -e "${RED}Could not find help for: $CMD_NAME${NC}"
|
||||||
@@ -527,6 +585,8 @@ show_flags() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo -e "${DIM}Tip: Use the filter to search for specific flags or keywords${NC}"
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
||||||
}
|
}
|
||||||
@@ -536,8 +596,16 @@ list_commands() {
|
|||||||
echo ""
|
echo ""
|
||||||
for cmd in "${COMMANDS[@]}"; do
|
for cmd in "${COMMANDS[@]}"; do
|
||||||
CMD_NAME=${cmd%%:*}
|
CMD_NAME=${cmd%%:*}
|
||||||
DESC=${cmd#*:}
|
REST=${cmd#*:}
|
||||||
printf " %-10s - %s\n" "$CMD_NAME" "$DESC"
|
|
||||||
|
# Extract description (before pipe) and syntax (after pipe)
|
||||||
|
if [[ "$REST" =~ (.+)\ \|\ (.+) ]]; then
|
||||||
|
DESC="${BASH_REMATCH[1]}"
|
||||||
|
SYNTAX="${BASH_REMATCH[2]}"
|
||||||
|
printf " %-10s - %-40s | %s\n" "$CMD_NAME" "$DESC" "$SYNTAX"
|
||||||
|
else
|
||||||
|
printf " %-10s - %s\n" "$CMD_NAME" "$REST"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -545,122 +613,127 @@ get_command_description() {
|
|||||||
local search_cmd=$1
|
local search_cmd=$1
|
||||||
for cmd in "${COMMANDS[@]}"; do
|
for cmd in "${COMMANDS[@]}"; do
|
||||||
CMD_NAME=${cmd%%:*}
|
CMD_NAME=${cmd%%:*}
|
||||||
DESC=${cmd#*:}
|
REST=${cmd#*:}
|
||||||
if [ "$CMD_NAME" = "$search_cmd" ]; then
|
if [ "$CMD_NAME" = "$search_cmd" ]; then
|
||||||
echo "$DESC"
|
# Extract just the description part (before the pipe)
|
||||||
|
if [[ "$REST" =~ (.+)\ \|\ (.+) ]]; then
|
||||||
|
echo "${BASH_REMATCH[1]}"
|
||||||
|
else
|
||||||
|
echo "$REST"
|
||||||
|
fi
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo "Command help"
|
echo "Command help"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Command definitions for interactive mode
|
# Command definitions for interactive mode (format: "cmd:Description | Syntax")
|
||||||
COMMANDS=(
|
COMMANDS=(
|
||||||
# File Operations
|
# File Operations
|
||||||
"ls:List directory contents"
|
"ls:List directory contents | ls [OPTION]... [FILE]..."
|
||||||
"cd:Change the current directory"
|
"cd:Change the current directory | cd [DIRECTORY]"
|
||||||
"pwd:Print the name of the current working directory"
|
"pwd:Print the name of the current working directory | pwd [OPTION]"
|
||||||
"cp:Copy files and directories"
|
"cp:Copy files and directories | cp [OPTION]... SOURCE DEST"
|
||||||
"mv:Move or rename files and directories"
|
"mv:Move or rename files and directories | mv [OPTION]... SOURCE DEST"
|
||||||
"rm:Remove files or directories"
|
"rm:Remove files or directories | rm [OPTION]... FILE..."
|
||||||
"mkdir:Create a new directory"
|
"mkdir:Create a new directory | mkdir [OPTION]... DIRECTORY..."
|
||||||
"rmdir:Remove an empty directory"
|
"rmdir:Remove an empty directory | rmdir [OPTION]... DIRECTORY..."
|
||||||
"touch:Create empty file or update timestamp"
|
"touch:Create empty file or update timestamp | touch [OPTION]... FILE..."
|
||||||
"cat:Concatenate and display files"
|
"cat:Concatenate and display files | cat [OPTION]... [FILE]..."
|
||||||
"less:View file contents with pagination"
|
"less:View file contents with pagination | less [OPTION]... [FILE]..."
|
||||||
"head:Display first lines of a file"
|
"head:Display first lines of a file | head [OPTION]... [FILE]..."
|
||||||
"tail:Display last lines of a file"
|
"tail:Display last lines of a file | tail [OPTION]... [FILE]..."
|
||||||
"chmod:Change file permissions"
|
"chmod:Change file permissions | chmod [OPTION] MODE FILE..."
|
||||||
"chown:Change file owner"
|
"chown:Change file owner | chown [OPTION]... OWNER[:GROUP] FILE..."
|
||||||
"ln:Create links between files"
|
"ln:Create links between files | ln [OPTION]... TARGET LINK_NAME"
|
||||||
"file:Determine file type"
|
"file:Determine file type | file [OPTION]... FILE..."
|
||||||
"stat:Display file status"
|
"stat:Display file status | stat [OPTION]... FILE..."
|
||||||
|
|
||||||
# Text Processing
|
# Text Processing
|
||||||
"grep:Search for patterns in files"
|
"grep:Search for patterns in files | grep [OPTION]... PATTERN [FILE]..."
|
||||||
"sed:Stream editor for text manipulation"
|
"sed:Stream editor for text manipulation | sed [OPTION]... SCRIPT [FILE]..."
|
||||||
"awk:Pattern scanning and text processing"
|
"awk:Pattern scanning and text processing | awk [OPTION]... PROGRAM [FILE]..."
|
||||||
"cut:Remove sections from lines of files"
|
"cut:Remove sections from lines of files | cut [OPTION]... [FILE]..."
|
||||||
"sort:Sort lines of text"
|
"sort:Sort lines of text | sort [OPTION]... [FILE]..."
|
||||||
"uniq:Report or filter out repeated lines"
|
"uniq:Report or filter out repeated lines | uniq [OPTION]... [FILE]..."
|
||||||
"tr:Translate or delete characters"
|
"tr:Translate or delete characters | tr [OPTION]... SET1 [SET2]"
|
||||||
"wc:Count lines, words, and characters"
|
"wc:Count lines, words, and characters | wc [OPTION]... [FILE]..."
|
||||||
"diff:Compare files line by line"
|
"diff:Compare files line by line | diff [OPTION]... FILE1 FILE2"
|
||||||
|
|
||||||
# File Search
|
# File Search
|
||||||
"find:Search for files in directory hierarchy"
|
"find:Search for files in directory hierarchy | find [PATH] [OPTIONS] [EXPRESSION]"
|
||||||
"locate:Find files by name quickly"
|
"locate:Find files by name quickly | locate [OPTION]... PATTERN..."
|
||||||
"which:Show full path of commands"
|
"which:Show full path of commands | which [OPTION]... COMMAND..."
|
||||||
"whereis:Locate binary, source, and manual pages"
|
"whereis:Locate binary, source, and manual pages | whereis [OPTION]... COMMAND..."
|
||||||
|
|
||||||
# Compression
|
# Compression
|
||||||
"tar:Archive files"
|
"tar:Archive files | tar [OPTION]... [FILE]..."
|
||||||
"gzip:Compress files"
|
"gzip:Compress files | gzip [OPTION]... [FILE]..."
|
||||||
"gunzip:Decompress gzip files"
|
"gunzip:Decompress gzip files | gunzip [OPTION]... [FILE]..."
|
||||||
"zip:Package and compress files"
|
"zip:Package and compress files | zip [OPTION]... ZIPFILE FILES..."
|
||||||
"unzip:Extract compressed zip files"
|
"unzip:Extract compressed zip files | unzip [OPTION]... FILE..."
|
||||||
|
|
||||||
# Network
|
# Network
|
||||||
"ping:Test network connectivity"
|
"ping:Test network connectivity | ping [OPTION]... HOST"
|
||||||
"curl:Transfer data from URLs"
|
"curl:Transfer data from URLs | curl [OPTION]... URL..."
|
||||||
"wget:Download files from the web"
|
"wget:Download files from the web | wget [OPTION]... URL..."
|
||||||
"ssh:Secure shell remote login"
|
"ssh:Secure shell remote login | ssh [OPTION]... USER@HOST [COMMAND]"
|
||||||
"scp:Secure copy files between hosts"
|
"scp:Secure copy files between hosts | scp [OPTION]... SOURCE DEST"
|
||||||
"netstat:Network statistics"
|
"netstat:Network statistics | netstat [OPTION]..."
|
||||||
"ss:Socket statistics"
|
"ss:Socket statistics | ss [OPTION]..."
|
||||||
"ip:Show/manipulate routing and devices"
|
"ip:Show/manipulate routing and devices | ip [OPTION]... OBJECT {COMMAND}"
|
||||||
"ifconfig:Configure network interfaces"
|
"ifconfig:Configure network interfaces | ifconfig [INTERFACE] [OPTIONS]"
|
||||||
|
|
||||||
# System Info
|
# System Info
|
||||||
"top:Display system processes"
|
"top:Display system processes | top [OPTION]..."
|
||||||
"htop:Interactive process viewer"
|
"htop:Interactive process viewer | htop [OPTION]..."
|
||||||
"ps:Report process status"
|
"ps:Report process status | ps [OPTION]..."
|
||||||
"df:Show disk space usage"
|
"df:Show disk space usage | df [OPTION]... [FILE]..."
|
||||||
"du:Estimate file space usage"
|
"du:Estimate file space usage | du [OPTION]... [FILE]..."
|
||||||
"free:Display memory usage"
|
"free:Display memory usage | free [OPTION]..."
|
||||||
"uname:Print system information"
|
"uname:Print system information | uname [OPTION]..."
|
||||||
"uptime:Show how long system has been running"
|
"uptime:Show how long system has been running | uptime [OPTION]..."
|
||||||
|
|
||||||
# Process Management
|
# Process Management
|
||||||
"kill:Send signal to a process"
|
"kill:Send signal to a process | kill [OPTION]... PID..."
|
||||||
"pkill:Kill processes by name"
|
"pkill:Kill processes by name | pkill [OPTION]... PATTERN"
|
||||||
"killall:Kill processes by name"
|
"killall:Kill processes by name | killall [OPTION]... NAME..."
|
||||||
"bg:Put job in background"
|
"bg:Put job in background | bg [JOB_SPEC]"
|
||||||
"fg:Bring job to foreground"
|
"fg:Bring job to foreground | fg [JOB_SPEC]"
|
||||||
"jobs:List active jobs"
|
"jobs:List active jobs | jobs [OPTION]..."
|
||||||
|
|
||||||
# System Control
|
# System Control
|
||||||
"sudo:Execute command as another user"
|
"sudo:Execute command as another user | sudo [OPTION]... COMMAND"
|
||||||
"systemctl:Control systemd services"
|
"systemctl:Control systemd services | systemctl [OPTION]... COMMAND"
|
||||||
"service:Control system services"
|
"service:Control system services | service COMMAND [OPTIONS]"
|
||||||
"reboot:Reboot the system"
|
"reboot:Reboot the system | reboot [OPTION]..."
|
||||||
"shutdown:Shut down the system"
|
"shutdown:Shut down the system | shutdown [OPTION]... [TIME]"
|
||||||
|
|
||||||
# Package Management
|
# Package Management
|
||||||
"apt:Package manager (Debian/Ubuntu)"
|
"apt:Package manager (Debian/Ubuntu) | apt [OPTION]... COMMAND"
|
||||||
"apt-get:APT package handling utility"
|
"apt-get:APT package handling utility | apt-get [OPTION]... COMMAND"
|
||||||
"dpkg:Debian package manager"
|
"dpkg:Debian package manager | dpkg [OPTION]... ACTION"
|
||||||
"snap:Snap package manager"
|
"snap:Snap package manager | snap [OPTION]... COMMAND"
|
||||||
|
|
||||||
# User Management
|
# User Management
|
||||||
"useradd:Create new user"
|
"useradd:Create new user | useradd [OPTION]... LOGIN"
|
||||||
"userdel:Delete user account"
|
"userdel:Delete user account | userdel [OPTION]... LOGIN"
|
||||||
"passwd:Change user password"
|
"passwd:Change user password | passwd [OPTION]... [USER]"
|
||||||
"su:Switch user"
|
"su:Switch user | su [OPTION]... [USER]"
|
||||||
"whoami:Print current username"
|
"whoami:Print current username | whoami"
|
||||||
"w:Show who is logged in"
|
"w:Show who is logged in | w [OPTION]... [USER]"
|
||||||
"who:Show who is logged in"
|
"who:Show who is logged in | who [OPTION]..."
|
||||||
|
|
||||||
# Misc Utilities
|
# Misc Utilities
|
||||||
"echo:Display a line of text"
|
"echo:Display a line of text | echo [OPTION]... [STRING]..."
|
||||||
"date:Display or set system date and time"
|
"date:Display or set system date and time | date [OPTION]... [+FORMAT]"
|
||||||
"cal:Display calendar"
|
"cal:Display calendar | cal [OPTION]... [[MONTH] YEAR]"
|
||||||
"history:Show command history"
|
"history:Show command history | history [n]"
|
||||||
"alias:Create command aliases"
|
"alias:Create command aliases | alias [NAME[=VALUE]...]"
|
||||||
"export:Set environment variables"
|
"export:Set environment variables | export [NAME[=VALUE]...]"
|
||||||
"env:Display environment variables"
|
"env:Display environment variables | env [OPTION]... [NAME=VALUE]... [COMMAND]"
|
||||||
"man:Display manual pages"
|
"man:Display manual pages | man [OPTION]... [SECTION] PAGE"
|
||||||
"watch:Execute command periodically"
|
"watch:Execute command periodically | watch [OPTION]... COMMAND"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Parse arguments
|
# Parse arguments
|
||||||
@@ -750,16 +823,38 @@ if [ "$INTERACTIVE" = true ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
FZF_COMMAND=$(printf "%s\n" "${COMMANDS[@]}" | fzf --height 40% --border --preview 'echo {}' --preview-window=up:1:wrap)
|
# Enhanced preview showing command, description, and syntax
|
||||||
|
FZF_COMMAND=$(printf "%s\n" "${COMMANDS[@]}" | fzf --height 60% --border \
|
||||||
|
--preview 'echo -e "\033[0;36mCommand:\033[0m {1}\n\033[0;36mDescription:\033[0m {2}\n\033[0;36mSyntax:\033[0m {3}"' \
|
||||||
|
--preview-window=up:3:wrap \
|
||||||
|
--delimiter ':|\|' \
|
||||||
|
--with-nth 1,2,3)
|
||||||
|
|
||||||
if [ -n "$FZF_COMMAND" ]; then
|
if [ -n "$FZF_COMMAND" ]; then
|
||||||
|
# Parse the selected command: "cmd:description | syntax"
|
||||||
CMD=${FZF_COMMAND%%:*}
|
CMD=${FZF_COMMAND%%:*}
|
||||||
DESC=${FZF_COMMAND#*:}
|
REST=${FZF_COMMAND#*:}
|
||||||
|
|
||||||
|
# Extract description and syntax
|
||||||
|
if [[ "$REST" =~ (.+)\ \|\ (.+) ]]; then
|
||||||
|
DESC="${BASH_REMATCH[1]}"
|
||||||
|
SYNTAX="${BASH_REMATCH[2]}"
|
||||||
|
else
|
||||||
|
DESC="$REST"
|
||||||
|
SYNTAX="$CMD [options]"
|
||||||
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "\033[0;34m═══════════════════════════════════════════════════════════\033[0m"
|
echo -e "${BLUE}═══════════════════════════════════════════════════════════${NC}"
|
||||||
echo -e "\033[0;32mCommand:\033[0m $CMD"
|
echo -e "${YELLOW}Command:${NC} ${MAGENTA}$CMD${NC}"
|
||||||
echo -e "\033[0;32mDescription:\033[0m $DESC"
|
echo -e "${BLUE}═══════════════════════════════════════════════════════════${NC}"
|
||||||
echo -e "\033[0;34m═══════════════════════════════════════════════════════════\033[0m"
|
echo ""
|
||||||
|
echo -e "${CYAN}${BOLD}SYNTAX:${NC}"
|
||||||
|
echo -e " ${GREEN}$SYNTAX${NC}"
|
||||||
|
echo ""
|
||||||
|
echo -e "${GREEN}Description:${NC} $DESC"
|
||||||
|
echo ""
|
||||||
|
echo -e "${BLUE}═══════════════════════════════════════════════════════════${NC}"
|
||||||
echo ""
|
echo ""
|
||||||
read -p "Filter flags (optional, press Enter to skip): " FILTER
|
read -p "Filter flags (optional, press Enter to skip): " FILTER
|
||||||
echo ""
|
echo ""
|
||||||
@@ -772,11 +867,23 @@ if [ "$INTERACTIVE" = true ]; then
|
|||||||
elif [ -n "$COMMAND" ]; then
|
elif [ -n "$COMMAND" ]; then
|
||||||
# Validate command exists in our list
|
# Validate command exists in our list
|
||||||
FOUND=false
|
FOUND=false
|
||||||
|
DESC_PART=""
|
||||||
|
SYNTAX_PART=""
|
||||||
|
|
||||||
for cmd in "${COMMANDS[@]}"; do
|
for cmd in "${COMMANDS[@]}"; do
|
||||||
CMD_NAME=${cmd%%:*}
|
CMD_NAME=${cmd%%:*}
|
||||||
if [ "$CMD_NAME" = "$COMMAND" ]; then
|
if [ "$CMD_NAME" = "$COMMAND" ]; then
|
||||||
FOUND=true
|
FOUND=true
|
||||||
DESC=${cmd#*:}
|
REST=${cmd#*:}
|
||||||
|
|
||||||
|
# Extract description and syntax
|
||||||
|
if [[ "$REST" =~ (.+)\ \|\ (.+) ]]; then
|
||||||
|
DESC_PART="${BASH_REMATCH[1]}"
|
||||||
|
SYNTAX_PART="${BASH_REMATCH[2]}"
|
||||||
|
else
|
||||||
|
DESC_PART="$REST"
|
||||||
|
SYNTAX_PART="$COMMAND [options]"
|
||||||
|
fi
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@@ -788,15 +895,22 @@ elif [ -n "$COMMAND" ]; then
|
|||||||
echo ""
|
echo ""
|
||||||
echo "Attempting to show flags anyway..."
|
echo "Attempting to show flags anyway..."
|
||||||
echo ""
|
echo ""
|
||||||
|
DESC_PART=$(get_command_description "$COMMAND")
|
||||||
|
SYNTAX_PART="$COMMAND [options]"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Show command info
|
# Show command info in enhanced format
|
||||||
DESC=$(get_command_description "$COMMAND")
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "\033[0;34m═══════════════════════════════════════════════════════════\033[0m"
|
echo -e "${BLUE}═══════════════════════════════════════════════════════════${NC}"
|
||||||
echo -e "\033[0;32mCommand:\033[0m $COMMAND"
|
echo -e "${YELLOW}Command:${NC} ${MAGENTA}$COMMAND${NC}"
|
||||||
echo -e "\033[0;32mDescription:\033[0m $DESC"
|
echo -e "${BLUE}═══════════════════════════════════════════════════════════${NC}"
|
||||||
echo -e "\033[0;34m═══════════════════════════════════════════════════════════\033[0m"
|
echo ""
|
||||||
|
echo -e "${CYAN}${BOLD}SYNTAX:${NC}"
|
||||||
|
echo -e " ${GREEN}$SYNTAX_PART${NC}"
|
||||||
|
echo ""
|
||||||
|
echo -e "${GREEN}Description:${NC} $DESC_PART"
|
||||||
|
echo ""
|
||||||
|
echo -e "${BLUE}═══════════════════════════════════════════════════════════${NC}"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
show_flags "$COMMAND" "$FILTER"
|
show_flags "$COMMAND" "$FILTER"
|
||||||
|
|||||||
Reference in New Issue
Block a user