diff --git a/README.md b/README.md index 0a5ca50..f458a90 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ “工欲善其事,必先利其器。” -> Dotfile of the tools what I use. +> Dotfiles for the tools I use. -## Including +## Includes - [fish](https://github.com/fish-shell/fish-shell) @@ -12,5 +12,6 @@ - [tmux](https://github.com/tmux/tmux) -- Customed Keymaps Files +- [ranger](https://github.com/ranger/ranger) +- Custom keymap files diff --git a/ranger/README.md b/ranger/README.md new file mode 100644 index 0000000..5130987 --- /dev/null +++ b/ranger/README.md @@ -0,0 +1,23 @@ +# ranger + +This directory tracks the ranger setup I actually use instead of storing a +full copy of the packaged defaults. + +## Files + +- `rc.conf`: minimal overrides on top of ranger's built-in defaults +- `scope.sh`: richer previews for images, video, PDF, archives, and text + +## Recommended packages on Arch Linux + +```bash +sudo pacman -S --needed \ + ranger ueberzugpp chafa ffmpegthumbnailer mediainfo highlight atool \ + perl-image-exiftool w3m mpv trash-cli unrar poppler imagemagick bat jq file +``` + +## Notes + +- `preview_images_method ueberzug` works well in X11 terminals such as Alacritty. +- `chafa` provides a readable fallback when graphical image previews are unavailable. +- `trash-cli` powers the `dt` and `dT` key bindings in `rc.conf`. diff --git a/ranger/rc.conf b/ranger/rc.conf new file mode 100644 index 0000000..103d946 --- /dev/null +++ b/ranger/rc.conf @@ -0,0 +1,14 @@ +# Minimal ranger overrides on top of the built-in defaults. +set use_preview_script true +set preview_script ~/.config/ranger/scope.sh + +set vcs_aware true +set preview_images true +set preview_images_method ueberzug +set collapse_preview false +set wrap_plaintext_previews true +set draw_borders both + +# Prefer trash over permanent deletion for routine cleanup. +map dt shell -w trash-put -- %s +map dT shell -w trash-restore diff --git a/ranger/scope.sh b/ranger/scope.sh index 11508f9..869ae66 100755 --- a/ranger/scope.sh +++ b/ranger/scope.sh @@ -162,20 +162,21 @@ handle_image() { ;; ## Video - # video/*) - # # Thumbnail - # ffmpegthumbnailer -i "${FILE_PATH}" -o "${IMAGE_CACHE_PATH}" -s 0 && exit 6 - # exit 1;; + video/*) + ffmpegthumbnailer -i "${FILE_PATH}" -o "${IMAGE_CACHE_PATH}" -s 0 && exit 6 + exit 1 + ;; ## PDF - # application/pdf) - # pdftoppm -f 1 -l 1 \ - # -scale-to-x "${DEFAULT_SIZE%x*}" \ - # -scale-to-y -1 \ - # -singlefile \ - # -jpeg -tiffcompression jpeg \ - # -- "${FILE_PATH}" "${IMAGE_CACHE_PATH%.*}" \ - # && exit 6 || exit 1;; + application/pdf) + pdftoppm -f 1 -l 1 \ + -scale-to-x "${DEFAULT_SIZE%x*}" \ + -scale-to-y -1 \ + -singlefile \ + -jpeg -tiffcompression jpeg \ + -- "${FILE_PATH}" "${IMAGE_CACHE_PATH%.*}" && + exit 6 || exit 1 + ;; ## ePub, MOBI, FB2 (using Calibre) # application/epub+zip|application/x-mobipocket-ebook|\ @@ -331,8 +332,8 @@ handle_mime() { ## Image image/*) - ## Preview as text conversion - # img2txt --gamma=0.6 --width="${PV_WIDTH}" -- "${FILE_PATH}" && exit 4 + chafa --animate=off --size="${PV_WIDTH}x${PV_HEIGHT}" \ + --symbols=block -- "${FILE_PATH}" && exit 4 exiftool "${FILE_PATH}" && exit 5 exit 1 ;;