]> gitweb.fluxo.info Git - keyringer.git/commitdiff
Builtin implementation for 'tree' action
authorSilvio Rhatto <rhatto@riseup.net>
Tue, 26 Nov 2013 18:27:56 +0000 (16:27 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Tue, 26 Nov 2013 18:27:56 +0000 (16:27 -0200)
lib/keyringer/actions/tree

index 2033abd8d6ef15d52b394b354aca1015bdbcd255..8e94cb0eca9803fffc4254b08d725c623fe5a7f7 100755 (executable)
@@ -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"