Skip to content

Instantly share code, notes, and snippets.

@katoozi
Created April 13, 2019 06:36
Show Gist options
  • Save katoozi/e620c25e8772df8b7c0e69afd06bc5a9 to your computer and use it in GitHub Desktop.
Save katoozi/e620c25e8772df8b7c0e69afd06bc5a9 to your computer and use it in GitHub Desktop.
my google search script for dmenu
#!/bin/sh
browser=${BROWSER:-google-chrome-stable}
pgrep -x dmenu && exit
choice=$(echo "" | dmenu -i -p "Search Google:") || exit 1
if [ "$choice" = "" ]; then
$browser "https://google.com"
else
if echo "$choice" | grep "^(http:\/\/|https:\/\/)?[a-zA-Z0-9]+\.[a-zA-Z]+(/)?.*$"; then
$browser "$choice"
else
$browser "https://google.com/search?q=$choice"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment