Last active
May 1, 2020 11:01
-
-
Save higedice/01f32e3259cbfeda1d4ca3ba42dd523d to your computer and use it in GitHub Desktop.
A Module for PowerShell. This Adds chrome, google, bing and duckduckgo commands.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
This is a Module for PowerShell. | |
This Adds chrome, google, bing and duckduckgo commands. | |
Usage: | |
chrome <URLs> | |
OR | |
google <search words> | |
OR | |
bing <search words> | |
OR | |
duckduckgo <search words> | |
How to Setup: | |
copy to $env:PSModulePath. | |
https://docs.microsoft.com/en-us/powershell/scripting/developer/module/installing-a-powershell-module?view=powershell-7 | |
https://docs.microsoft.com/ja-jp/powershell/scripting/developer/module/installing-a-powershell-module?view=powershell-7 | |
by @higedice http://www.ohigedokoro.xyz/ | |
#> | |
function chrome() | |
{ | |
<# | |
.SYNOPSIS | |
Executes Google Chrome app. | |
.DESCRIPTION | |
Executes Google Chrome app and opens web sites. | |
.EXAMPLE | |
chrome | |
.EXAMPLE | |
chrome https://www.google.co.jp/ | |
.EXAMPLE | |
chrome https://www.google.co.jp/ http://www.yahoo.co.jp/ | |
.LINK | |
https://gist.github.com/higedice/01f32e3259cbfeda1d4ca3ba42dd523d | |
#> | |
$l = $args.Length | |
if ($l -eq 0) | |
{ | |
} | |
else | |
{ | |
Start-Process -FilePath C:\Program` Files` `(x86`)\Google\Chrome\Application\chrome.exe -ArgumentList $args | |
} | |
} | |
function google() | |
{ | |
<# | |
.SYNOPSIS | |
Executes Google Chrome app and searches with specified keywords. | |
.DESCRIPTION | |
Executes Google Chrome app and searches with specified keywords by Google. | |
.EXAMPLE | |
google powershell | |
.EXAMPLE | |
chrome windows powershell モジュール | |
.LINK | |
https://gist.github.com/higedice/01f32e3259cbfeda1d4ca3ba42dd523d | |
#> | |
$l = $args.Length | |
if ($l -eq 0) | |
{ | |
$url = 'https://www.google.co.jp/' | |
} | |
else | |
{ | |
$q = EncodeToUrl $args | |
$url = 'https://www.google.co.jp/search?q='+ $q | |
} | |
C:\Program` Files` `(x86`)\Google\Chrome\Application\chrome.exe $url | |
} | |
function bing() | |
{ | |
<# | |
.SYNOPSIS | |
Executes Google Chrome app and searches with specified keywords. | |
.DESCRIPTION | |
Executes Google Chrome app and searches with specified keywords by Bing. | |
.EXAMPLE | |
bing powershell | |
.EXAMPLE | |
bing windows powershell モジュール | |
.LINK | |
https://gist.github.com/higedice/01f32e3259cbfeda1d4ca3ba42dd523d | |
#> | |
$l = $args.Length | |
if ($l -eq 0) | |
{ | |
$url = 'https://www.bing.com/' | |
} | |
else | |
{ | |
$q = EncodeToUrl $args | |
$url = 'https://www.bing.com/search?q='+ $q | |
} | |
C:\Program` Files` `(x86`)\Google\Chrome\Application\chrome.exe $url | |
} | |
function duckduckgo() | |
{ | |
<# | |
.SYNOPSIS | |
Executes Google Chrome app and searches with specified keywords. | |
.DESCRIPTION | |
Executes Google Chrome app and searches with specified keywords by DuckDuckGo. | |
.EXAMPLE | |
duckduckgo powershell | |
.EXAMPLE | |
duckduckgo windows powershell モジュール | |
.LINK | |
https://gist.github.com/higedice/01f32e3259cbfeda1d4ca3ba42dd523d | |
#> | |
$l = $args.Length | |
if ($l -eq 0) | |
{ | |
$url = 'https://duckduckgo.com/' | |
} | |
else | |
{ | |
$q = EncodeToUrl $args | |
$url = 'https://duckduckgo.com/?q='+ $q | |
} | |
C:\Program` Files` `(x86`)\Google\Chrome\Application\chrome.exe $url | |
} | |
function EncodeToUrl() | |
{ | |
$l = $args.Length | |
if ($l -eq 0) | |
{ | |
return '' | |
} | |
$q = $args[0] | |
for ($i = 1; $i -lt $l; $i++) | |
{ | |
$q += ' ' | |
$q += $args[$i] | |
} | |
$urlenc = [System.Uri]::UnescapeDataString($q) | |
return $urlenc | |
} | |
Export-ModuleMember -Function chrome, google, bing, duckduckgo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment