diff options
Diffstat (limited to 'bin/open-in-pane')
-rwxr-xr-x | bin/open-in-pane | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/bin/open-in-pane b/bin/open-in-pane new file mode 100755 index 0000000..f5f07ab --- /dev/null +++ b/bin/open-in-pane @@ -0,0 +1,23 @@ +#!/bin/sh + +W3M='/usr/bin/w3m' + +# If the window has only one pane, create one by splitting. +pane_count=`tmux list-panes -F '#{line}' | wc -l` +if [ $pane_count -lt 2 ]; then + tmux split-window -h +fi + +# Start my reader if it ain't running already, and send it the URL +# to +# open. + +w3m_process_count=`ps auxw | grep "$W3M" | grep -cv grep` + +if [ $w3m_process_count = '1' ];then + tmux send-keys -t 2 "TU" "C-u" "$1" enter + tmux select-pane -t 2 +else + tmux send-keys -t 2 "$W3M \"$1\"" enter + tmux select-pane -t 2 +fi |