scripts: update complete_nick - sob - simple output bar
(HTM) git clone git://git.codemadness.org/sob
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit e0cb947ff6f99ab3423e45bc681fd2ab67d4379b
(DIR) parent 215516a8bfac89528bcdee472b89d18546504515
(HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sun, 9 Nov 2014 14:23:48 +0000
scripts: update complete_nick
Diffstat:
M scripts/complete_nick | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
---
(DIR) diff --git a/scripts/complete_nick b/scripts/complete_nick
@@ -1,14 +1,11 @@
#!/bin/sh
file="${OUTFILE}"
-test -f "${file}" || exit 1
+namesfile="$(dirname ${OUTFILE})/names"
+test -f "${namesfile}" || exit 1
grepword() {
- if test x"$1" = x""; then
- grep -oE '^[0-9\: \-]*(<[^>]*)' "${file}" | sed 's@^[0-9\: \-]*<@@g'
- else
- grep -oE '^[0-9\: \-]*(<[^>]*)' "${file}" | sed 's@^[0-9\: \-]*<@@g' | grep -E "^$1"
- fi
+ grep -iE "^$1" "${namesfile}"
}
word="${SOBWRITE}"
@@ -19,13 +16,20 @@ word="${SOBWRITE}"
# line=$(grepword "${word}" | sort | uniq | dmenu -l 20)
#fi
-matches=$(grepword "${word}" | sort | uniq | wc -l)
-if test x"${matches}" = x"1"; then
+matches=$(grepword "${word}" | wc -l)
+if test x"${matches}" = x"0"; then
+ exit 1
+elif test x"${matches}" = x"1"; then
line=$(grepword "${word}" | tail -n 1)
else
line=$(grepword "${word}" | sort | uniq | dmenu -l 20)
fi
if test x"${line}" != x""; then
- printf '%s' "${line}"
+ # if line empty or a command: don't add ": ".
+ if expr x"${SOBLINE}" : x"/" > /dev/null; then
+ printf '%s ' "${line}"
+ else
+ printf '%s: ' "${line}"
+ fi
fi