summaryrefslogtreecommitdiff
path: root/open-in-pane
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2023-06-15 15:58:59 -0500
committerluxagraf <sng@luxagraf.net>2023-06-15 15:58:59 -0500
commitab987e10f154f5536bb8fd936ae0966e909fa969 (patch)
tree9de5076f38b71ececb1bc94f8d9d19170898d603 /open-in-pane
added all my scriptssynced/master
Diffstat (limited to 'open-in-pane')
-rwxr-xr-xopen-in-pane23
1 files changed, 23 insertions, 0 deletions
diff --git a/open-in-pane b/open-in-pane
new file mode 100755
index 0000000..f5f07ab
--- /dev/null
+++ b/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