summaryrefslogtreecommitdiff
path: root/bin/open-in-pane
blob: f5f07ab3a1e0fecce389d01eb633eba12ac3508a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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