summaryrefslogtreecommitdiff
path: root/.local/bin/preview
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin/preview')
-rwxr-xr-x.local/bin/preview9
1 files changed, 5 insertions, 4 deletions
diff --git a/.local/bin/preview b/.local/bin/preview
index b71d0f0..f15e884 100755
--- a/.local/bin/preview
+++ b/.local/bin/preview
@@ -1,22 +1,23 @@
#!/bin/sh
if [ -d "$1" ]; then
- if [ -x /bin/eza ] || [ -x /usr/bin/eza ]; then
+ if command -v eza >/dev/null; then
eza -alhF --group-directories-first --color=always --icons=always -- "$1"
else
ls -lhAF --group-directories-first --color=always -- "$1"
fi
readme="$(find "$1" -maxdepth 1 -name "README.*" | head -1)"
- [ -n "$readme" ] && preview "$readme"
+ [ -z "$readme" ] || preview "$readme"
exit
fi
alias highlight='highlight --out-format=ansi'
+alias glow='glow -s dark --width="$(( "${FZF_PREVIEW_COLUMNS:-"$(tput cols)"}" - 5 ))"'
case "$1" in
'') echo "USAGE: preview <FILE>" >&2; exit 1 ;;
*.html) w3m -dump "$1" ;;
- *.md) glow -s dark --width="${FZF_PREVIEW_COLUMNS:-"$(tput cols)"}" "$1" ;;
+ *.md) glow "$1" ;;
# *.vim) highlight --syntax=vim --replace-tabs=2 -- "$1" ;;
*.js|*.vim|*.lua) highlight -- "$1" ;;
*.txt|*.description|*.srt) cat -- "$1" ;;
@@ -44,7 +45,7 @@ case "$1" in
filetype=$(file --dereference --brief --mime-type "$1")
case $filetype in
*html) w3m -dump "$1" ;;
- text/markdown) glow -s dark -w "$(tput cols)" "$1" ;;
+ text/markdown) glow "$1" ;;
application/json) highlight --syntax=json --replace-tabs=2 -- "$1" ;;
text/*) highlight --force -- "$1" ;;
audio/*|video/*|image/*) mediainfo -- "$1" ;;