Git Product home page Git Product logo

stpv's Introduction

Simple Terminal PreViewer (STPV)

Preview as many possible kinds of files.

./screenshot.gif

Dependencies

One of the following is needed for image previews

ueberzugUsed for image previews in X11
kittyKitty’s icat is used if available; the only option so far under wayland
chafaCharacter-art previews in the terminal

The following programs. Note that the names are the command names and not the package names

typecli programimage program
directoryls-
archivexzcat,zcat,atool,bsdtar-
rarunrar-
7z+iso7z-
htmlw3m,lynx,elinks,pandoc-
jsonjq,=text-source-
markdownpandoc,=text-source-
csvpandoc,cat-
diffdelta,diff-so-fancy,=text-source-
pdfpdftotext,mutool,exiftoolpdftoppm
epubepub2txt-
text-sourcemdcat,bat,highlight,source-highlight,cat-
imageexiftoolconvert,identify
videoexiftoolffmpegthumbnailer
audioexiftool-
officepandoc,libreofficelibreoffice
xounralpp-xournalpp
torrenttransmission-show-
stl-openscad+convert

Overall, it should work fine without most dependencies, it will fallback to simpler previews.

Usage

stpv

Note: stpvimg should be run first as mentioned below for image previews to work

stpv $FILE $H $W $X $Y $ID # all arguments except FILE are optional
stpv --clear $ID # only if stpvimg is running

stpvimg

ID=$$
stpvimg --listen $ID &
stpvimg --add $ID 1.png
stpvimg --add $ID 2.png $X $Y $W $H
stpvimg --clear $ID
stpvimg --end $ID

Integration with fmz

stpv is already integrated with fmz. Just install stpv and fmz will use it.

Integration with lf

lf now support image previews. All what is needed is to add the following to lfrc:

set previewer stpv
set cleaner stpvimgclr
&stpvimg --listen $id
cmd on-quit $stpvimg --end $id

Integration with fzf

fzfp

Installation

sudo make install

Configuration

The configuration file is typically located in ~/.config/stpv/config.sh. It is a simple shell script that gets sourced in stpv.

Options are listed below. Use any string for true, leave empty for false.

PV_IMAGE_ENABLED=1        # show image previews when possible
PV_TYPE=img               # (img or text) where text shows image previews in the terminal
PREFER_TEXT=              # prefer text over images when displaying documents
DARK_DOCS=                # invert documents preview color in image previews
SAFE=1                    # kill itself if needed (check main for details)
AUTO_ORIENT=1             # auto orient images
MAX_IMG_CACHE_SIZE=300kb  # max image cache size
MAX_IMG_CACHE_W=1920      # max image cached image width
MAX_IMG_CACHE_H=1080      # max image cached image height
TIMEOUT=5                 # maximum time in seconds stpv should take, approximately

The last 3 options control how images are cached. Setting them to empty values will improve performance but at the same time might increase cache size.

Custom previews can be added to your config.sh file as well. Below is an example that shows any file ending with a .moo in cowsay.

#       function    type dep    dep-image
add_top handle_cows cows cowsay -
handle_cows() {
    [ "$file_extension_lower" = moo ] ||
        return "$RET_NO_MATCH"

    cowsay < "$file_path"
}

However, if you think you wrote a nice previewer, pull requests are more than welcomed. Check the main stpv file for more examples.

Related work

ctpv is a remake of stpv in C. It’s faster compared to stpv and has some great potential.

Video

https://youtu.be/MXkjcgzILIc

License

GPL3

stpv's People

Contributors

naheel-azawy avatar nikitaivanovv avatar seirdy avatar xphyro avatar spfabgerman avatar stoychod avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.