Skip to content

Commit

Permalink
rename r - randomization to p - pretify, configuring colors and speci…
Browse files Browse the repository at this point in the history
…al patterns
  • Loading branch information
c00kiemon5ter committed Jan 11, 2013
1 parent 872d497 commit abb584d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions iii.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
: "${c:=""}" # channel - empty for network (default)
: "${m:=12}" # max nick lenght
: "${h:=20}" # lines from history
: "${r:=true}" # whether to use random colors for nicks
: "${p:=1}" # pretify - colors and stuff
: "${l:=3}" # highlight color
: "${f:=120}" # max characters per mesg - fold after limit

Expand Down Expand Up @@ -55,10 +55,11 @@ do

# pretify special symbols around words
# *bold* _underline_ /italics/ and underline urls
$r && mesg="$(echo "$mesg" | awk -vis="$(tput sitm; tput setaf 05)" -vie="$(tput ritm)${wht}" \
-vus="$(tput smul; tput setaf 03)" -vue="$(tput rmul)${wht}" \
-vbs="$(tput bold; tput setaf 01)" -vbe="$(tput sgr0)${wht}" \
-vls="$(tput smul; tput setaf 11)" -vle="$(tput rmul)${wht}" '
[ "$p" -ne 0 ] && mesg="$(echo "$mesg" | awk \
-vis="$(tput sitm; tput setaf 05)" -vie="$(tput ritm)${wht}" \
-vus="$(tput smul; tput setaf 03)" -vue="$(tput rmul)${wht}" \
-vbs="$(tput bold; tput setaf 01)" -vbe="$(tput sgr0)${wht}" \
-vls="$(tput smul; tput setaf 11)" -vle="$(tput rmul)${wht}" '
function replace(l, s, r) {
p = index(l, s) - 1
n = p + length(s) + 1
Expand All @@ -83,10 +84,10 @@ do
}
')"

$r && clr="$(tput setaf $(( $(printf '(%d ^ %d + %d)' "${#nick}" "'$nick" "'${nick#?}") % 14 + 1)))" || clr="$grn"
[ "$p" -ne 0 ] && clr="$(tput setaf $(( $(printf '(%d ^ %d + %d)' "${#nick}" "'$nick" "'${nick#?}") % 14 + 1)))" || clr="$grn"

# let server name have a static color across all randomization functions
$r && [ "$nick" == '-!-' ] && clr="$(tput setaf 14)"
[ "$p" -ne 0 ] && [ "$nick" == '-!-' ] && clr="$(tput setaf 14)"
case "$mesg" in ACTION*) mesg="$clr$nick$rst:${mesg#ACTION}" nick="*" clr="$grn" ;; esac

# fold lines breaking on spaces if message is greater than 'f' chars
Expand Down
2 changes: 1 addition & 1 deletion tmiii.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# accepts all env vars iii.sh accepts plus 't' which sets the terminal

## collect options from env - all opts to iii.sh should be set here
opts="TERM="${t:-rxvt-unicode}" m="$m" h="$h" r=$r u="$u" l="$l" i="$i" n="$n" c="$c""
opts="TERM="${t:-rxvt-unicode}" m="$m" h="$h" p=$p u="$u" l="$l" i="$i" n="$n" c="$c""

## spawn a new tmux window named <channel> in a tmux session named IRC
if ! tmux list-sessions | awk -v r=1 '$1 == "IRC:" { exit r=0 } END { exit r }'
Expand Down

0 comments on commit abb584d

Please sign in to comment.