Skip to content

Commit

Permalink
add manpages and kitty images previews
Browse files Browse the repository at this point in the history
  • Loading branch information
MarrekNozka committed Apr 25, 2024
1 parent b27823e commit 91424fb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ This uses the programs:
* `pdftotext` (poppler-utils), for PDF preview
* `odt2txt`, simple converter from OpenDocument Text
* `catdoc` and `docx2txt`, for M\$-Office preview
* [`ascii-image-converter`](https://github.com/TheZoraiz/ascii-image-converter)
* [kitty](https://sw.kovidgoyal.net/kitty/) `icat`
or [`ascii-image-converter`](https://github.com/TheZoraiz/ascii-image-converter)
for images

On Debian/Devuan based systems you can install them like so:

```bash
sudo apt update; sudo apt install -y bat tree hexyl atool poppler-utils odt2txt catdoc
sudo apt update; sudo apt install -y bat tree hexyl atool poppler-utils odt2txt catdoc kitty
```

Similarly, I use this with `fzf` (fuzzy finder), which you will need to follow the usage example.
Expand Down
16 changes: 15 additions & 1 deletion fzf--previewer.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@ FILE_PATH=$1

bat=`/usr/bin/which bat || echo batcat`

kitty +kitten icat --clear --z-index=-1 --transfer-mode=stream 2>/dev/null
if [ -d "$1" ]; then
tree --du -C -L 2 "$FILE_PATH"

elif which $1 &>/dev/null; then
type -a $1
if man -w $1 &>/dev/null; then
print
man $1 | col -bx | head -n 30
fi
elif ! [ -f "$1" ]; then
echo $1 | read -A tokens
for token in $tokens; do
Expand Down Expand Up @@ -64,7 +72,13 @@ else

[jJ][pP][gG]|[jJ][pP][eE][gG]|[gG][iI][fF]|[bB][mM][pP]|webp|[pP][nN][gG]|\
[tT][iI][fF]|[tT][iI][fF][fF])
ascii-image-converter --width $[$COLUMNS - 20] --braille --color "${FILE_PATH}" && exit 0
zmodload zsh/mathfunc
width=$(( $COLUMNS - 10 ))
height=$(( int($LINES * 0.77) - 5 ))
identify ${FILE_PATH}
kitty +kitten icat --z-index=-1 --engine=builtin --clear --align=center --place=${width}x${height}@2x2 --transfer-mode=stream <"${FILE_PATH}" && exit 0
ascii-image-converter --dimensions ${with},${height} --braille --color "${FILE_PATH}" && exit 0
# fim sdl=600:600 ${FILE_PATH}
exit 1;;

*)
Expand Down

0 comments on commit 91424fb

Please sign in to comment.