Instantly share code, notes, and snippets.

Embed
What would you like to do?
A quick attempt to automate opening up a tmux session with Irssi and its nicklist.pl running.
#!/usr/bin/env bash
# This should work whether you are already in a TMUX session or not...
# Irssi directory is assumed to be in the user's home dir
if [ -z "$TMUX" ]
then
tmux new-session -d -s ircuser
tmux split-window -tircuser -h -l20
tmux send-keys -tircuser "tmux send-keys -t0 \"irssi\" C-m; \
tmux send-keys -t0 \"/set nicklist_height \$(stty size | cut -f1 -d' ' -)\" C-m; \
tmux send-keys -t0 \"/set nicklist_width \$(stty size | cut -f2 -d' ' -)\" C-m; \
tmux send-keys -t1 \"cat ~/.irssi/nicklistfifo\" C-m; \
tmux send-keys -t0 \"/nicklist fifo\" C-m; \
tmux select-pane -t0" C-m
tmux attach-session -t ircuser
else
tmux split-window -h -l20
tmux send-keys -t1 "tmux send-keys -t0 \"irssi\" C-m; \
tmux send-keys -t0 \"/set nicklist_height \$(stty size | cut -f1 -d' ' -)\" C-m; \
tmux send-keys -t0 \"/set nicklist_width \$(stty size | cut -f2 -d' ' -)\" C-m; \
tmux send-keys -t0 \"/nicklist fifo\" C-m; \
cat ~/.irssi/nicklistfifo" C-m
fi
@elithrar

This comment has been minimized.

Show comment
Hide comment
@elithrar

elithrar Aug 20, 2012

This looks great, however I'm having issues where the scripts shoots out sessions should be nested with care, unset $TMUX to force. and session not found: ircuser. Anything I should be modifying in the script or my tmux environment to get this working? (I'd like to avoid nesting sessions, for starters)

elithrar commented Aug 20, 2012

This looks great, however I'm having issues where the scripts shoots out sessions should be nested with care, unset $TMUX to force. and session not found: ircuser. Anything I should be modifying in the script or my tmux environment to get this working? (I'd like to avoid nesting sessions, for starters)

@megalithic

This comment has been minimized.

Show comment
Hide comment
@megalithic

megalithic Jan 21, 2013

@elithrar i'm getting the same issue. any updates on this?

megalithic commented Jan 21, 2013

@elithrar i'm getting the same issue. any updates on this?

@nathanharper

This comment has been minimized.

Show comment
Hide comment
@nathanharper

nathanharper Jan 26, 2013

@megalithic I talked to elithrar over email about this already a while ago... this script is something I whipped up to get it working for my personal needs, but you may need to tweak it to work for your purposes. I think the problem he was having was that he was running it from inside a tmux session, which this isn't designed to handle. I can't remember exactly what solution we came up with, but I think it looked something like...

!/bin/bash

if [ -z "$IRSSI_PATH" ]
then
echo "Environment variable IRSSI_PATH not set."
exit
fi

tmux split-window -h -l 20
tmux send-keys -t0 "irssi" C-m
tmux send-keys -t0 "/set nicklist_height $(stty size | cut -f1 -d' ' -)" C-m
tmux send-keys -t0 "/set nicklist_width $(stty size | cut -f2 -d' ' -)" C-m
tmux send-keys -t0 "/nicklist fifo" C-m
cat $IRSSI_PATH/nicklistfifo

Owner

nathanharper commented Jan 26, 2013

@megalithic I talked to elithrar over email about this already a while ago... this script is something I whipped up to get it working for my personal needs, but you may need to tweak it to work for your purposes. I think the problem he was having was that he was running it from inside a tmux session, which this isn't designed to handle. I can't remember exactly what solution we came up with, but I think it looked something like...

!/bin/bash

if [ -z "$IRSSI_PATH" ]
then
echo "Environment variable IRSSI_PATH not set."
exit
fi

tmux split-window -h -l 20
tmux send-keys -t0 "irssi" C-m
tmux send-keys -t0 "/set nicklist_height $(stty size | cut -f1 -d' ' -)" C-m
tmux send-keys -t0 "/set nicklist_width $(stty size | cut -f2 -d' ' -)" C-m
tmux send-keys -t0 "/nicklist fifo" C-m
cat $IRSSI_PATH/nicklistfifo

@nathanharper

This comment has been minimized.

Show comment
Hide comment
@nathanharper

nathanharper Jan 26, 2013

UPDATE: it seems like there's a lot of confusion about this, so I updated it to automatically detect if it's in a TMUX session and act accordingly.

Owner

nathanharper commented Jan 26, 2013

UPDATE: it seems like there's a lot of confusion about this, so I updated it to automatically detect if it's in a TMUX session and act accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment