#!/bin/zsh # clip2goog - google for selected text selurl() { setopt localoptions extendedglob sel=$(xclip -out) LC_ALL=C input=( ${(s::)sel} ) # work on bytes print ${(j::)input/(#b)([^A-Za-z0-9_.!~*\'\(\)-])/%$(([##16]#match))} } firefox "http://google.com/search?q=$(selurl)"