complete_nick (745B)
1#!/bin/sh 2 3file="${OUTFILE}" 4namesfile="$(dirname ${OUTFILE})/names" 5test -f "${namesfile}" || exit 1 6 7grepword() { 8 grep -iE "^$1" "${namesfile}" 9} 10 11word="${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 19matches=$(grepword "${word}" | wc -l) 20if test x"${matches}" = x"0"; then 21 exit 1 22elif test x"${matches}" = x"1"; then 23 line=$(grepword "${word}" | tail -n 1) 24else 25 line=$(grepword "${word}" | sort | uniq | dmenu -l 20) 26fi 27 28if 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 35fi