complete_nick - sob - simple output bar
 (HTM) git clone git://git.codemadness.org/sob
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
       complete_nick (745B)
       ---
            1 #!/bin/sh
            2 
            3 file="${OUTFILE}"
            4 namesfile="$(dirname ${OUTFILE})/names"
            5 test -f "${namesfile}" || exit 1
            6 
            7 grepword() {
            8         grep -iE "^$1" "${namesfile}"
            9 }
           10 
           11 word="${SOBWRITE}"
           12 
           13 #if test x"${DISPLAY}" = x""; then
           14 #        line=$(grepword "${word}" | sort | uniq | slmenu -l 20)
           15 #else
           16 #        line=$(grepword "${word}" | sort | uniq | dmenu -l 20)
           17 #fi
           18 
           19 matches=$(grepword "${word}" | wc -l)
           20 if test x"${matches}" = x"0"; then
           21         exit 1
           22 elif test x"${matches}" = x"1"; then
           23         line=$(grepword "${word}" | tail -n 1)
           24 else
           25         line=$(grepword "${word}" | sort | uniq | dmenu -l 20)
           26 fi
           27 
           28 if test x"${line}" != x""; then
           29         # if line empty or a command: don't add ": ".
           30         if expr x"${SOBLINE}" : x"/" > /dev/null; then
           31                 printf '%s ' "${line}"
           32         else
           33                 printf '%s: ' "${line}"
           34         fi
           35 fi