summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorThorsten Wißmann <edu@thorsten-wissmann.de>2011-08-31 03:53:59 +0200
committerThorsten Wißmann <edu@thorsten-wissmann.de>2011-08-31 03:53:59 +0200
commit1984464d78425e55490879c78544f3222a19c787 (patch)
tree26630a5d188dc4891d132ff329a88ed8ae6dd079 /scripts
parentfd6309d0c5cb45cd7199ff8fa68eebf947ffe80f (diff)
scripts: added dumpbeatify.sh
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/dumpbeatify.sh23
1 files changed, 23 insertions, 0 deletions
diff --git a/scripts/dumpbeatify.sh b/scripts/dumpbeatify.sh
new file mode 100755
index 00000000..c4fd47ef
--- /dev/null
+++ b/scripts/dumpbeatify.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+# aligns the output of dump command as a nice tree
+# usage:
+# herbstclient dump | ./dumpbeatify.sh
+
+indent=""
+
+# an ugly hack, but it's okey:
+IFS="" # we do not need fields
+# but with IFS="" read -n 1 can read spaces :)
+
+function p(){
+ while read -n 1 p ; do
+ [ "$p" = '(' ] && echo -en '\n'"$indent"'(' && indent+=' ' && ( p ) && continue
+ [ "$p" = ')' ] && echo -en ')' && return 0
+ echo -n "$p"
+ done
+ echo
+}
+
+p | sed '/^[ ]*$/d'
+