J2897

PowerShell Profile for Windows PowerShell 5.1

Apr 1st, 2026 (edited)
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # -------------------------------------------------------------------
  2. # PowerShell Profile for Windows PowerShell 5.1
  3. # -------------------------------------------------------------------
  4. # This profile customizes the PowerShell experience with best practices:
  5. # - Leaves the current directory unchanged in normal sessions
  6. # - Redirects away from C:\Windows\System32 to the user's home directory
  7. # - Provides a clean, colored prompt indicating elevation status
  8. # - Includes useful functions with proper help and parameter validation
  9. # - Loads Chocolatey tab completion if available
  10. # -------------------------------------------------------------------
  11.  
  12. # If PowerShell starts in C:\Windows\System32, move to the user's home directory
  13. $currentPath = (Get-Location).ProviderPath
  14. $system32Path = (Join-Path $env:WINDIR 'System32')
  15.  
  16. if ($currentPath -ieq $system32Path) {
  17.     Set-Location -Path $HOME
  18. }
  19.  
  20. # Detect administrative privileges (calculated once for efficiency)
  21. $IsAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(`
  22.     [Security.Principal.WindowsBuiltInRole]::Administrator)
  23.  
  24. # Custom prompt function
  25. function Prompt {
  26.     # Set prompt prefix color: Red for admin, Green for normal user
  27.     $color = if ($IsAdmin) { 'Red' } else { 'Green' }
  28.  
  29.     Write-Host 'PS' -NoNewline -ForegroundColor $color
  30.     Write-Host " $((Get-Location).Path)" -NoNewline -ForegroundColor Cyan
  31.     Write-Host '>' -NoNewline -ForegroundColor $color
  32.  
  33.     # Important: Return a string (with a trailing space) to complete the prompt
  34.     return ' '
  35. }
  36.  
  37. # -------------------------------------------------------------------
  38. # Function: Get-FolderSize
  39. # -------------------------------------------------------------------
  40. <#
  41. .SYNOPSIS
  42.     Calculates the total size of files in a directory and its subdirectories.
  43.  
  44. .DESCRIPTION
  45.     Recursively enumerates files under the specified path, sums their sizes,
  46.     and returns a custom object with file count, total size in bytes, and
  47.     formatted size in MB/GB (auto-scaled for readability).
  48.  
  49. .PARAMETER Path
  50.     The directory path to measure. Defaults to the current location.
  51.  
  52. .EXAMPLE
  53.     Get-FolderSize -Path "C:\Users\$env:USERNAME\Documents"
  54.  
  55. .EXAMPLE
  56.     Get-FolderSize | Format-Table
  57. #>
  58. function Get-FolderSize {
  59.     [CmdletBinding()]
  60.     param(
  61.         [Parameter(Mandatory = $false, Position = 0)]
  62.         [ValidateNotNullOrEmpty()]
  63.         [string]$Path = (Get-Location).Path
  64.     )
  65.  
  66.     $files = Get-ChildItem -Path $Path -Recurse -File -ErrorAction SilentlyContinue
  67.  
  68.     if (-not $files) {
  69.         Write-Warning "No files found in '$Path' or access denied to some subfolders."
  70.         return
  71.     }
  72.  
  73.     $measure = $files | Measure-Object -Property Length -Sum
  74.  
  75.     $totalBytes = $measure.Sum
  76.  
  77.     # Auto-scale to MB or GB
  78.     if ($totalBytes -ge 1GB) {
  79.         $formattedSize = '{0:N2} GB' -f ($totalBytes / 1GB)
  80.     } elseif ($totalBytes -ge 1MB) {
  81.         $formattedSize = '{0:N2} MB' -f ($totalBytes / 1MB)
  82.     } else {
  83.         $formattedSize = '{0:N2} KB' -f ($totalBytes / 1KB)
  84.     }
  85.  
  86.     [PSCustomObject]@{
  87.         Path       = (Resolve-Path -Path $Path).Path
  88.         FileCount  = $measure.Count
  89.         TotalBytes = $totalBytes
  90.         Size       = $formattedSize
  91.     }
  92. }
  93.  
  94. # -------------------------------------------------------------------
  95. # Chocolatey Tab Completion
  96. # -------------------------------------------------------------------
  97. # Load Chocolatey profile for tab completion if installed
  98. $ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
  99. if (Test-Path -Path $ChocolateyProfile) {
  100.     Import-Module -Name $ChocolateyProfile
  101. }
  102.  
  103. # -------------------------------------------------------------------
  104. # Function: Remove-PSReadLineHistoryEntry
  105. # -------------------------------------------------------------------
  106. <#
  107. .SYNOPSIS
  108.     Deletes entries from the PSReadLine persistent history file by line number.
  109.  
  110. .DESCRIPTION
  111.     Removes one or more specific lines from the file at (Get-PSReadLineOption).HistorySavePath.
  112.     This is the same numbering you see in `rh`, which shows the 1-based line number in the
  113.     PSReadLine history file (not the session history Id used by Get-History/Clear-History).
  114.  
  115. .PARAMETER LineNumber
  116.     One or more 1-based line numbers to delete.
  117.  
  118. .PARAMETER PassThru
  119.     If set, outputs objects describing what was deleted.
  120.  
  121. .EXAMPLE
  122.     Remove-PSReadLineHistoryEntry 1947
  123.  
  124. .EXAMPLE
  125.     1947,1952 | Remove-PSReadLineHistoryEntry -PassThru
  126. #>
  127. function Remove-PSReadLineHistoryEntry {
  128.     [CmdletBinding(SupportsShouldProcess = $true)]
  129.     param(
  130.         [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)]
  131.         [ValidateRange(1, [int]::MaxValue)]
  132.         [int[]]$LineNumber,
  133.  
  134.         [switch]$PassThru
  135.     )
  136.  
  137.     $historyPath = (Get-PSReadLineOption).HistorySavePath
  138.     if (-not (Test-Path -Path $historyPath)) {
  139.         Write-Error "History file not found at '$historyPath'."
  140.         return
  141.     }
  142.  
  143.     $targets = $LineNumber | Sort-Object -Unique
  144.     $lines = [System.IO.File]::ReadAllLines($historyPath)
  145.     $max = $lines.Count
  146.  
  147.     $bad = $targets | Where-Object { $_ -lt 1 -or $_ -gt $max }
  148.     if ($bad) {
  149.         Write-Warning ("Ignoring out-of-range line number(s): {0}. Valid range is 1..{1}." -f ($bad -join ', '), $max)
  150.         $targets = $targets | Where-Object { $_ -ge 1 -and $_ -le $max }
  151.         if (-not $targets) { return }
  152.     }
  153.  
  154.     $toDelete = foreach ($n in $targets) {
  155.         [PSCustomObject]@{
  156.             LineNumber = $n
  157.             Command    = $lines[$n - 1]
  158.         }
  159.     }
  160.  
  161.     # Always write a backup alongside the history file.
  162.     $stamp  = Get-Date -Format "yyyyMMdd-HHmmss"
  163.     $backup = "$historyPath.bak.$stamp"
  164.     Copy-Item -Path $historyPath -Destination $backup -Force
  165.  
  166.     if (-not $PSCmdlet.ShouldProcess($historyPath, "Delete PSReadLine history line(s): $($targets -join ', ')")) {
  167.         return
  168.     }
  169.  
  170.     # Remove from bottom-up to keep indexes stable.
  171.     $list = New-Object 'System.Collections.Generic.List[string]' (, $lines)
  172.     foreach ($n in ($targets | Sort-Object -Descending)) {
  173.         $list.RemoveAt($n - 1)
  174.     }
  175.  
  176.     [System.IO.File]::WriteAllLines($historyPath, $list, [System.Text.UTF8Encoding]::new($false))
  177.  
  178.     # Best-effort: refresh in-memory history for this session so UpArrow / Ctrl+R reflect the deletion.
  179.     try {
  180.         [Microsoft.PowerShell.PSConsoleReadLine]::ClearHistory()
  181.         foreach ($l in $list) {
  182.             if ($l -and $l.Trim()) {
  183.                 [Microsoft.PowerShell.PSConsoleReadLine]::AddToHistory($l)
  184.             }
  185.         }
  186.     } catch {
  187.         # If PSReadLine isn't available for some reason, just leave it.
  188.     }
  189.  
  190.     if ($PassThru) {
  191.         return $toDelete
  192.     }
  193.  
  194.     foreach ($d in $toDelete) {
  195.         Write-Host ("Deleted {0}: {1}" -f $d.LineNumber, $d.Command)
  196.     }
  197.     Write-Host ("Backup written to: {0}" -f $backup)
  198. }
  199.  
  200. # -------------------------------------------------------------------
  201. # Function: Invoke-HistoryCommand
  202. # -------------------------------------------------------------------
  203. <#
  204. .SYNOPSIS
  205.     Searches PowerShell history for unique commands matching a term and re-runs a selected one.
  206.  
  207. .DESCRIPTION
  208.     Displays unique commands from history that start with the optional search term,
  209.     numbered for selection.
  210.  
  211.     At the prompt you can:
  212.       - Enter a number to re-run the command
  213.       - Enter `d <number>` (or `del <number>`) to delete that history line
  214.  
  215. .PARAMETER SearchTerm
  216.     Optional prefix to filter history commands.
  217.  
  218. .PARAMETER Delete
  219.     Deletes one or more PSReadLine history lines by number (the same numbers shown by `rh`).
  220.  
  221. .EXAMPLE
  222.     rh clear
  223.  
  224. .EXAMPLE
  225.     rh -Delete 1947
  226. #>
  227. function Invoke-HistoryCommand {
  228.     [CmdletBinding()]
  229.     param(
  230.         [Parameter(Mandatory = $false, Position = 0)]
  231.         [string]$SearchTerm = '',
  232.  
  233.         [Parameter(Mandatory = $false)]
  234.         [ValidateRange(1, [int]::MaxValue)]
  235.         [int[]]$Delete
  236.     )
  237.  
  238.     if ($Delete) {
  239.         Remove-PSReadLineHistoryEntry -LineNumber $Delete
  240.         return
  241.     }
  242.  
  243.     # Ensure PSReadLine is available (built-in for PS 5.1)
  244.     $historyPath = (Get-PSReadLineOption).HistorySavePath
  245.     if (-not (Test-Path -Path $historyPath)) {
  246.         Write-Error "History file not found at '$historyPath'."
  247.         return
  248.     }
  249.  
  250.     $historyLines = Get-Content -Path $historyPath
  251.  
  252.     # Filter and collect unique commands (preserving most recent occurrence)
  253.     $unique = [ordered]@{}
  254.     for ($i = $historyLines.Count - 1; $i -ge 0; $i--) {
  255.         $line = $historyLines[$i].Trim()
  256.         if ($line -and ($SearchTerm -eq '' -or $line -like "$SearchTerm*") -and -not $unique.Contains($line)) {
  257.             $unique[$line] = $i + 1  # 1-based line number for display
  258.         }
  259.     }
  260.  
  261.     if ($unique.Count -eq 0) {
  262.         Write-Host "No matching commands found in history."
  263.         return
  264.     }
  265.  
  266.     # Display numbered list (most recent first)
  267.     $unique.GetEnumerator() | ForEach-Object {
  268.         Write-Host ("{0,4}: {1}" -f $_.Value, $_.Key)
  269.     }
  270.  
  271.     # Prompt for selection
  272.     $selection = Read-Host -Prompt "Enter number to re-run, or 'd <number>' to delete (empty to cancel)"
  273.     if (-not $selection) { return }
  274.  
  275.     # Delete mode: d 1947   /   del 1947,1950
  276.     $deleteMatch = [regex]::Match($selection, '^\s*(d|del|delete)\s+(.+?)\s*$', 'IgnoreCase')
  277.     if ($deleteMatch.Success) {
  278.         $raw = $deleteMatch.Groups[2].Value
  279.         $tokens = $raw -split '[,\s]+' | Where-Object { $_ }
  280.  
  281.         $nums = New-Object 'System.Collections.Generic.List[int]'
  282.         foreach ($t in $tokens) {
  283.             $n = 0
  284.             if ([int]::TryParse($t, [ref]$n) -and $n -ge 1) {
  285.                 [void]$nums.Add($n)
  286.             } else {
  287.                 Write-Warning "Ignoring invalid line number token: '$t'"
  288.             }
  289.         }
  290.  
  291.         if ($nums.Count -gt 0) {
  292.             Remove-PSReadLineHistoryEntry -LineNumber ($nums.ToArray())
  293.         }
  294.         return
  295.     }
  296.  
  297.     # Run mode: just a number
  298.     $chosenNumber = 0
  299.     if (-not [int]::TryParse($selection, [ref]$chosenNumber)) {
  300.         Write-Warning "Invalid input: '$selection' is not a number (or 'd <number>')."
  301.         return
  302.     }
  303.  
  304.     $match = $unique.GetEnumerator() | Where-Object { $_.Value -eq $chosenNumber } | Select-Object -First 1
  305.     if (-not $match) {
  306.         Write-Warning "No command found for number '$chosenNumber'."
  307.         return
  308.     }
  309.  
  310.     $chosenLine = $match.Key
  311.     Write-Host "Executing: $chosenLine" -ForegroundColor Yellow
  312.     Invoke-Expression -Command $chosenLine
  313. }
  314.  
  315.  
  316.  
  317. # -------------------------------------------------------------------
  318. # Convenience Functions
  319. # -------------------------------------------------------------------
  320. <#
  321. .SYNOPSIS
  322.     Opens the current PowerShell profile in Notepad++ when available.
  323. #>
  324. function Edit-Profile {
  325.     [CmdletBinding()]
  326.     param()
  327.  
  328.     if (-not (Test-Path -Path $PROFILE)) {
  329.         New-Item -ItemType File -Path $PROFILE -Force | Out-Null
  330.     }
  331.  
  332.     $editor = Get-Command notepad++ -ErrorAction SilentlyContinue
  333.     if ($editor) {
  334.         & $editor.Source $PROFILE
  335.     } else {
  336.         notepad $PROFILE
  337.     }
  338. }
  339.  
  340. <#
  341. .SYNOPSIS
  342.     Creates a directory if needed, then enters it.
  343.  
  344. .PARAMETER Path
  345.     Directory path to create and enter.
  346. #>
  347. function New-AndEnterDirectory {
  348.     [CmdletBinding()]
  349.     param(
  350.         [Parameter(Mandatory = $true, Position = 0)]
  351.         [ValidateNotNullOrEmpty()]
  352.         [string]$Path
  353.     )
  354.  
  355.     if (-not (Test-Path -Path $Path)) {
  356.         New-Item -ItemType Directory -Path $Path -Force | Out-Null
  357.     }
  358.  
  359.     Set-Location -Path $Path
  360. }
  361.  
  362. <#
  363. .SYNOPSIS
  364.     Changes to the dedicated Codex workspace.
  365. #>
  366. function Enter-CodexWorkspace {
  367.     [CmdletBinding()]
  368.     param()
  369.  
  370.     Set-Location -Path 'C:\Users\J2897\Codex'
  371. }
  372.  
  373. <#
  374. .SYNOPSIS
  375.     Launches Codex in the dedicated workspace.
  376. #>
  377. function Start-CodexWorkspace {
  378.     [CmdletBinding()]
  379.     param(
  380.         [Parameter(ValueFromRemainingArguments = $true)]
  381.         [string[]]$Arguments
  382.     )
  383.  
  384.     & codex --cd 'C:\Users\J2897\Codex' @Arguments
  385. }
  386.  
  387. <#
  388. .SYNOPSIS
  389.     Launches Codex in the dedicated workspace with live web search enabled.
  390. #>
  391. function Start-CodexWorkspaceSearch {
  392.     [CmdletBinding()]
  393.     param(
  394.         [Parameter(ValueFromRemainingArguments = $true)]
  395.         [string[]]$Arguments
  396.     )
  397.  
  398.     & codex --cd 'C:\Users\J2897\Codex' --search @Arguments
  399. }
  400.  
  401. <#
  402. .SYNOPSIS
  403.     Resumes the most recent Codex session for the dedicated workspace.
  404. #>
  405. function Resume-CodexWorkspace {
  406.     [CmdletBinding()]
  407.     param(
  408.         [Parameter(ValueFromRemainingArguments = $true)]
  409.         [string[]]$Arguments
  410.     )
  411.  
  412.     Push-Location 'C:\Users\J2897\Codex'
  413.     try {
  414.         & codex resume --last @Arguments
  415.     }
  416.     finally {
  417.         Pop-Location
  418.     }
  419. }
  420.  
  421. <#
  422. .SYNOPSIS
  423.     Opens the user-level Codex configuration file in Notepad++ when available.
  424. #>
  425. function Edit-CodexConfig {
  426.     [CmdletBinding()]
  427.     param()
  428.  
  429.     $configPath = Join-Path $HOME '.codex\config.toml'
  430.     $configDir = Split-Path -Parent $configPath
  431.     if (-not (Test-Path -Path $configDir)) {
  432.         New-Item -ItemType Directory -Path $configDir -Force | Out-Null
  433.     }
  434.     if (-not (Test-Path -Path $configPath)) {
  435.         New-Item -ItemType File -Path $configPath -Force | Out-Null
  436.     }
  437.  
  438.     $editor = Get-Command notepad++ -ErrorAction SilentlyContinue
  439.     if ($editor) {
  440.         & $editor.Source $configPath
  441.     } else {
  442.         notepad $configPath
  443.     }
  444. }
  445.  
  446. <#
  447. .SYNOPSIS
  448.     Shows concise Git status for the current repository.
  449. #>
  450. function Get-GitShortStatus {
  451.     [CmdletBinding()]
  452.     param(
  453.         [Parameter(ValueFromRemainingArguments = $true)]
  454.         [string[]]$Arguments
  455.     )
  456.  
  457.     & git status --short --branch @Arguments
  458. }
  459.  
  460. <#
  461. .SYNOPSIS
  462.     Stages files for commit.
  463. #>
  464. function Add-GitItem {
  465.     [CmdletBinding()]
  466.     param(
  467.         [Parameter(ValueFromRemainingArguments = $true)]
  468.         [string[]]$Arguments
  469.     )
  470.  
  471.     & git add @Arguments
  472. }
  473.  
  474. <#
  475. .SYNOPSIS
  476.     Shows the current Git diff.
  477. #>
  478. function Get-GitDiff {
  479.     [CmdletBinding()]
  480.     param(
  481.         [Parameter(ValueFromRemainingArguments = $true)]
  482.         [string[]]$Arguments
  483.     )
  484.  
  485.     & git diff @Arguments
  486. }
  487.  
  488. <#
  489. .SYNOPSIS
  490.     Shows the staged Git diff.
  491. #>
  492. function Get-GitCachedDiff {
  493.     [CmdletBinding()]
  494.     param(
  495.         [Parameter(ValueFromRemainingArguments = $true)]
  496.         [string[]]$Arguments
  497.     )
  498.  
  499.     & git diff --cached @Arguments
  500. }
  501.  
  502. <#
  503. .SYNOPSIS
  504.     Creates a Git commit.
  505. #>
  506. function Invoke-GitCommit {
  507.     [CmdletBinding()]
  508.     param(
  509.         [Parameter(ValueFromRemainingArguments = $true)]
  510.         [string[]]$Arguments
  511.     )
  512.  
  513.     & git commit @Arguments
  514. }
  515.  
  516. <#
  517. .SYNOPSIS
  518.     Shows a compact decorated Git log for the current repository.
  519. #>
  520. function Get-GitOneLineLog {
  521.     [CmdletBinding()]
  522.     param(
  523.         [Parameter(ValueFromRemainingArguments = $true)]
  524.         [string[]]$Arguments
  525.     )
  526.  
  527.     & git log --oneline --graph --decorate -12 @Arguments
  528. }
  529.  
  530. <#
  531. .SYNOPSIS
  532.     Shows a commit or object with summary statistics.
  533. #>
  534. function Get-GitShow {
  535.     [CmdletBinding()]
  536.     param(
  537.         [Parameter(ValueFromRemainingArguments = $true)]
  538.         [string[]]$Arguments
  539.     )
  540.  
  541.     & git show --stat @Arguments
  542. }
  543.  
  544. <#
  545. .SYNOPSIS
  546.     Shows local branches with verbose tracking information.
  547. #>
  548. function Get-GitBranchList {
  549.     [CmdletBinding()]
  550.     param(
  551.         [Parameter(ValueFromRemainingArguments = $true)]
  552.         [string[]]$Arguments
  553.     )
  554.  
  555.     & git branch -vv @Arguments
  556. }
  557.  
  558. <#
  559. .SYNOPSIS
  560.     Switches branches.
  561. #>
  562. function Switch-GitBranch {
  563.     [CmdletBinding()]
  564.     param(
  565.         [Parameter(ValueFromRemainingArguments = $true)]
  566.         [string[]]$Arguments
  567.     )
  568.  
  569.     & git switch @Arguments
  570. }
  571.  
  572. <#
  573. .SYNOPSIS
  574.     Creates and switches to a new branch.
  575. #>
  576. function New-GitBranchSwitch {
  577.     [CmdletBinding()]
  578.     param(
  579.         [Parameter(ValueFromRemainingArguments = $true)]
  580.         [string[]]$Arguments
  581.     )
  582.  
  583.     & git switch -c @Arguments
  584. }
  585.  
  586. <#
  587. .SYNOPSIS
  588.     Restores files in the working tree or index.
  589. #>
  590. function Restore-GitItem {
  591.     [CmdletBinding()]
  592.     param(
  593.         [Parameter(ValueFromRemainingArguments = $true)]
  594.         [string[]]$Arguments
  595.     )
  596.  
  597.     & git restore @Arguments
  598. }
  599.  
  600. <#
  601. .SYNOPSIS
  602.     Shows line-by-line authorship for a file.
  603. #>
  604. function Get-GitBlame {
  605.     [CmdletBinding()]
  606.     param(
  607.         [Parameter(ValueFromRemainingArguments = $true)]
  608.         [string[]]$Arguments
  609.     )
  610.  
  611.     & git blame @Arguments
  612. }
  613.  
  614. <#
  615. .SYNOPSIS
  616.     Lists tracked files.
  617. #>
  618. function Get-GitTrackedFiles {
  619.     [CmdletBinding()]
  620.     param(
  621.         [Parameter(ValueFromRemainingArguments = $true)]
  622.         [string[]]$Arguments
  623.     )
  624.  
  625.     & git ls-files @Arguments
  626. }
  627.  
  628. <#
  629. .SYNOPSIS
  630.     Fetches updates from the remote.
  631. #>
  632. function Invoke-GitFetch {
  633.     [CmdletBinding()]
  634.     param(
  635.         [Parameter(ValueFromRemainingArguments = $true)]
  636.         [string[]]$Arguments
  637.     )
  638.  
  639.     & git fetch @Arguments
  640. }
  641.  
  642. <#
  643. .SYNOPSIS
  644.     Pulls updates with fast-forward only.
  645. #>
  646. function Invoke-GitPull {
  647.     [CmdletBinding()]
  648.     param(
  649.         [Parameter(ValueFromRemainingArguments = $true)]
  650.         [string[]]$Arguments
  651.     )
  652.  
  653.     & git pull --ff-only @Arguments
  654. }
  655.  
  656. <#
  657. .SYNOPSIS
  658.     Pushes commits to the remote.
  659. #>
  660. function Invoke-GitPush {
  661.     [CmdletBinding()]
  662.     param(
  663.         [Parameter(ValueFromRemainingArguments = $true)]
  664.         [string[]]$Arguments
  665.     )
  666.  
  667.     & git push @Arguments
  668. }
  669.  
  670. <#
  671. .SYNOPSIS
  672.     Shows a short reference for custom Git aliases.
  673. #>
  674. function Show-GitAliasReference {
  675.     [CmdletBinding()]
  676.     param()
  677.  
  678.     @(
  679.         'ga    git add'
  680.         'gst   git status --short --branch'
  681.         'gd    git diff'
  682.         'gdc   git diff --cached'
  683.         'glg   git log --oneline --graph --decorate -12'
  684.         'gcmt  git commit'
  685.         'gsh   git show --stat'
  686.         'gbr   git branch -vv'
  687.         'gsw   git switch'
  688.         'gcb   git switch -c'
  689.         'grs   git restore'
  690.         'gbl   git blame'
  691.         'gls   git ls-files'
  692.         'gft   git fetch'
  693.         'gpl   git pull --ff-only'
  694.         'gpu   git push'
  695.     ) | ForEach-Object { Write-Host $_ }
  696. }
  697.  
  698. # Aliases for convenience
  699.  
  700. ### History and profile
  701. Set-Alias -Name rh -Value Invoke-HistoryCommand -Description "Search unique history and re-run selected command"
  702. Set-Alias -Name rhd -Value Remove-PSReadLineHistoryEntry -Description "Delete PSReadLine history by line number"
  703. Set-Alias -Name eprof -Value Edit-Profile -Description "Open the current PowerShell profile"
  704. Set-Alias -Name mkcd -Value New-AndEnterDirectory -Description "Create a directory and enter it"
  705.  
  706. ### Codex
  707. Set-Alias -Name croot -Value Enter-CodexWorkspace -Description "Change to C:\Users\J2897\Codex"
  708. Set-Alias -Name cdx -Value Start-CodexWorkspace -Description "Launch Codex in C:\Users\J2897\Codex"
  709. Set-Alias -Name cdxs -Value Start-CodexWorkspaceSearch -Description "Launch Codex in C:\Users\J2897\Codex with live web search"
  710. Set-Alias -Name cdxr -Value Resume-CodexWorkspace -Description "Resume the latest Codex session in C:\Users\J2897\Codex"
  711. Set-Alias -Name ecodex -Value Edit-CodexConfig -Description "Open ~/.codex/config.toml"
  712.  
  713. ### Git
  714. Set-Alias -Name ga -Value Add-GitItem -Description "Stage files with Git add"
  715. Set-Alias -Name gst -Value Get-GitShortStatus -Description "Show short Git status with branch"
  716. Set-Alias -Name gd -Value Get-GitDiff -Description "Show Git diff"
  717. Set-Alias -Name gdc -Value Get-GitCachedDiff -Description "Show staged Git diff"
  718. Set-Alias -Name glg -Value Get-GitOneLineLog -Description "Show a compact decorated Git log"
  719. Set-Alias -Name gcmt -Value Invoke-GitCommit -Description "Create a Git commit"
  720. Set-Alias -Name gsh -Value Get-GitShow -Description "Show commit details with stats"
  721. Set-Alias -Name gbr -Value Get-GitBranchList -Description "Show branches with tracking info"
  722. Set-Alias -Name gsw -Value Switch-GitBranch -Description "Switch branches"
  723. Set-Alias -Name gcb -Value New-GitBranchSwitch -Description "Create and switch to a new branch"
  724. Set-Alias -Name grs -Value Restore-GitItem -Description "Restore files with Git restore"
  725. Set-Alias -Name gbl -Value Get-GitBlame -Description "Show Git blame for a file"
  726. Set-Alias -Name gls -Value Get-GitTrackedFiles -Description "List tracked Git files"
  727. Set-Alias -Name gft -Value Invoke-GitFetch -Description "Fetch from remote"
  728. Set-Alias -Name gpl -Value Invoke-GitPull -Description "Pull with fast-forward only"
  729. Set-Alias -Name gpu -Value Invoke-GitPush -Description "Push to remote"
  730. Set-Alias -Name gref -Value Show-GitAliasReference -Description "Show custom Git alias reference"
  731.  
Add Comment
Please, Sign In to add comment