=== modified file 'tmux-buffer-urls' --- tmux-buffer-urls 2012-07-29 19:11:21 +0000 +++ tmux-buffer-urls 2012-07-29 14:38:49 +0000 @@ -22,10 +22,8 @@ exit 0 fi -# the regular expression :-) -URL_RE='(http|ftp|git|bzr)s?(\+ssh)?://[].:[[:alnum:]-]+/[-[:alnum:]/_.?&#]+[-[:alnum:]/_?&#]' +#set -x -# check if command was passed if [[ $# == 0 ]]; then cmd=( tmux load-buffer - ) A=() @@ -33,30 +31,16 @@ cmd=( "$@" ) fi -# check if prompt text was passed if [[ $#P == 2 ]]; then sl_args=( -p ${P[2]} ) else sl_args=( -p 'open url' ) fi -# grep for urls in the buffer, read them into list and reverse them -urls=( ${(fOa)"$( tmux save-buffer - | egrep -o $URL_RE )"} ) - -# print error if none was found -if [[ -z "$urls" ]]; then - echo "no URLs found!" - read -t 1 -q # wait for any keypress, up to 1 sec - exit -fi - -# display menu and print result -print -rl -- $urls | slmenu $sl_args -l $(($LINES-2)) | read url - -# exit on canceled +URL_RE='(http|ftp)s?://[].:[[:alnum:]-]+/[-[:alnum:]/_.?&#]+[-[:alnum:]/_?&#]' + +tmux save-buffer - | egrep -o $URL_RE | slmenu $sl_args -l $(($LINES-2)) | read url [[ -z "$url" ]] && exit - -# execute command depending on --append flag if (($#A)); then $cmd $url else