pcw / pcw_win.sh

#!/bin/sh
#
# This is the script run by pcw when you join a new channel or a new message
# comes in.  CPATH is the path to the directory, OUT and IN are the out file
# in fifo respectively, and NICK is the nick passed to pcw or the empty string
# if no nick was passed in.
#
# These are just a few examples, and I trust that you can figure out how to do
# other stuff.  Of note, pcw decides when to run the command based on the
# status of the last command it ran for a given 'path'.  If the child is still
# alive it will not run the command again (helpful for open terminals).  This
# does mean however that some ideas won't work out of the box, for instance
# using urxvtc or screen.  You should be able to keep track of some stuff here
# in order to decide whether or not to launch a new window, have fun!
#
# NOTE: if you use cw_color.sh make sure you have a 256 color terminal, or edit
#       cw_color.sh accordingly

CPATH="$1"
OUT="$2"
IN="$3"
NICK="$4"


#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!
# make sure to add 'set -g default-terminal "screen-256color"' to your ~/.tmux.conf
# if you don't want color, you can change the cw_color.sh part to cw etc. like the other examples
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\""
fi

# The default command
# exec urxvt -title "$CPATH" -e srw -p "$(basename "$CPATH")> " cw "$OUT" "$IN"

# If for some reason you really don't want to use srw...
# exec urxvt -title "$CPATH" -e cw "$OUT" "$IN"

# For colors, bell on nick, better line wrapping etc. (this is what i use)
# exec urxvt -title "$CPATH" -e srw -p "$(basename "$CPATH")> " cw_color.sh -i "$OUT" -o "$IN" -n "$NICK"

# And to add reflowing text when the window changes size.  Although beware, in
# this case reflow means reprint the whole file at the new width.  This can be
# slow, but if you use chat.sh it gzips the old out files everytime you startup
# again.  (This is the one I use, along with chat.sh)
# exec urxvt -title "$CPATH" -e srw -w -p "$(basename "$CPATH")> " cw_color.sh -i "$OUT" -o "$IN" -n "$NICK"
 
# If you want to use tabbed (http://tools.suckless.org/tabbed) so each new
# channel has it's own tab.  Start tabbed with -d then export the window id as
# pcw_window_id (or whatever you want...) then start pcw.  It should be fairly
# simple to do that in a script, use cw_color.sh if you want the colors etc.
# exec urxvt -embed "$pcw_window_id" -title "$CPATH", -e srw -p "$(basename "$CPATH")> " cw "$OUT" "$IN"

# If you want notifications in dzen, then click on a specific message to spawn
# a terminal for that channel.
# NOTE: alpha quality at best, more of a proof of concept, but have fun with it
# pcw_notify.sh "$CPATH" "$NICK"
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.