Skip to content

Instantly share code, notes, and snippets.

@alvinfrancis
Created August 1, 2013 10:44
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alvinfrancis/6130298 to your computer and use it in GitHub Desktop.
Save alvinfrancis/6130298 to your computer and use it in GitHub Desktop.
newsbeuter open browser script in tmux
#!/bin/sh
shellbrowser='elinks'
tmux_current_window=`tmux display-message -p "#W"`
tmux_current_pane=`tmux display-message -p "#P"`
# Check if in the right tmux window
if [ $tmux_current_window != 'news' ];then
elinks $1
exit 0
fi
# 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.
browser_process_count=`ps auxw | grep "$shellbrowser" | grep -cv grep`
if [ $browser_process_count -gt 0 ];then
tmux send-keys -t 1 "t" "$1"
tmux send -t 1 Enter
tmux select-pane -t $tmux_current_pane
else
tmux send-keys -t 1 "$shellbrowser \"$1\""
tmux send -t 1 Enter
tmux select-pane -t $tmux_current_pane
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment