summaryrefslogtreecommitdiffstats
path: root/tmux-url
diff options
context:
space:
mode:
authorRaghavendra D Prabhu <raghu.prabhu13@gmail.com>2011-03-13 00:24:47 +0530
committerRaghavendra D Prabhu <raghu.prabhu13@gmail.com>2011-03-13 00:24:47 +0530
commit5ec75ea891c9b44cdd2d7a3e0c29b4d08dff2b2a (patch)
treedeabb15393558ab3a1a629fc0782d8b0c3124c48 /tmux-url
downloadScripts-5ec75ea891c9b44cdd2d7a3e0c29b4d08dff2b2a.tar.gz
Scripts-5ec75ea891c9b44cdd2d7a3e0c29b4d08dff2b2a.tar.bz2
Scripts-5ec75ea891c9b44cdd2d7a3e0c29b4d08dff2b2a.zip
Initial scripts update
Diffstat (limited to 'tmux-url')
-rwxr-xr-xtmux-url28
1 files changed, 28 insertions, 0 deletions
diff --git a/tmux-url b/tmux-url
new file mode 100755
index 0000000..0dec877
--- /dev/null
+++ b/tmux-url
@@ -0,0 +1,28 @@
+#!/bin/zsh
+tmux capture-pane -t uake
+tmux save-buffer /tmp/mux-buffer
+#LAST_URL=$(/bin/grep -i -P '(https?://|www.)[0-9A-Z\.\/\-\_~\?=]*' 2>/dev/null /tmp/mux-buffer | tac | $=DMENU)
+
+
+typeset -A dispatcher
+dispatcher=(
+';' '/bin/true'
+':' 'ubrowser'
+)
+
+while :;do
+ LAST_URL=${$(/bin/grep -i -E 'http[s]?:.*' /tmp/mux-buffer | tac | $=DMENU ):?Empty input}
+ echo "$LAST_URL" >>| ~/.current
+ method=$dispatcher[$LAST_URL[-1]]
+
+ if [[ -n $method ]];then
+ LAST_URL=$(perl -MRegexp::Common=URI -lne 'm{$RE{URI}{HTTP}{-scheme => qr/https?/}{-keep}} && print $1' <<< ${LAST_URL[1,-2]})
+ $method $LAST_URL
+ break
+ else
+ LAST_URL=$(perl -MRegexp::Common=URI -lne 'm{$RE{URI}{HTTP}{-scheme => qr/https?/}{-keep}} && print $1' <<< ${LAST_URL})
+ browser $LAST_URL
+ fi
+done
+xclip -i <<< $LAST_URL
+notify-send "Turl" "$LAST_URL handled"