aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncaen <mail@duncano.de>2017-02-13 01:51:41 +0100
committerDuncaen <mail@duncano.de>2017-02-13 01:52:11 +0100
commit28bb440e6c5b056970b4948e252f9085e28015bb (patch)
tree80e2101f135fe374c6db7404254acdecfd408da8
parent297e98d72661b0f895dfc65342cfed3ff780a183 (diff)
downloaddotfiles-28bb440e6c5b056970b4948e252f9085e28015bb.tar.gz
bin/h: add desc, cvs support and simplify
-rwxr-xr-xbin/h14
1 files changed, 8 insertions, 6 deletions
diff --git a/bin/h b/bin/h
index c74d0b9..460ba11 100755
--- a/bin/h
+++ b/bin/h
@@ -1,8 +1,10 @@
#!/bin/sh
+# h - print the current paths vcs root or home
-dir="$PWD"
-while [ -n "$dir" ]; do
- [ -d "$dir/.git" ] && break
- [ "$dir" = "$HOME" ] && break
- dir="${dir%/*}"
-done && echo "$dir" || return 1
+while \
+ [ -n "${d:=$PWD}" ] && \
+ [ ! -d "$d/.git" ] && \
+ [ ! -d "$d/CVSROOT" ] && \
+ [ "$d" != "$HOME" ]
+ do d="${d%/*}"
+done && printf "%s\n" "$d"