Skip to content

Instantly share code, notes, and snippets.

@lgaggini
Last active October 25, 2017 13:46
Show Gist options
  • Save lgaggini/f0d0e119a0ab4410943dd227370f6fe6 to your computer and use it in GitHub Desktop.
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
#!/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! :)
@lgaggini
Copy link
Author

Open new page in same tab

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