commit 9ce9eea11d50b0f748730c5acb3699e23a958a56
parent 25a5c231e41db16fc2d468c55cfbfa775ba6f522
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Tue, 28 Oct 2014 21:43:41 +0000
rename hysteria scripts to make it usable system-wide
- use the prefix "hysteria-" for the helper scripts.
- make the default config location "$HOME/.hysteria/config".
Diffstat:
10 files changed, 97 insertions(+), 97 deletions(-)
diff --git a/autojoin b/autojoin
@@ -1,24 +0,0 @@
-#!/bin/sh
-
-if [ "$3" = "" ]; then
- . ./config
-else
- . "$3"
-fi
-
-if test $# -lt 2; then
- echo "usage: $(basename $0) host channel [config]" 1>&2
- exit 1
-fi
-
-tmux list-sessions -F '#S' 2>/dev/null | \
- grep "^$session$" >/dev/null 2>/dev/null
-if [ $? -eq 1 ]; then
- echo "no hysteria session \"$session\" running" 1>&2
- exit 1
-fi
-
-host="$1"
-c="$2"
-echo "/join $c" > "$ircdir/$host/in"
-./waitfile "$ircdir/$host/$c/out"
diff --git a/connectserver b/connectserver
@@ -1,26 +0,0 @@
-#!/bin/sh
-
-if [ "$2" = "" ]; then
- . ./config
-else
- . "$2"
-fi
-
-if test -z $1; then
- echo "usage: $(basename $0) host [config]" 1>&2
- exit 1
-fi
-
-tmux list-sessions -F '#S' 2>/dev/null | \
- grep "^$session$" >/dev/null 2>/dev/null
-if [ $? -eq 1 ]; then
- echo "no hysteria session \"$session\" running" 1>&2
- exit 1
-fi
-
-host=$(printf '%s' "$1" | cut -d ':' -f 1)
-port=$(printf '%s' "$1" | cut -s -d ':' -f 2)
-[ "$port" = "" ] && port="6667"
-tmux new-window "ii -i $ircdir -s $host -p $port -n $nick -f $fullname"
-tmux rename-window "$host"
-./waitfile "$ircdir/$host/out"
diff --git a/hysteria b/hysteria
@@ -1,7 +1,7 @@
#!/bin/sh -x
if [ "$1" = "" ]; then
- config="./config"
+ config="$HOME/.hysteria/config"
else
config=$(readlink -f "$1")
fi
@@ -9,15 +9,15 @@ fi
rm -rf "$ircdir"
mkdir -p "$ircdir"
-tmux new-session -s "$session" -d "./monitor \"$config\""
+tmux new-session -s "$session" -d "hysteria-monitor \"$config\""
tmux rename-window "monitor"
for h in $hosts; do
- ./connectserver "$h" "$config"
+ hysteria-connect "$h" "$config"
done
for c in $channels; do
host=$(printf '%s' "$c" | cut -d ':' -f 1)
channel=$(printf '%s' "$c" | cut -s -d ':' -f 2)
- ./autojoin "$host" "$channel" "$config"
+ hysteria-autojoin "$host" "$channel" "$config"
done
diff --git a/hysteria-autojoin b/hysteria-autojoin
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+if [ "$3" = "" ]; then
+ . "$HOME/.hysteria/config"
+else
+ . "$3"
+fi
+
+if test $# -lt 2; then
+ echo "usage: $(basename $0) host channel [config]" 1>&2
+ exit 1
+fi
+
+tmux list-sessions -F '#S' 2>/dev/null | \
+ grep "^$session$" >/dev/null 2>/dev/null
+if [ $? -eq 1 ]; then
+ echo "no hysteria session \"$session\" running" 1>&2
+ exit 1
+fi
+
+host="$1"
+c="$2"
+echo "/join $c" > "$ircdir/$host/in"
+hysteria-waitfile "$ircdir/$host/$c/out"
diff --git a/hysteria-connect b/hysteria-connect
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+if [ "$2" = "" ]; then
+ . "$HOME/.hysteria/config"
+else
+ . "$2"
+fi
+
+if test -z $1; then
+ echo "usage: $(basename $0) host [config]" 1>&2
+ exit 1
+fi
+
+tmux list-sessions -F '#S' 2>/dev/null | \
+ grep "^$session$" >/dev/null 2>/dev/null
+if [ $? -eq 1 ]; then
+ echo "no hysteria session \"$session\" running" 1>&2
+ exit 1
+fi
+
+host=$(printf '%s' "$1" | cut -d ':' -f 1)
+port=$(printf '%s' "$1" | cut -s -d ':' -f 2)
+[ "$port" = "" ] && port="6667"
+tmux new-window "ii -i $ircdir -s $host -p $port -n $nick -f $fullname"
+tmux rename-window "$host"
+hysteria-waitfile "$ircdir/$host/out"
diff --git a/highlight.c b/hysteria-highlight.c
diff --git a/hysteria-monitor b/hysteria-monitor
@@ -0,0 +1,42 @@
+#!/bin/sh
+#
+# Monitor for private messages and/or new channels and
+# create a new split tmux window
+
+if [ "$1" = "" ]; then
+ . "$HOME/.hysteria/config"
+else
+ . "$1"
+fi
+
+while :; do
+ for n in $(find "$ircdir" -name "in" | sort -r 2>/dev/null); do
+ title=$(printf '%s' "$n" | awk -F/ '{ \
+ if (NF == 4) \
+ print $2":"$3; \
+ else if (NF == 3) \
+ print $2}')
+ found=0
+ for t in $(tmux list-windows -F '#W'); do
+ if test "$t" = "$title"; then
+ found=1
+ break
+ fi
+ done
+ if test $found -eq 0; then
+ INFILE="$(readlink -f $n)"
+ NDIR="$(dirname ${INFILE})"
+ OUTFILE="${NDIR}/out"
+ CHAN="$(basename ${NDIR})"
+ # default inputcmd if not set in config.
+ if test x"${inputcmd}" = x""; then
+ inputcmd='cat >> "$INFILE"'
+ fi
+ tmux new-window "tail -f '$OUTFILE' | hysteria-highlight"
+ tmux split-window -v -p 1 "tmux resize-pane -y 4; \
+ CHAN='$CHAN' INFILE='$INFILE' OUTFILE='$OUTFILE' eval '$inputcmd'"
+ tmux rename-window "$title"
+ fi
+ done
+ sleep 1
+done
diff --git a/waitfile b/hysteria-waitfile
diff --git a/mkfile b/mkfile
@@ -2,7 +2,7 @@ CC = cc
CFLAGS = -Wall -pedantic -std=c99 -Os
LDFLAGS = -s
-TARG = highlight
+TARG = hysteria-highlight
all: $TARG
diff --git a/monitor b/monitor
@@ -1,42 +0,0 @@
-#!/bin/sh
-#
-# Monitor for private messages and/or new channels and
-# create a new split tmux window
-
-if [ "$1" = "" ]; then
- . ./config
-else
- . "$1"
-fi
-
-while :; do
- for n in $(find "$ircdir" -name "in" | sort -r 2>/dev/null); do
- title=$(printf '%s' "$n" | awk -F/ '{ \
- if (NF == 4) \
- print $2":"$3; \
- else if (NF == 3) \
- print $2}')
- found=0
- for t in $(tmux list-windows -F '#W'); do
- if test "$t" = "$title"; then
- found=1
- break
- fi
- done
- if test $found -eq 0; then
- INFILE="$(readlink -f $n)"
- NDIR="$(dirname ${INFILE})"
- OUTFILE="${NDIR}/out"
- CHAN="$(basename ${NDIR})"
- # default inputcmd if not set in config.
- if test x"${inputcmd}" = x""; then
- inputcmd='cat >> "$INFILE"'
- fi
- tmux new-window "tail -f '$OUTFILE' | ./highlight"
- tmux split-window -v -p 1 "tmux resize-pane -y 4; \
- CHAN='$CHAN' INFILE='$INFILE' OUTFILE='$OUTFILE' eval '$inputcmd'"
- tmux rename-window "$title"
- fi
- done
- sleep 1
-done