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
git hash-object /relative/path/to/file/in/repo.ext | |
# SEE https://stackoverflow.com/questions/460297/git-finding-the-sha1-of-an-individual-file-in-the-index |
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
# list ALL | |
get-childitem Env: | |
# list one | |
echo $env:SomeVarName | |
# edit one | |
$env:SomeVarName = "value" | |
# https://www.itprotoday.com/powershell/powershell-one-liner-creating-and-modifying-environment-variable |
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
. c:\projects\WebUI-PowershellScripts\profile.ps1 | |
# Chocolatey profile | |
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" | |
if (Test-Path($ChocolateyProfile)) { | |
Import-Module "$ChocolateyProfile" | |
} | |
# list branches matching args, '.' for all else exception | |
function fbr { git br --all | ss $args } |
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
# https://blogs.technet.microsoft.com/heyscriptingguy/2016/06/27/use-windows-powershell-to-search-for-files/ | |
# | |
# -r : search recursively through subdirs | |
# -i "*pattern*" : include files matching pattern, can be used with exclude | |
# -i "*pattern*" : exclude files matching pattern, can be used with include | |
# -File : only find files, not dirs? | |
# -ErrorAction SilentlyContinue : ignore errors, generally, but includes specific minor errors such as files without permissions | |
# just find file via include |
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
function fsha { get-filehash -algorithm sha1 $args | select-object -ExpandProperty Hash } |
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-childitem -recurse -inc "*.csproj" | select-object -expandproperty FullName |
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-childitem -recurse -inc "*.csproj" | select-object -expandproperty Directory | select-object -ExpandProperty FullName | get-childitem -recurse -inc bin,obj | ?{$_.PSIsContainer} | select-object -ExpandProperty FullName | remove-item -recurse -force |
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
function IsDir { (get-item $args) -Is [System.IO.DirectoryInfo] } | |
function IsFile { (get-item $args) -Is [System.IO.FileInfo] } |
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
# Purge the reflog of anything farther back than 180 days, specifying --all, otherwise unreachable 'dangling' objects will be missed, | |
# optional --expire-unreachable flag could differ on when to expire unreachables | |
git reflog expire --all --expire=180.days.ago --expire-unreachable=180.days.ago --all | |
# other examples for expire | |
--expire=now | |
--expire=never | |
--expire="Jan 01 2019" | |
--expire="2019-01-01 00:00" |
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-childitem reference: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-childitem?view=powershell-6 | |
Get-ChildItem -recurse -attributes !directory+!compressed+!encrypted+!offline+!reparsepoint | Select-String -pattern "insert-pattern-here" | group path | select name |