Skip to content

Instantly share code, notes, and snippets.

@JasonJCross
Last active September 20, 2023 16:35
{
"blocks": [
{
"type": "prompt",
"alignment": "left",
"segments": [
{
"type": "path",
"style": "diamond",
"foreground": "#ffffff",
"background": "#880000",
"leading_diamond": "",
"trailing_diamond": "",
"properties": {
"prefix": " ",
"home_icon": "ﭾ ",
"folder_separator_icon": "\\",
"style": "agnoster_short"
}
},
{
"type": "git",
"style": "powerline",
"powerline_symbol": "",
"foreground": "#FFFFFF",
"background": "#0000DD",
"background_templates": [
"{{ if or (.Working.Changed) (.Staging.Changed) }}#FF9248{{ end }}",
"{{ if and (gt .Ahead 0) (gt .Behind 0) }}#ff4500{{ end }}",
"{{ if gt .Ahead 0 }}#B388FF{{ end }}",
"{{ if gt .Behind 0 }}#B388FF{{ end }}"
],
"properties": {
"fetch_status": true,
"fetch_stash_count": true,
"fetch_upstream_icon": true,
"branch_max_length": 25,
"template": "{{ .UpstreamIcon }}{{ .HEAD }}{{ .BranchStatus }}{{ if .Working.Changed }} \uF044 {{ .Working.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Staging.Changed }} \uF046 {{ .Staging.String }}{{ end }}{{ if gt .StashCount 0 }} \uF692 {{ .StashCount }}{{ end }}"
}
},
{
"type": "dotnet",
"style": "powerline",
"powerline_symbol": "",
"leading_diamond" : "",
"trailing_diamond": "",
"foreground": "#ffffff",
"background": "#003366",
"properties": {
"prefix": "  "
}
},
{
"type": "root",
"style": "powerline",
"powerline_symbol": "",
"leading_diamond" : "",
"trailing_diamond": "",
"foreground": "#111111",
"background": "#ffff66",
"properties": {
"root_icon": ""
}
},
{
"type": "executiontime",
"style": "powerline",
"powerline_symbol": "",
"leading_diamond" : "",
"trailing_diamond": "",
"foreground": "#ffffff",
"background": "#555555",
"properties": {
"threshold": 500,
"style": "austin",
"prefix": "ﮮ",
"postfix": ""
}
}
]
}
],
"final_space": true,
"console_title": true,
"console_title_style": "template",
"console_title_template": "{{ .Shell }} in {{ .Folder }}"
}
Write-Host "Split-Path <== Shows PATH per line"
function Split-Path { $env:path -split ";" }
Write-Host "Sync-My(repoPath, jasonjcrossPath) <== pull's the latest from the repo"
function Sync-My ($script:repoPath, $script:jasonjcrossPath = "C:\GitRepositories\GitHub\jasonjcross\") {
$script:currPath = Get-Location
Write-Host "Syncing $jasonjcrossPath$repoPath"
try {
Set-Location -Path "$jasonjcrossPath$repoPath"
git pull
}
catch {
Write-Host "Syncing $jasonjcrossPath$repoPath failed:" $_.Exception.Message
}
Set-Location -Path $currPath
}
Write-Host "syncall <== pull's Dashboard and DevNotes"
function syncall {
Sync-My("MyDashboard")
Sync-My("DevNotes")
}
Write-Host "Get-Time(startTime) <== Format: 'MM/DD/YYYY HH:MM:SS'"
function Get-Time($script:startTime) {
$now = Get-Date
$getTime = New-TimeSpan -Start $startTime -End $now
return $getTime
}
# starting variables
$script:defaultPath = Get-Location
Import-Module -Name Terminal-Icons
Import-Module z
Import-Module posh-git
Import-Module "C:\Users\jcross\.shell\MyHelperModule.psm1"
try {
oh-my-posh --init --shell pwsh --config C:\jsonSettings\jcross.omp.json | Invoke-Expression
}
catch {
Write-Host "oh-my-posh Invoke failed" $_.Exception.Message
}
# Autocomplete
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
# dotnet autocomplete
try {
Register-ArgumentCompleter -Native -CommandName dotnet -ScriptBlock {
param($commandName, $wordToComplete, $cursorPosition)
dotnet complete --position $cursorPosition "$wordToComplete" | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}
}
catch {
Write-Host "dotnet autocoplete failed" $_.Exception.Message
}
Set-Location -Path $defaultPath
# starting variables
$script:defaultPath = Get-Location
Import-Module -Name Terminal-Icons
Import-Module z
Import-Module posh-git
Import-Module posh-docker
Import-Module AWS.Tools.Common
Import-Module "C:\Users\jcross\.shell\MyHelperModule.psm1"
function Get-Time($script:startTime) {
$now = Get-Date
$getTime = New-TimeSpan -Start $startTime -End $now
return $getTime
}
try {
oh-my-posh --init --shell pwsh --config C:\jsonSettings\jcross.omp.json | Invoke-Expression
}
catch {
Write-Host "oh-my-posh Invoke failed" $_.Exception.Message
}
# Autocomplete
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
# dotnet autocomplete
try {
Register-ArgumentCompleter -Native -CommandName dotnet -ScriptBlock {
param($commandName, $wordToComplete, $cursorPosition)
dotnet complete --position $cursorPosition "$wordToComplete" | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}
}
catch {
Write-Host "dotnet autocoplete failed" $_.Exception.Message
}
# # kubctl
# try {
# Register-ArgumentCompleter -Native -CommandName kubectl -ScriptBlock {
# param($commandName, $wordToComplete, $cursorPosition)
# kubectl completion powershell | Invoke-Expression
# kubectl completion powershell | Out-String | Invoke-Expression
# }
# }
# catch {
# Write-Host "kubectl autocomplete failed" $_.Exception.Message
# }
# # aws autocomplete
# try {
# Register-ArgumentCompleter -Native -CommandName aws -ScriptBlock {
# param($commandName, $wordToComplete, $cursorPosition)
# aws --completion-powershell | Out-String | Invoke-Expression
# }
# }
# catch {
# Write-Host "aws autocomplete failed" $_.Exception.Message
# }
Set-Location -Path $defaultPath
@JasonJCross
Copy link
Author

JasonJCross commented Jun 1, 2022

Here's helpful info for the profile.ps1

Setting up Powershell

Scott Hanselman :

Video: How to make the ultimate Terminal Prompt on Windows 11 - This video is LONG and WORDY and DETAILED

Blog: https://www.hanselman.com/blog/my-ultimate-powershell-prompt-with-oh-my-posh-and-the-windows-terminal

Update Powershell config code $PROFILE
Learning Powershell https://github.com/PowerShell/PowerShell/tree/master/docs/learning-powershell

Baseline Powershell

Setting up Windows Terminal

(Store) Install Link (Github Releases) https://github.com/microsoft/terminal/releases

Setting up Powershell

Windows 10 Windows 11
Powershell 7 (link) Windows Terminal (Store) Then install via Store

On Terminal

  • Set Powershell 7 as default

  • Use Settings file, move to top

Run as Administrator:

install Chocolatey ==> See next page (Link)

Chocolatey installs

Name Command Link
Nerd Font choco install cascadia-code-nerd-font https://community.chocolatey.org/packages/cascadia-code-nerd-font

Winget Installs

Name Command
OhMyPosh winget install JanDeDobbeleer.OhMyPosh -s winget

Install modules

Name Command
z Install-Module -Scope CurrentUser z
posh-docker Install-Module -Scope CurrentUser posh-docker
posh-git Install-Module -Scope CurrentUser posh-git
Terminal-Icons Install-Module -Scope CurrentUser Terminal-Icons

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment