: # uhl # unique history list # # Usage: history -r | uhl # # sample usage in an alias # alias ! 'history -r | uhl' # If the environment variable uhistory is set, use it as the # default for limit, else use 20. limit=${uhistory-20} # Default limit is uhistory, if set limit=${1-$limit} # Otherwise, default limit is 20 lines awk ' { if (substr($0,1,1) == "\t") { # This is ksh and ksh history is weird # if you do loops on the command line ms[cnt] = ms[cnt] "\n" $0 if (length > ml[cnt]) ml[cnt] = length next } # csh uses blanks, ksh tab, to separate number from command hn = $1 ss = $0 sub(/^[ \t][ \t]*[0-9][0-9]*[ \t][ \t]*/, "", ss) if (mx[ss] == "") { mx[ss] = "*" mn[++cnt] = hn ms[cnt] = ss if (cnt == '$limit') exit } } END { for (i=cnt; i>=1; i--) printf("%6d\t%s\n",mn[i],ms[i]) }' # 222 vi /usr/local/nib/uhl # 221 ! # 220 vi /usr/local/nib/uhl # 219 ! # 218 vi /usr/local/nib/uhl # 217 ! # 216 vi /usr/local/nib/uhl