diff --git a/README.md b/README.md index d343e5c..9c7e869 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,10 @@ See the difference by disabling this optimization using the `-0` option. Or just sudo snap install --edge tiv +### Homebrew + + brew install https://raw.githubusercontent.com/stefanhaustein/TerminalImageViewer/master/terminalimageviewer.rb + ### Build from source sudo apt install imagemagick || yum install ImageMagick @@ -47,6 +51,11 @@ The shell will expand wildcards. By default, thumbnails and file names will be d - bperel has created a Docker image: https://hub.docker.com/r/bperel/terminalimageviewer - teresaejunior has created a snapcraft.yaml file, which can build a Snap package with `sudo docker run -it --rm -v "$PWD:$PWD" -w "$PWD" snapcore/snapcraft sh -c 'apt-get update && snapcraft'`, and then installed with `sudo snap install --dangerous ./*.snap`. + - aaronliu0130 has added brew support. + +I am happy to accept useful contributions under the Apache 2.0 licencse, but it might make sense to file an issue to discuss the approach before investing large amounts of time. + +Support for additional platforms, CPUs or similar will require somebody who is happy to help with maintenance, in particular, if I don't have access to it. ## Common problems diff --git a/terminalimageviewer.rb b/terminalimageviewer.rb new file mode 100644 index 0000000..0353528 --- /dev/null +++ b/terminalimageviewer.rb @@ -0,0 +1,37 @@ +class Terminalimageviewer < Formula + desc "Display images in a terminal using block graphic characters" + homepage "https://github.com/stefanhaustein/TerminalImageViewer" + url "https://github.com/stefanhaustein/TerminalImageViewer/archive/v1.0.0.tar.gz" + sha256 "d28c5746d25d83ea707db52b54288c4fc1851c642ae021951967e69296450c8c" + head "https://github.com/stefanhaustein/TerminalImageViewer.git" + depends_on "gcc" => :build unless OS.linux? + depends_on "imagemagick" + + def install + cd "src/main/cpp" do + system "make" + if OS.mac? + # No expermimental/filesystem.h on mac + system "#{Formula["gcc"].opt_bin}/gcc-#{Formula["gcc"].version_suffix}", "-std=c++17", + "-Wall", + "-fpermissive", + "-fexceptions", + "-O2", "-c", + "tiv.cpp", "-o", "tiv.o" + system "#{Formula["gcc"].opt_bin}/gcc-#{Formula["gcc"].version_suffix}", "tiv.o", "-o", + "tiv", "-lstdc++fs", + "-pthread", "-s" + else + system "make" + end + bin.install "tiv" + end + end + + test do + # Downloads a public domain test file from wikimedia commons and displays it. + # For some reason, when you redirect the output it is blank. + assert_equal "", + shell_output("#{bin}/tiv -0 https://upload.wikimedia.org/wikipedia/commons/2/24/Cornell_box.png").strip + end +end