up: Command line tool to generate pathnames to facilitate moving upward in a file system.

[ bsd3, program, utils ] [ Propose Tags ]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.0.3, 1.0.0, 1.0.0.1, 1.0.0.2, 1.0.0.3, 1.0.0.4, 1.0.0.5, 1.0.0.6, 2.0.0.0
Dependencies base (>=4.9 && <5.0), directory (>=1.2 && <1.3), filepath (>=1.4 && <1.5), lambda-options (>=0.9 && <0.10), mtl (>=2.2 && <2.3), split (>=0.2 && <0.3) [details]
License BSD-3-Clause
Author Thomas Eding
Maintainer none
Category Utils
Home page https://github.com/thomaseding/up
Uploaded by ThomasEding at 2017-01-04T20:33:58Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Executables up
Downloads 6565 total (24 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
Last success reported on 2017-01-04 [all 3 reports]

Readme for up-1.0.0.4

[back to package description]

Homepage: https://github.com/thomaseding/up

Hackage: https://hackage.haskell.org/package/up


Install from git repository:

$ cabal configure
$ cabal build
$ cabal install

Install from Hackage.

$ cabal update
$ cabal install up

These will install the up command.


Example usage:

$ cd /home/thomas/code/up/src
$ up thomas
../../..
$ up --absolute thomas
/home/thomas
$ up ....
../../..
$ up --relative --from-to /abc/def/xyz/ abc
../../..

See up --help for more info.


up generates file path strings, but it (by itself) does not change your current working directory. So below is code you can add to your shell's config file (e.g. .bashrc) to use the up program to change your directory.

g () {
    local DEST
    DEST=$(up "$@")
    if [ "$?" == '0' ]
    then
        cd "$DEST"
    else
        return "$?"
    fi
}

Example usage:

$ cd /home/thomas/code/up/src
$ g thomas
$ pwd
/home/thomas

For shell autocomplete for the above g command, you can add this to your shell's config in addition:

_g () {
    if [ "$COMP_CWORD" == "1" ]
    then
        local cur=${COMP_WORDS[COMP_CWORD]}
        local parts="$(pwd | tr '/' ' ')"
        COMPREPLY=( $(compgen -W "$parts" -- $cur) )
    fi
}
complete -F _g g