Last active
October 25, 2017 13:46
-
-
Save lgaggini/f0d0e119a0ab4410943dd227370f6fe6 to your computer and use it in GitHub Desktop.
wrapper to use w3m as pager / browser opening a right panel in tmux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# https://cyprio.net/wtf/2012-08-13-using-newsbeuter-with-tmux-and-w3m-to-read-news.html | |
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 1 "U" "C-u" "$1" | |
tmux send-keys -t 1 Enter | |
tmux select-pane -t 1 | |
else | |
tmux send-keys -t 1 "$W3M '$1'" | |
tmux send-keys -t 1 Enter | |
tmux select-pane -t 1 | |
fi | |
# Done! :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Open new page in same tab