mirror of
https://github.com/donovanglover/nix-config.git
synced 2024-12-02 05:05:43 +01:00
343076f942
Since all of these files do roughly the same thing (that is, configure the system in a specific way that a separate file seems necessary), this should reduce the overall complexity of the project tree.
33 lines
858 B
Bash
Executable File
33 lines
858 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
FILE_PATH="$1" # Full path of the previewed file
|
|
PREVIEW_X_COORD="$2" # x coordinate of upper left cell of preview area
|
|
PREVIEW_Y_COORD="$3" # y coordinate of upper left cell of preview area
|
|
PREVIEW_WIDTH="$4" # Width of the preview pane (number of fitting characters)
|
|
PREVIEW_HEIGHT="$5" # Height of the preview pane (number of fitting characters)
|
|
|
|
TMP_FILE="$HOME/.cache/joshuto/thumbcache.png"
|
|
|
|
mimetype=$(file --mime-type -Lb "$FILE_PATH")
|
|
|
|
function image {
|
|
kitty +kitten icat \
|
|
--transfer-mode=file \
|
|
--clear 2>/dev/null
|
|
kitty +kitten icat \
|
|
--transfer-mode=file \
|
|
--place "${PREVIEW_WIDTH}x${PREVIEW_HEIGHT}@${PREVIEW_X_COORD}x${PREVIEW_Y_COORD}" \
|
|
"$1" 2>/dev/null
|
|
}
|
|
|
|
case "$mimetype" in
|
|
image/*)
|
|
image "${FILE_PATH}"
|
|
;;
|
|
*)
|
|
kitty +kitten icat \
|
|
--transfer-mode=file \
|
|
--clear 2>/dev/null
|
|
;;
|
|
esac
|