# -*- 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
# $Id: Portfile 91992 2012-04-15 08:32:45Z dports@macports.org $

PortSystem          1.0

name                autojump
version             20
categories          sysutils
platforms           darwin
maintainers         gmail.com:johnny.kuan
license             GPL-3+
supported_archs     noarch

description         a cd command that learns

long_description    ${name} is ${description}.

homepage            http://github.com/joelthelion/autojump
master_sites        https://github.com/downloads/joelthelion/autojump
distname            ${name}_v${version}

checksums           rmd160  de31e3396684fc88305b5a4fc47afe5c9a40c060 \
                    sha256  a2a8cf2dcda97fef227a53b3a634ebb7173e0f8da97545da247e7f4de88ba408

depends_run         port:python27

post-patch {
    reinplace "s:/etc/profile.d:${prefix}/etc/profile.d:g" ${worksrcpath}/autojump.sh
    reinplace "s:/usr/bin/env python:${prefix}/bin/python2.7:g" ${worksrcpath}/autojump
}

use_configure       no

build {}

destroot {
    xinstall -m 755 -W ${worksrcpath} autojump ${destroot}${prefix}/bin/
    xinstall -m 755 -W ${worksrcpath} autojump.1 ${destroot}${prefix}/share/man/man1/
    xinstall -d ${destroot}${prefix}/etc/profile.d/
    xinstall -m 644 -W ${worksrcpath} autojump.sh autojump.bash autojump.zsh ${destroot}${prefix}/etc/profile.d/
    xinstall -d ${destroot}${prefix}/share/zsh/site-functions/
    xinstall -m 644 -W ${worksrcpath} _j ${destroot}${prefix}/share/zsh/site-functions/
}

notes "
To use autojump for bash, add the following to the end of your .bash_profile:
if \[ -f ${prefix}/etc/profile.d/autojump.sh \]; then
    . ${prefix}/etc/profile.d/autojump.sh
fi

To use autojump for zsh, add the following to the end of your .zshrc:
export FPATH=\"\$FPATH:${prefix}/share/zsh/site-functions/\"
if \[ -f ${prefix}/etc/profile.d/autojump.sh \]; then
    . ${prefix}/etc/profile.d/autojump.sh
fi
"

livecheck.url       ${homepage}/downloads
livecheck.regex     ${name}_v(\[0-9.\]+)${extract.suffix}
