Skip to content

Instantly share code, notes, and snippets.

@cd01
Last active December 23, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cd01/6647326 to your computer and use it in GitHub Desktop.
Save cd01/6647326 to your computer and use it in GitHub Desktop.
このコマンドレット、この前 PowerShell で実行した、ような・・・・・・ ref: http://qiita.com/cd01/items/1f4a380234ef9ea86d73
function Prompt {
# PowerShell 3.0+
Export-Csv -Path ~\.posh_history.csv -InputObject (Get-History)[-1] -Append
return "$pwd > "
}
Import-Csv ~\.posh_history.csv | Add-History
function Prompt {
# PowerShell 3.0+
Export-Csv -Path ~\.posh_history.csv -InputObject (Get-History)[-1] -Append
return "$pwd > "
}
Import-Csv ~\.posh_history.csv | Add-History
# 2.0 向け(PowerShell 2.0 のことは忘れましょう
if (-not (Test-Path ~\.posh_history.csv)) {
"#TYPE Microsoft.PowerShell.Commands.HistoryInfo" | Out-File ~\.posh_history.csv -encoding UTF8
'"Id","CommandLine","ExecutionStatus","StartExecutionTime","EndExecutionTime"' | Out-File ~\.posh_history.csv -encoding UTF8 -append
}
$h = (Get-History)[-1]
$csv = "`"$($h.Id)`",`"$($h.CommandLine)`",`"$($h.ExecutionStatus)`",`"$($h.StartExecutionTime)`",`"$($h.EndExecutionTime)`""
$csv | Out-File ~\.posh_history.csv -encoding UTF8 -append
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment