-
-
Save kuntau/1b736b3cb92fddca338893886d4ff45a to your computer and use it in GitHub Desktop.
Revisions
-
wolandark revised this gist
Aug 1, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ mime=$(file --mime-type -b "$1" 2>/dev/null) case "$mime" in text/*) # Use vim for text files vim "$1" ;; *) # Let xdg-open handle the rest -
wolandark revised this gist
Aug 1, 2024 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ # to be placed in ~/.bashrc export FZF_CTRL_T_OPTS=" --preview '~/preview_all.sh {}' --height '100%' --bind 'ctrl-/:change-preview-window(down|hidden|)' --bind 'enter:execute(~/execute_all.sh {+})'" -
wolandark revised this gist
Aug 1, 2024 . No changes.There are no files selected for viewing
-
wolandark revised this gist
Aug 1, 2024 . 1 changed file with 18 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ #!/bin/bash # MIME type of the file mime=$(file --mime-type -b "$1" 2>/dev/null) # Handle different MIME types case "$mime" in text/*) # Use vim for text files vim "$1" >/dev/null 2>&1 ;; *) # Let xdg-open handle the rest xdg-open "$1" >/dev/null 2>&1 ;; esac exit 0 -
wolandark created this gist
Aug 1, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,48 @@ #!/bin/bash # MIME type of the file mime=$(file --mime-type -b "$1" 2>/dev/null) # Cleanup function cleanup() { [[ -n "$thumb_cache" ]] && rm -f "$thumb_cache" } trap cleanup EXIT # Handle different MIME types case "$mime" in text/*) # Use bat for text files bat --color=always --style=numbers "$1" 2>/dev/null ;; inode/directory) tree "$1" 2>/dev/null ;; image/jpeg | image/png) # Use magick to display images in the terminal using sixel magick "$1" -geometry 800x480 sixel:- 2>/dev/null ;; application/pdf) # Use pdftotext for PDF files pdftotext "$1" - | head -n 1000 2>/dev/null ;; application/epub+zip) # Use epub2txt for EPUB files epub2txt "$1" | head -n 1000 2>/dev/null ;; video/*) # Generate a thumbnail for video files thumb_cache=$(mktemp "${TMPDIR:-/tmp}/thumb_cache.XXXXX.png") ffmpegthumbnailer -i "$1" -o "$thumb_cache" -s 0 2>/dev/null # Display the thumbnail img2sixel < "$thumb_cache" 2>/dev/null ;; application/x-tar | application/gzip | application/x-compressed-tar | application/x-bzip2 | application/x-xz | application/zip | application/x-7z-compressed | application/x-rar-compressed) ~/.config/lf/pistol-static-linux-x86_64 "$1" 2>/dev/null ;; *) # Default: show file details echo "File type: $mime" echo "No preview available for this file type." ;; esac