Skip to content

Instantly share code, notes, and snippets.

@JasonJCross
Last active September 20, 2023 16:35

Revisions

  1. JasonJCross revised this gist Sep 20, 2023. 3 changed files with 84 additions and 15 deletions.
    32 changes: 32 additions & 0 deletions MyHelperModule.psm1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    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
    }
    32 changes: 24 additions & 8 deletions Profile.ps1
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,32 @@
    oh-my-posh --init --shell pwsh --config C:\jsonSettings\Prompt\jcross.omp.json | Invoke-Expression
    # starting variables
    $script:defaultPath = Get-Location

    Import-Module -Name Terminal-Icons
    Import-Module z
    Import-Module posh-git
    Import-Module posh-docker
    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
    Register-ArgumentCompleter -Native -CommandName dotnet -ScriptBlock {
    param($commandName, $wordToComplete, $cursorPosition)
    dotnet complete --position $cursorPosition "$wordToComplete" | ForEach-Object {
    [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
    }
    }
    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
    35 changes: 28 additions & 7 deletions Updated (Complex) Profile.ps1
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,14 @@
    # starting variables
    $start = Get-Date
    $defaultPath = Get-Location
    $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($startTime) {
    function Get-Time($script:startTime) {
    $now = Get-Date
    $getTime = New-TimeSpan -Start $startTime -End $now
    return $getTime
    @@ -18,10 +18,10 @@ try {
    oh-my-posh --init --shell pwsh --config C:\jsonSettings\jcross.omp.json | Invoke-Expression
    }
    catch {
    Write-Host "oh-my-posh failed" $_.Exception.Message
    Write-Host "oh-my-posh Invoke failed" $_.Exception.Message
    }

    # dotnet autocomplete
    # Autocomplete
    Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete

    # dotnet autocomplete
    @@ -37,6 +37,27 @@ catch {
    Write-Host "dotnet autocoplete failed" $_.Exception.Message
    }

    # Write-Host "All modules loaded in $(Get-Time($start))"
    # # 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
    Set-Location -Path $defaultPath
  2. JasonJCross revised this gist Apr 4, 2023. 1 changed file with 42 additions and 0 deletions.
    42 changes: 42 additions & 0 deletions Updated (Complex) Profile.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    # starting variables
    $start = Get-Date
    $defaultPath = Get-Location

    Import-Module -Name Terminal-Icons
    Import-Module z
    Import-Module posh-git
    Import-Module posh-docker
    Import-Module AWS.Tools.Common

    function Get-Time($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 failed" $_.Exception.Message
    }

    # dotnet 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
    }

    # Write-Host "All modules loaded in $(Get-Time($start))"

    Set-Location -Path $defaultPath
  3. JasonJCross revised this gist Apr 16, 2022. 1 changed file with 13 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions Profile.ps1
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,16 @@
    oh-my-posh --init --shell pwsh --config C:\jsonSettings\Prompt\jcross.omp.json | Invoke-Expression

    Import-Module -Name Terminal-Icons
    Import-Module z
    Import-Module posh-git
    Import-Module posh-docker

    Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete

    # dotnet autocomplete
    Register-ArgumentCompleter -Native -CommandName dotnet -ScriptBlock {
    param($commandName, $wordToComplete, $cursorPosition)
    dotnet complete --position $cursorPosition "$wordToComplete" | ForEach-Object {
    [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
    }
    }
  4. JasonJCross created this gist Jan 6, 2022.
    3 changes: 3 additions & 0 deletions Profile.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    oh-my-posh --init --shell pwsh --config C:\jsonSettings\Prompt\jcross.omp.json | Invoke-Expression

    Import-Module -Name Terminal-Icons
    87 changes: 87 additions & 0 deletions jcross.omp.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,87 @@
    {
    "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 }}"
    }