Last active
March 26, 2021 10:44
-
-
Save MarioBinder/18c46c51ff647674aca5eaee0bf26626 to your computer and use it in GitHub Desktop.
some cool powershell commands to make the work easier
This file contains hidden or 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
| #################################################################################### | |
| # get the list of own aliases | |
| # save under C:\Windows\System32\WindowsPowerShell\v1.0 | |
| function listMyAliases(){ | |
| echo "###############################################################################################" | |
| echo " outlook #start Outlook" | |
| echo " g <searchterm> #lmgtfy :)" | |
| echo " so #search at stackoverflow with optional tags (blank separated)" | |
| echo " n #download and init nuget" | |
| echo " gitignore #get and save the gitignore file from API" | |
| echo " gist #open my gist" | |
| echo " remote #open mRemoteNG" | |
| echo " ssms #open SQL Management Studio" | |
| echo " slack #open Slack" | |
| echo " new #new instance of powershell" | |
| echo " checkout #switch to branch develop for all subfolders" | |
| echo " merge #merge all from develop to beta and overwrite last beta changes" | |
| echo " pull #pull branch from arguments" | |
| echo " listfolders #listfolders list all subfolders" | |
| echo "-----------------------------------------------------------------------------------------------" | |
| echo " type f for semas/Front-End & b for semas/Back-End" | |
| echo " type ff find in files" | |
| echo " change this script with subl `$PROFILE.AllUsersAllHosts` or subl `$PROFILE` " | |
| get-date | |
| echo "###############################################################################################" | |
| } | |
| set-alias aliases listMyAliases | |
| #################################################################################### | |
| #################################################################################### | |
| #open outlook | |
| function openOutlook{ | |
| $p = get-process outlook -ErrorAction ignore | |
| if($p){ | |
| Stop-Process $p | |
| } | |
| Start-Process -FilePath "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Outlook.lnk" | |
| } | |
| set-alias outlook openOutlook | |
| #################################################################################### | |
| #################################################################################### | |
| #open my gist | |
| function openGist{ | |
| start https://gist.github.com/MarioBinder | |
| } | |
| set-alias gist openGist | |
| #################################################################################### | |
| #################################################################################### | |
| #lmgtfy :) | |
| function googleSearch{ | |
| start www.google.com/search?q=$args | |
| } | |
| set-alias g googleSearch | |
| #################################################################################### | |
| #download and init the alias for nuget | |
| function initNuget{ | |
| $sourceNugetExe = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" | |
| $targetNugetExe = "$rootPath\nuget.exe" | |
| Invoke-WebRequest $sourceNugetExe -OutFile $targetNugetExe | |
| Set-Alias nuget $targetNugetExe -Scope Global -Verbose | |
| } | |
| set-alias n initNuget | |
| #################################################################################### | |
| #get the gitignore file from API | |
| function getGitignoreFile(){ | |
| wget https://www.gitignore.io/api/csharp -OutFile .gitignore | |
| } | |
| set-alias gitignore getGitignoreFile | |
| #################################################################################### | |
| # search at stackoverflow with optional tags (blank separated) | |
| function stackoverflowSearch{ | |
| param ( | |
| [string]$arguments = $(Read-Host "type your search term"), | |
| [string]$taginput = $(Read-Host "type your tags" ) | |
| ) | |
| IF ([string]::IsNullOrWhitespace($taginput)){ | |
| $tag = "" | |
| } else { | |
| foreach($t in $taginput.split(' ')){ | |
| $tag += "[$t]" | |
| } | |
| echo "search $arguments $tag on stackoverflow" | |
| } | |
| $query = "$arguments $tag" | |
| start https://stackoverflow.com/search?q=$query | |
| } | |
| set-alias so stackoverflowSearch | |
| #################################################################################### | |
| function sqlMgmntStudio{ | |
| start "C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\IDE\Ssms.exe" | |
| } | |
| set-alias ssms sqlMgmntStudio | |
| #################################################################################### | |
| function remoteStudio{ | |
| start "C:\Program Files (x86)\mRemoteNG\mRemoteNG.exe" | |
| } | |
| set-alias remote remoteStudio | |
| #################################################################################### | |
| function openSlack{ | |
| start "C:\Program Files\Slack\Slack.exe" | |
| } | |
| set-alias slack openSlack | |
| #################################################################################### | |
| function newInstancOfPowershell{ | |
| invoke-expression 'cmd /c start powershell' | |
| } | |
| set-alias new newInstancOfPowershell | |
| #################################################################################### | |
| function checkout{ | |
| Get-ChildItem -Recurse -Directory -Hidden -Filter .git | ForEach-Object { & echo $_.FullName; | |
| git --git-dir="$($_.FullName)" --work-tree="$(Split-Path $_.FullName -Parent)" checkout develop; | |
| git --git-dir="$($_.FullName)" --work-tree="$(Split-Path $_.FullName -Parent)" branch; | |
| echo "###########################################" | |
| } | |
| } | |
| function merge { | |
| param ( | |
| [string]$env = $(Read-Host "type your target environment (beta or live)") | |
| ) | |
| Get-ChildItem -Recurse -Directory -Hidden -Filter .git | ForEach-Object { & echo $_.FullName; | |
| git --git-dir="$($_.FullName)" --work-tree="$(Split-Path $_.FullName -Parent)" pull origin develop; | |
| git --git-dir="$($_.FullName)" --work-tree="$(Split-Path $_.FullName -Parent)" branch -D $env; | |
| git --git-dir="$($_.FullName)" --work-tree="$(Split-Path $_.FullName -Parent)" push origin --delete $env; | |
| git --git-dir="$($_.FullName)" --work-tree="$(Split-Path $_.FullName -Parent)" branch $env; | |
| git --git-dir="$($_.FullName)" --work-tree="$(Split-Path $_.FullName -Parent)" checkout $env; | |
| git --git-dir="$($_.FullName)" --work-tree="$(Split-Path $_.FullName -Parent)" merge -s ours develop; | |
| git --git-dir="$($_.FullName)" --work-tree="$(Split-Path $_.FullName -Parent)" push origin $env --force; | |
| git --git-dir="$($_.FullName)" --work-tree="$(Split-Path $_.FullName -Parent)" checkout develop; | |
| echo "###########################################" | |
| } | |
| } | |
| #################################################################################### | |
| function pull { | |
| param ( | |
| [string]$env = $(Read-Host "type your target environment (develop, beta)") | |
| ) | |
| Get-ChildItem -Recurse -Directory -Hidden -Filter .git | | |
| ForEach-Object { & echo $_.FullName; | |
| git --git-dir="$($_.FullName)" --work-tree="$(Split-Path $_.FullName -Parent)" remote remove daimler; | |
| git --git-dir="$($_.FullName)" --work-tree="$(Split-Path $_.FullName -Parent)" checkout $env; | |
| git --git-dir="$($_.FullName)" --work-tree="$(Split-Path $_.FullName -Parent)" pull origin $env; | |
| git --git-dir="$($_.FullName)" --work-tree="$(Split-Path $_.FullName -Parent)" branch; | |
| echo "###########################################" | |
| } | |
| } | |
| #################################################################################### | |
| function listfolders{ | |
| Get-ChildItem -Recurse -Directory -Hidden -Filter .git | | |
| ForEach-Object { & echo $($_.FullName); | |
| } | |
| } | |
| #################################################################################### | |
| function dev { | |
| cd "D:\Dev" | |
| } | |
| function spielwiese { | |
| cd "D:\Dev\Spielwiese" | |
| } | |
| function f { | |
| cd "D:\Dev\SEMAS\Front-End" | |
| } | |
| function b { | |
| cd "D:\Dev\SEMAS\Back-End" | |
| } | |
| function ff{ | |
| param ( | |
| [string]$term = $(Read-Host "type your searchterm"), | |
| [string]$extension = $(Read-Host "type your extension like '*.cs,*.json'") | |
| ) | |
| [string[]]$includeArray = $extension -split "," | |
| Get-ChildItem -recurse -Include $includeArray | Select-String $term | select Filename,LineNUmber, Line | Ft -autosize -wrap | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment