From b7fc52ce27c4c415c322b0b0ed8eee296cfa47ee Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Tue, 26 Nov 2013 16:27:56 -0200 Subject: Builtin implementation for 'tree' action --- lib/keyringer/actions/tree | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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" -- cgit v1.2.3