-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from bjompen/WriteSecretStatus
Added Write-SecretStatus and guide to run it in Posh-git
- Loading branch information
Showing
5 changed files
with
107 additions
and
28 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
external help file: PSSecretScanner-help.xml | ||
Module Name: PSSecretScanner | ||
online version: | ||
schema: 2.0.0 | ||
--- | ||
|
||
# Write-SecretStatus | ||
|
||
## SYNOPSIS | ||
|
||
This command is created to get a quick and easy way of having secrets found shown in your prompt function. | ||
You can use it side by side with [posh-git](https://github.com/dahlbyk/posh-git), or as a stand alone function. | ||
|
||
## SYNTAX | ||
|
||
```PowerShell | ||
Write-SecretStatus | ||
``` | ||
|
||
## DESCRIPTION | ||
|
||
This command is created to get a quick and easy way of having secrets found shown in your prompt function. | ||
You can use it side by side with [posh-git](https://github.com/dahlbyk/posh-git), or as a stand alone function. | ||
|
||
--- | ||
|
||
To add output to your default prompt, create or edit your prompt function and add `Write-SecretStatus` where you want it to show. | ||
|
||
--- | ||
|
||
To add this to your posh-git prompt add the following to your `$PROFILE` script **after the `Import-Module posh-git` statement!** | ||
|
||
```PowerShell | ||
$GitPromptSettings.DefaultPromptBeforeSuffix.Text = ' $(Write-SecretStatus)' | ||
# You may also change the default white console output colour by running | ||
$GitPromptSettings.DefaultPromptBeforeSuffix.ForegroundColor = 'LightBlue' # or any other colour of choice.. | ||
``` | ||
|
||
--- | ||
|
||
You _may_ also add this to your oh-my-posh thing, but I don't use it and have no idea how that works. | ||
|
||
## EXAMPLES | ||
|
||
## PARAMETERS | ||
|
||
## INPUTS | ||
|
||
### None | ||
|
||
## OUTPUTS | ||
|
||
### System.Object | ||
|
||
## NOTES | ||
|
||
## RELATED LINKS |
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 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
function Write-SecretStatus { | ||
param () | ||
|
||
try { | ||
[array]$IsGit = (git status *>&1).ToString() | ||
if ( $IsGit[0] -eq 'fatal: not a git repository (or any of the parent directories): .git' ) { | ||
break | ||
} | ||
else { | ||
$SecretsCount = (Find-Secret -Recursive:$false -OutputPreference Object).Count | ||
Write-Output "[$SecretsCount]" | ||
} | ||
} | ||
catch {} | ||
} |