summaryrefslogtreecommitdiff
path: root/.config/wmii-hg/include.sh
diff options
context:
space:
mode:
Diffstat (limited to '.config/wmii-hg/include.sh')
-rw-r--r--.config/wmii-hg/include.sh71
1 files changed, 65 insertions, 6 deletions
diff --git a/.config/wmii-hg/include.sh b/.config/wmii-hg/include.sh
index bd9456f..36f8f3e 100644
--- a/.config/wmii-hg/include.sh
+++ b/.config/wmii-hg/include.sh
@@ -1,11 +1,70 @@
#!/bin/bash
-if [[ -z "$WMII_NAMESPACE" ]]; then
- export WMII_NAMESPACE="`wmiir namespace`"
+if [ -z "$WMII_NAMESPACE" ]; then
+ export WMII_NAMESPACE=`wmiir namespace`
fi
-if [[ -z "$WMII_DIR" ]]; then
- export WMII_DIR="$HOME/n/wmii${DISPLAY}"
+if [ -z "$WMII_DIR" ]; then
+ export WMII_DIR=$WMII_NAMESPACE/mnt
fi
-. util.sh
-. config.sh
+# a -- a work-around for buggy IO append in 9pfuse
+# useing '|a' should be just like using '>>', but will work
+# when 9pfuse decides to bug out.
+a() {
+ f="${1/#${WMII_DIR}/}"
+ if [ "$f" = "$1" ]; then
+ cat >> "$1"
+ else
+ if wmiir ls "$f" &>/dev/null; then
+ wmiir write "$f"
+ else
+ wmiir create "$f"
+ fi
+ fi
+}
+
+# I like wmiir's setsid better than linux-utils'
+setsid() { wmiir setsid "$@"; }
+
+path_ls() {
+ find -L `echo "$@"|sed 'y/:/ /'` -maxdepth 1 -type f -executable -printf '%f\n' 2>/dev/null| sort -u
+}
+
+path_which() {
+ mypath=$1
+ prog=$2
+ which=`which which`
+ PATH="$mypath" "$which" -- "$prog" 2>/dev/null
+}
+
+
+lstags() {
+ ls $WMII_DIR/tag | sed '/^sel$/d'
+}
+
+scansection() {
+ file=`path_which "$WMII_CONFPATH" wmiirc`
+ sec=$1
+ tmp=`mktemp`
+ if [ -n "$sec" ]; then
+ < "$file" sed -n "/^\s*$sec\s*()/,/##\s*End $sec/p" | sed '1d;$d'> $tmp
+ else
+ < "$file" sed "/\s*}\s*##\s*End\s/d" > $tmp
+ fi
+ < $tmp sed -n '/##/p'|sed -r 's/^\s*(.*)\)\s*## ?/\t\1\t/;s/\s*## ?//'
+ rm $tmp
+}
+
+conffile() {
+ echo "$HOME/.wmii/$@"
+}
+
+Action() {
+ prog=`path_which "$WMII_CONFPATH" $1`; shift
+ if [ -n "$prog" ]; then
+ "$prog" "$@"
+ return $?
+ else
+ return 1
+ fi
+}