persona

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 25cea768b7ce281b1ffd4b7841d84c5a2c5010bb
parent eb237dd0ec5822fe5899e25fe3e37611c0a455a9
Author: minerva-jupiter <ryouturn@gmail.com>
Date:   Thu, 22 Jan 2026 07:46:44 +0900

add auto gitpull on ps

Diffstat:
MMicrosoft.PowerShell_profile.ps1 | 61++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 58 insertions(+), 3 deletions(-)

diff --git a/Microsoft.PowerShell_profile.ps1 b/Microsoft.PowerShell_profile.ps1 @@ -1,5 +1,4 @@ -# This need to put $PROFILE -# and run it `Install-Module posh-git` +#this need to put on $PROFILES #f45873b3-b655-43a6-b217-97c00aa0db58 PowerToys CommandNotFound module Import-Module -Name Microsoft.WinGet.CommandNotFound @@ -13,7 +12,36 @@ function ls-bash { Get-ChildItem $args -Force } if (Test-Path alias:ls) { Remove-Item alias:ls } Set-Alias ls ls-bash -function rm-bash { Remove-Item -Recurse -Force $args } +function rm-bash { + [CmdletBinding()] + param( + [Parameter(ValueFromRemainingArguments = $true)] + $RemainingArgs + ) + + $params = @{} + $cleanArgs = @() + + foreach ($arg in $RemainingArgs) { + if ($arg -eq "-r" -or $arg -eq "-R") { + $params["Recurse"] = $true + } + elseif ($arg -eq "-f") { + $params["Force"] = $true + } + elseif ($arg -eq "-rf" -or $arg -eq "-fr") { + $params["Recurse"] = $true + $params["Force"] = $true + } + else { + $cleanArgs += $arg + } + } + + if ($cleanArgs.Count -gt 0) { + Remove-Item -Path $cleanArgs @params + } +} if (Test-Path alias:rm) { Remove-Item alias:rm } Set-Alias rm rm-bash @@ -28,3 +56,30 @@ function Update-Environment { Write-Host "Environment variables (Path) updated!" -ForegroundColor Cyan } Set-Alias refresh Update-Environment + +$global:lastGitRepo = "" + +function prompt { + $currentPath = (Get-Location).Path + + # Gitリポジトリのルートを探す + $gitRoot = git rev-parse --show-toplevel 2>$null + + # Gitリポジトリ内にいて、かつ前回記録したリポジトリと異なる場合のみ実行 + if ($null -ne $gitRoot -and $gitRoot -ne $global:lastGitRepo) { + $global:lastGitRepo = $gitRoot + + Write-Host "`n[Git Detect] New repository: $gitRoot" -ForegroundColor Yellow + Write-Host "Execute 'git pull'? (y/n): " -ForegroundColor Cyan -NoNewline + $response = Read-Host + + if ($response -eq 'y') { + git pull + } + } elseif ($null -eq $gitRoot) { + # Gitリポジトリ外に出た場合は記録をリセット + $global:lastGitRepo = "" + } + + "PS $currentPath> " +}