# -*- 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.44.1
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  75fb34f62f6affacdaa5dc7b27e29baa75e2d9dd \
                        sha256  20ff4630f75686f8cb7c64b03ee36e210de97743482e53d427694e0f306b73af \
                        size    251063

go.vendors          golang.org/x/text \
                        lock    v0.5.0 \
                        rmd160  22d952d3a5226707a3ab3575c75ad6269ab28851 \
                        sha256  ae1308be329a9c8a939243c5f44410d5155594d3d31c274bd6daa2399784ce33 \
                        size    8354318 \
                    golang.org/x/term \
                        lock    v0.13.0 \
                        rmd160  5575fcb908ce86b2e4ba2be7fe23b33b8ff707af \
                        sha256  7fc5c4e59a7e0a0fce704201cdd95554d6ac1ca3972958797d91e35116f4b54f \
                        size    14796 \
                    golang.org/x/sys \
                        lock    v0.14.0 \
                        rmd160  d36195a767e48169c413eb77843e71fa014e7ac2 \
                        sha256  9407ff6fbe0423f2559a99f7ad55479e1eb20201c5dfb9e885abb83c7b44bfc4 \
                        size    1442384 \
                    golang.org/x/sync \
                        lock    886fb9371eb4 \
                        rmd160  07189c3d28ca5ed453a679628116e7c5a8c5233d \
                        sha256  8bd1485b686a749c6373a8713fa7942673f2fcae03c40547e2a94d4cd925611e \
                        size    19384 \
                    github.com/saracen/walker \
                        lock    v0.1.3 \
                        rmd160  44eaf0e72971dbf99afecbf2d2458089f104297b \
                        sha256  43df182f9772de1386d0d1d2852599f2d904820416a2e6b5a8fb4a07c781ce76 \
                        size    11298 \
                    github.com/rivo/uniseg \
                        lock    v0.4.4 \
                        rmd160  00ed48c772088197112a0732fe3c7cd90ec8c94e \
                        sha256  c80468291b3a3df4d56d48f1335564a3813fb7e6d5588a8502949fd9d67a704a \
                        size    453472 \
                    github.com/mattn/go-shellwords \
                        lock    v1.0.12 \
                        rmd160  966c28bc678d710bb7f052842378462c800f24d7 \
                        sha256  317db0f9d20370e4dc274495c7ecd409f8cefc84d4629df65f62ecd558c417ed \
                        size    6326 \
                    github.com/mattn/go-runewidth \
                        lock    v0.0.14 \
                        rmd160  7186117475d80aff012960b61daefd53c7efeca6 \
                        sha256  71e68e76e460aff1af8b58453a5a7b2278c42f6659c8c7b4321907bdf14ee6eb \
                        size    18269 \
                    github.com/mattn/go-isatty \
                        lock    v0.0.17 \
                        rmd160  8a79d7ac1ac5311cb4892f75b7a439fd07cccc17 \
                        sha256  e75610c71dfca6ab7f671d1372f7b603b98338b7cbf1098d5a418d5a6760fb52 \
                        size    4700 \
                    github.com/lucasb-eyer/go-colorful \
                        lock    v1.2.0 \
                        rmd160  a4183d0625e6c94474942cdc544c1061d35c4e34 \
                        sha256  fbad1aade4444bf51409f5b6a008cc14c7a7cdd1af856841fc1170605fae3914 \
                        size    970841 \
                    github.com/gdamore/tcell \
                        lock    v2.5.4 \
                        rmd160  761731b4f1b46a48b7116e2b07069c816a16a1c7 \
                        sha256  bcf9ff6786fe66e2ab5293f965693331a16936fbad773849d8d1169548ea13ba \
                        size    165301 \
                    github.com/gdamore/encoding \
                        lock    v1.0.0 \
                        rmd160  3ed8916f763a5b51db1bcc8bd3ad06cf3d12ec07 \
                        sha256  4f470c7308790bea8a526ea26cecbaa22345aad8dc566821cda6175b3d241ee1 \
                        size    10900

# 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.
"
