Skip to content

[Idea]: Searching and displaying fabric patterns from the terminal #1466

Open
@Uuhuuu

Description

@Uuhuuu

What do you need?

Guide is for Linux environment.

Step 1
Create or modify .bash_aliases:
sudo nano ~/.bash_aliases

Step 2
Create function that do searching the fabric pattern name or displaying the content of selected pattern:
`pname() {
local pattern_dir="$HOME/.config/fabric/patterns"

# Check if a pattern name was provided
if [[ -z "$1" ]]; then
    echo -e "\e[31mError:\e[0m Please provide a pattern name."
    return 1
fi

# Exact match check
if [[ -d "$pattern_dir/$1" ]]; then
    echo -e "\e[32mPattern found:\e[0m $1"
    cat "$pattern_dir/$1/system.md"
    return 0
fi

# No exact match, suggest closest matches
local matches=$(ls "$pattern_dir" | grep -i "$1" | sort)

if [[ -n "$matches" ]]; then
    echo -e "\e[33mPattern '$1' not found. Did you mean?\e[0m"
    echo "$matches" | column
else
    echo -e "\e[31mNo matching patterns found.\e[0m"
fi

}`

Step 3
Save file. Refresh terminal. Por favor - everything should be ready. In the image an example of using it.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions