From 907253b09710eea61ec4470ce3b401af757b5279 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Mon, 5 Dec 2022 01:48:04 +0900 Subject: [PATCH] fix: pwsh: custom history log --- dotfiles/pwsh/powershell_profile.ps1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dotfiles/pwsh/powershell_profile.ps1 b/dotfiles/pwsh/powershell_profile.ps1 index 45f5dbd..7dce21e 100644 --- a/dotfiles/pwsh/powershell_profile.ps1 +++ b/dotfiles/pwsh/powershell_profile.ps1 @@ -33,13 +33,17 @@ Set-Alias whereis where.exe # change window name # save my history $My_Pwsh_History = "$HOME\my_pwsh_history.txt" +# shell starts +Write-Output "$(Get-Date -UFormat '+%Y-%m-%d %H:%M:%S') $env:COMPUTERNAME`:$PID [START]" +| Out-File -FilePath $My_Pwsh_History -Append -Encoding utf8 +# save function Invoke-Starship-PreCommand { # window title $ParentFolder = Split-Path $PWD -Leaf $host.ui.Write("`e]0; $ParentFolder `a") # save log - Write-Output "$(Get-Date -UFormat '+%Y-%m-%d %H:%M:%S') $env:COMPUTERNAME`:$PID [$Global:LASTEXITCODE] $(Get-History -Count 1)" + Write-Output "$(Get-Date -UFormat '+%Y-%m-%d %H:%M:%S') $env:COMPUTERNAME`:$PID $PWD [$Global:LASTEXITCODE] $(Get-History -Count 1)" | Out-File -FilePath $My_Pwsh_History -Append -Encoding utf8 } Invoke-Expression (&starship init powershell)