Commits

Evan Gates  committed 86b211e

update pcw_win.sh to deal with same channel on different server

  • Participants
  • Parent commits b98f25c

Comments (0)

Files changed (1)

 NICK="$4"
 
 
+# possible labels for channels (ran into trouble with same channel name on
+# multiple servers e.g. nickserv)
+#
+# /path/to/prefix/irc.server.net/#channel -> #channel
+#CHAN="$(basename "$CPATH")"
+#
+# /path/to/prefix/irc.server.net/#channel -> irc.server.net/#channel
+#CHAN="$(basename "$(dirname "$CPATH")")/$(basename "$CPATH")"
+#
+# /path/to/prefix/irc.server.net/#channel -> i.s.n/#channel
+#CHAN="$(basename "$(dirname "$CPATH")" | sed 's/\([^.]\)[^.]*\(\.\|$\)/\1\2/g')/$(basename "$CPATH")"
+#
+# /path/to/prefix/irc.server.net/#channel -> server/#channel
+CHAN="$(basename "$(dirname "$CPATH")")"
+while [ "${CHAN#*.}" != "$CHAN" -o "${CHAN%.*}" != "$CHAN" ]; do
+	CHAN="${CHAN%.*}"
+	CHAN="${CHAN#*.}"
+done
+CHAN="${CHAN:+$CHAN/}$(basename "$CPATH")"
+
 #exec urxvt -title "$CPATH" -e srw -l -p "$(basename "$CPATH")> " cw_color.sh -i "$OUT" -o "$IN" -n "$NICK"
 
 # Open a new tmux window for each channel, this one has been requested for a while, and now it works!
 TITLE="pcw"
 
 if ! tmux -L "$TITLE" list-sessions 2>/dev/null | grep -q "^$TITLE:"; then
-	tmux -L "$TITLE" new-session -d -s "$TITLE" -n "$(basename "$CPATH")" "srw -p \"$(basename "$CPATH")> \" cw_color.sh -i \"$OUT\" -o \"$IN\" -n \"$NICK\""
-elif ! tmux -L "$TITLE" list-windows -t "$TITLE" | grep -q " $(basename "$CPATH")[-*#!+~ ]"; then
-	tmux -L "$TITLE" new-window -d -t "$TITLE" -n "$(basename "$CPATH")" "srw -p \"$(basename "$CPATH")> \" cw_color.sh -i \"$OUT\" -o \"$IN\" -n \"$NICK\""
+	tmux -L "$TITLE" new-session -d -s "$TITLE" -n "$CHAN" "srw -p \"$CHAN> \" cw_color.sh -i \"$OUT\" -o \"$IN\" -n \"$NICK\""
+elif ! tmux -L "$TITLE" list-windows -t "$TITLE" | grep -q " $CHAN[-*#!+~ ]"; then
+	tmux -L "$TITLE" new-window -d -t "$TITLE" -n "$CHAN" "srw -p \"$CHAN> \" cw_color.sh -i \"$OUT\" -o \"$IN\" -n \"$NICK\""
 fi
 
 # The default command