Cmdr is a great tool. It’s nice to have a PowerShell terminal ready with just the press of a button. And as discussed in my previous post, I like to add more functionality to my PowerShell profile. This brought me to searching the web from within a terminal, just with a couple of keystrokes.
As usual when having an idea, somebody else already beat me to it… However, I still think these snippets could be of use to someone else.
The functions
function Reddit {
$Searchstring = $args
$URL = "https://www.reddit.com/search?q=" + $Searchstring
start $URL
}
function Technet {
$Searchstring = $args
$URL = "https://social.technet.microsoft.com/Search/en-us?query=" + $Searchstring
start $URL
}
function Google {
$Searchstring = $args
$URL = "https://www.google.com/#q=" + $Searchstring
start $URL
}
Save some of these in your profile.
The Good,
Nice. Now we can summon our command line, select our favorite website and go for a search.
Entering “Google this is a test” generates and runs this query: https://www.google.be/search?q=this%20is%20a%20test. Our trusty start function (old school cmd) automagically selects your default browser.
the Bad and the Ugly.
For each website it is necessary to find out the exact links to generate queries. Also, I really hope that these websites never change their way of searching.
Props to Monimoy Sanyal for his take on the searching.