# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           golang 1.0

go.setup            github.com/junegunn/fzf 0.74.0 v
github.tarball_from archive
revision            0

description         A command-line fuzzy finder written in Go

long_description    {*}${description}

categories          sysutils
installs_libs       no
license             MIT
maintainers         {isi.edu:calvin @cardi} \
                    {gmail.com:herby.gillot @herbygillot} \
                    openmaintainer

checksums           ${distname}${extract.suffix} \
                        rmd160  6904d7695968049becc2acfcf450b91ee3f8954a \
                        sha256  55ab5f2256edd8890f81d407b63d3a3e81cffe10e318cd196031dc85efdeb079 \
                        size    446279

go.vendors          golang.org/x/text \
                        lock    v0.28.0 \
                        rmd160  e5ab05d3bbb0adafb3984b7d33035c018b6a164a \
                        sha256  f11d445bbe3c12de14510103f18253b1840863ae66bebe2dfd65eceddb2be645 \
                        size    8974651 \
                    golang.org/x/term \
                        lock    v0.34.0 \
                        rmd160  c17f07f42813271264c518e71ffb0e025c096903 \
                        sha256  ed10832a496fc6e6af32e8a0933942b042f362bb117ccb232a0553bc057da308 \
                        size    15937 \
                    golang.org/x/sys \
                        lock    v0.35.0 \
                        rmd160  94ac3a8dd72c3a5b79bc8f068285b77634935368 \
                        sha256  b1c65be93d2d2ced17bd5ad9386a2385fd7258c708d3879f69e2485a1cea1011 \
                        size    1531744 \
                    github.com/rivo/uniseg \
                        lock    v0.4.7 \
                        rmd160  a9056dc9a2a80aa9c46d0ff9e54f9e2e5a498c41 \
                        sha256  abc6a2f17b64b34b8a0c56eb9d0b53886ebbe0c88d467755c09c7fa696a16677 \
                        size    458166 \
                    github.com/mattn/go-runewidth \
                        lock    v0.0.16 \
                        rmd160  297825c4365b5f723ae485e726259ebb620ecd66 \
                        sha256  6c9e81a6b46220612b97ebc35e8d29d1907fd225a9ce3e40b7cebd64cc58d09c \
                        size    18496 \
                    github.com/mattn/go-isatty \
                        lock    v0.0.22 \
                        rmd160  17623a5f25dfb8ed55495c059c4d0ca5744624f5 \
                        sha256  831ddc530128a925738793863e9814ccb148f0fd22b242f6e593f20107b19643 \
                        size    4804 \
                    github.com/lucasb-eyer/go-colorful \
                        lock    v1.2.0 \
                        rmd160  a4183d0625e6c94474942cdc544c1061d35c4e34 \
                        sha256  fbad1aade4444bf51409f5b6a008cc14c7a7cdd1af856841fc1170605fae3914 \
                        size    970841 \
                    github.com/junegunn/go-shellwords \
                        lock    2aa3b3277741 \
                        rmd160  e485926aae7afe9be61cd23728b7483a51459d95 \
                        sha256  37c95a7a5fd64ef3baa539e03efe1334e7cb3e2d75297ddc11a49da39c1a5e37 \
                        size    6627 \
                    github.com/gdamore/tcell/v2 \
                        lock    v2.9.0 \
                        rmd160  42fdfbfc44d5b802ce6190738e53db8779785205 \
                        sha256  cef3c5c649a976b48002526414775c97ae67a4eb7ea78a6a1ffc53c4f1e65859 \
                        size    187497 \
                    github.com/gdamore/encoding \
                        lock    v1.0.1 \
                        rmd160  7e73cab014fe3647552b67678a397ba5ce2475e9 \
                        sha256  dc7a586abe34b2d9562ca2aed225a1db734cc8b548a89bb238e75251d9aa0344 \
                        size    14814 \
                    github.com/charlievieth/fastwalk \
                        lock    v1.0.14 \
                        rmd160  9ec176cb0ff1f409f78d9fc3ad47d5fa1cad81c9 \
                        sha256  49602154d6cd575b4f72ae78870afefa0621c6d9bec1ad2f5e74e01399a3cf32 \
                        size    46442

# adds specific major.minor.patch version information
build.args-append   \
    "-ldflags \"-X main.version=${version} -X main.revision=MacPorts\""

destroot {
    # install fzf
    xinstall -d ${destroot}${prefix}/bin
    xinstall -m 0755 ${worksrcpath}/${name} ${destroot}${prefix}/bin/${name}
    # install fzf-tmux (has a failover if tmux isn't installed)
    xinstall -m 0755 ${worksrcpath}/bin/${name}-tmux \
        ${destroot}${prefix}/bin/${name}-tmux

    # install documentation
    xinstall -d -m 0755 ${destroot}${prefix}/share/doc/${name}
    xinstall -m 0644 -W ${worksrcpath} LICENSE README-VIM.md README.md \
        ${destroot}${prefix}/share/doc/${name}

    # install man pages
    xinstall -d -m 0755 ${destroot}${prefix}/share/man/man1
    xinstall -m 0644 {*}[glob ${worksrcpath}/man/man1/*.1] \
        ${destroot}${prefix}/share/man/man1/

    # shell completion and key binding files
    xinstall -d ${destroot}${prefix}/share/fzf/shell/
    xinstall -m 0644 {*}[glob ${worksrcpath}/shell/*] \
        ${destroot}${prefix}/share/fzf/shell/

    # fzf.vim plugin
    xinstall -d ${destroot}${prefix}/share/fzf/vim/doc/
    xinstall -m 0644 ${worksrcpath}/doc/${name}.txt \
        ${destroot}${prefix}/share/fzf/vim/doc/${name}.txt
    xinstall -d ${destroot}${prefix}/share/fzf/vim/plugin/
    xinstall -m 0644 ${worksrcpath}/plugin/${name}.vim \
        ${destroot}${prefix}/share/fzf/vim/plugin/${name}.vim
}

notes "
Bash
====

Append this line to ~/.bashrc to enable fzf keybindings for Bash:

    source ${prefix}/share/fzf/shell/key-bindings.bash

Append this line to ~/.bashrc to enable fuzzy auto-completion for Bash:

    source ${prefix}/share/fzf/shell/completion.bash


Zsh
===

Append this line to ~/.zshrc to enable fzf keybindings for Zsh:

    source ${prefix}/share/fzf/shell/key-bindings.zsh

Append this line to ~/.zshrc to enable fuzzy auto-completion for Zsh:

    source ${prefix}/share/fzf/shell/completion.zsh


Fish
====

To enable fzf keybindings for fish, append this line to
~/.config/fish/config.fish:

    source ${prefix}/share/fzf/shell/key-bindings.fish

and add the following to ~/.config/fish/functions/fish_user_key_bindings.fish:

    function fish_user_key_bindings
        fzf_key_bindings
    end


Vim
===

The Vim plugin is located in ${prefix}/share/fzf/vim.

Enable the Vim plugin by adding the following to your Vim configuration
file (default: ~/.vimrc):

    set rtp+=${prefix}/share/fzf/vim

Documentation for fzf and the Vim plugin is located in
${prefix}/share/doc/fzf.
"
