2024-11-16 10:24:00 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
CAMERA_DIR=~/Camera
|
|
|
|
|
|
|
|
if [[ -z "$@" ]]; then
|
|
|
|
echo "^cam .*$"
|
|
|
|
elif [[ "$1" == "--hint" ]]; then
|
|
|
|
shift
|
|
|
|
elif [[ "$1" == "--complete" ]]; then
|
|
|
|
shift
|
|
|
|
if [[ -d "$CAMERA_DIR" ]]; then
|
2024-11-23 18:31:37 +00:00
|
|
|
find ~/Camera -type f -not -path '*/\.*' -printf "%T@ %P\n" -type f | sort -n -r | cut -d " " -f 2 | awk '{print $1 " cam " $1}'
|
2024-11-16 10:24:00 +00:00
|
|
|
fi
|
|
|
|
elif [[ "$1" == "--preview" ]]; then
|
|
|
|
shift
|
|
|
|
|
|
|
|
FILE="$CAMERA_DIR/$1"
|
|
|
|
TYPE=$(file --dereference --mime -- "$FILE")
|
|
|
|
|
|
|
|
if [[ $TYPE =~ image/ ]]; then
|
|
|
|
DIM=${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}
|
|
|
|
chafa -s "$DIM" "$FILE"
|
|
|
|
# Add a new line character so that fzf can display multiple images in the preview window
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
|
|
|
|
elif [[ "$1" == "--run" ]]; then
|
|
|
|
shift
|
2024-11-20 07:08:16 +00:00
|
|
|
echo "file://$CAMERA_DIR/$2" | setsid -f wl-copy -t text/uri-list
|
2024-11-16 10:24:00 +00:00
|
|
|
else
|
|
|
|
echo "Unexpected arguments: $@"
|
|
|
|
fi
|