Sha256: 2d861f752c37bb313fec4da80ca3417a908372778c94b3e2958a0906851e7ede
Contents?: true
Size: 1.24 KB
Versions: 4
Compression:
Stored size: 1.24 KB
Contents
#!/usr/bin/env bash # Refactored examples/rgfzf to take search term and directory path as parameters search_term="$1" directory_path="${2:-$(pwd)}" # Use given directory path, or current working directory if not provided # Verify that a search term is provided if [[ -z "$search_term" ]]; then echo "Usage: $0 search_term [directory_path]" exit 1 fi # Ensure ripgrep (rg) and fzf are installed if ! command -v rg &> /dev/null || ! command -v fzf &> /dev/null; then echo "Please ensure ripgrep and fzf are installed before running this script." exit 1 fi # Perform the file search using ripgrep and selection using fzf selected_file=$( rg --files-with-matches \ --no-messages \ --smart-case "$search_term" "$directory_path" | sed "s#^$directory_path/##" | # Strip out the directory path fzf --ansi \ --color "hl:-1:underline,hl+:-1:underline:reverse" \ --preview "cat $directory_path/{}" \ --preview-window "up,60%,border-bottom" \ --no-multi \ --exit-0 \ --query "$search_term" ) # If no file was selected, exit the script if [[ -z "$selected_file" ]]; then # echo "No file selected." exit 0 fi # Remove the file extension prompt_id=$(echo "$selected_file" | sed "s/\.[^.]*$//") echo "$prompt_id"
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
prompt_manager-0.4.2 | examples/rgfzf |
prompt_manager-0.4.1 | examples/rgfzf |
prompt_manager-0.4.0 | examples/rgfzf |
prompt_manager-0.3.3 | examples/rgfzf |