-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfimage
More file actions
executable file
·38 lines (28 loc) · 1.25 KB
/
fimage
File metadata and controls
executable file
·38 lines (28 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
# fimage: Search for images starting from the current directory by file types
# as defined in the fss.conf. If a pattern (keyword) is provided as an
# argument, pre-filter by it, preview using in fzf and open the selected image.
# Usage: fimage [pattern]
# shellcheck disable=SC1091
source "$FSS_ROOT_DIR/lib/config_parser.sh"
source "$FSS_ROOT_DIR/lib/fd_builder.sh"
source "$FSS_ROOT_DIR/lib/fzf_builder.sh"
# Assign the first command line argument to 'pattern'
pattern="$1"
# Parse the IMAGE section from the configuration file
parse_config "IMAGE" || { echo "Failed to parse config"; exit 1; }
# Initialize fd_command and set type to file
fd_add_type "f"
# Add extensions to the search command
fd_add_extensions "${EXTENSIONS[@]//\"/}"
# Add the pattern to the search command if provided
fd_set_pattern "$pattern"
# Construct the fzf command with a preview
fzf_add_preview "${PREVIEW_COMMAND//\"/} {}"
# Use fd_command to search for images and pipe the results into the fzf command
selected_image=$(fd_execute 2>/dev/null | fzf_execute)
# Open the selected image if any were selected
if [ -n "$selected_image" ]; then
# Open the selected image with the specified image open command
eval "${OPEN_COMMAND//\"/} \"$selected_image\"" &> /dev/null &
fi