Skip to content

Instantly share code, notes, and snippets.

@mkhl
Forked from ieure/cdup.sh
Created December 13, 2011 22:19
Show Gist options
  • Save mkhl/1474167 to your computer and use it in GitHub Desktop.
Save mkhl/1474167 to your computer and use it in GitHub Desktop.
function cdup {
local dir=$PWD
local target=${*:-.git}
until [ -e "$dir/$target" -o "$dir" = "/" ]; do
dir="$(dirname "$dir")"
done
test -e "$dir/$target" && cd "$dir"
}
function catup {
local target=$*
(cdup "$target" && cat "$target")
}
function lsup {
local target=$*
(cdup "$target" && ls -l "$target")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment