aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2013-11-26 16:27:56 -0200
committerSilvio Rhatto <rhatto@riseup.net>2013-11-26 16:27:56 -0200
commitb7fc52ce27c4c415c322b0b0ed8eee296cfa47ee (patch)
tree3fbdd48dcc20bc4eaea297cddbae77241f30976d /lib
parent17bfa3c574c8a44614053410edf06791cb432dbc (diff)
downloadkeyringer-b7fc52ce27c4c415c322b0b0ed8eee296cfa47ee.tar.gz
keyringer-b7fc52ce27c4c415c322b0b0ed8eee296cfa47ee.tar.bz2
Builtin implementation for 'tree' action
Diffstat (limited to 'lib')
-rwxr-xr-xlib/keyringer/actions/tree14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/keyringer/actions/tree b/lib/keyringer/actions/tree
index 2033abd..8e94cb0 100755
--- a/lib/keyringer/actions/tree
+++ b/lib/keyringer/actions/tree
@@ -3,6 +3,11 @@
# List keys.
#
+# Thanks http://www.centerkey.com/tree/
+function keyringer_tree {
+ ls -R $* | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
+}
+
# Load functions
LIB="`dirname $0`/../functions"
source "$LIB" || exit 1
@@ -14,6 +19,13 @@ CWD="`pwd`"
shift
ARGS="`echo "$*" | sed -e "s|^/*||"`"
+# Check implementation
+if which tree &> /dev/null; then
+ TREE="tree"
+else
+ TREE="keyringer_tree"
+fi
+
# Run list command
-cd "$KEYDIR" && tree $ARGS
+cd "$KEYDIR" && $TREE $ARGS
cd "$CWD"