Skip to content

Instantly share code, notes, and snippets.

@lv7777
Last active September 17, 2017 06:42
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 lv7777/d3181fb882642d5226f595d8ed640c33 to your computer and use it in GitHub Desktop.
Save lv7777/d3181fb882642d5226f595d8ed640c33 to your computer and use it in GitHub Desktop.
my psprofile
#タイトルを変更する
$a = (Get-Host).UI.RawUI
$a.WindowTitle = "三( `・ω・)\\|| Powershell////(・ω・´ )三"
function zsh {
bash -c zsh
}
<#(`・ω・´)
function Prompt {
if ($?) {
#Write-Host "PS [" (Split-Path (Get-Location) -Leaf) "](=ω=.)" -NoNewLine -ForegroundColor "Green"
#Write-Host "PS [" (Split-Path (Get-Location) -Leaf) "]" -NoNewLine -ForegroundColor "Green"
Write-Host "PS [" (Get-Location) "]( ´_ゝ`) " -ForegroundColor "Green"
return "> "
} else {
Write-Host "PS [" (Split-Path (Get-Location) -Leaf) "](≧Д≦)" -ForegroundColor "Red"
return "> "
}
}
function prompt {
# our theme
$cdelim = [ConsoleColor]::DarkCyan
$chost = [ConsoleColor]::Green
$cloc = [ConsoleColor]::Cyan
write-host "$([char]0x0A7) " -n -f $cloc
write-host ([net.dns]::GetHostName()) -n -f $chost
write-host ' {' -n -f $cdelim
write-host (shorten-path (pwd).Path) -n -f $cloc
write-host '}' -n -f $cdelim
return ' '
}
#>
function prompt {
# our theme
if ($?) {
$cdelim = [ConsoleColor]::DarkCyan
$chost = [ConsoleColor]::Green
$cloc = [ConsoleColor]::Cyan
write-host "PS " -n -f $cloc
write-host ([net.dns]::GetHostName()) -n -f $chost
write-host ' [' -n -f $cdelim
# contains system32 or syswow or Program Files
if("$pwd" -match "AppData"){Write-Host " Warning!!! " -n -ForegroundColor "Red"}
if("$pwd" -match "Windows"){Write-Host " Warning!!! " -n -ForegroundColor "Red"}
if("$pwd" -match "Program Files"){Write-Host " Warning!!! " -n -ForegroundColor "Red"}
if("$pwd" -match "system32"){Write-Host " ☢CAUTION!!!☢ ☢CAUTION!!!☢ " -n -ForegroundColor "Red"}
write-host (shorten-path (pwd).Path) -n -f $cloc
write-host ']' -n -f $cdelim
Write-Host "( ´_ゝ`) " -ForegroundColor "Green"
if( (Get-Acl . | Select-Object AccessToString) -match (Get-Content Env:\USERNAME) ){
return "[☀] > "
}else{
return "[☂] > "
}
} else {
$cdelim = [ConsoleColor]::DarkCyan
$chost = [ConsoleColor]::Green
$cloc = [ConsoleColor]::Cyan
write-host "PS " -n -f $cloc
write-host ([net.dns]::GetHostName()) -n -f $chost
write-host ' [' -n -f $cdelim
# contains system32 or syswow or Program Files
if("$pwd" -match "AppData"){Write-Host " Warning!!! " -n -ForegroundColor "Red"}
if("$pwd" -match "Windows"){Write-Host " Warning!!! " -n -ForegroundColor "Red"}
if("$pwd" -match "Program Files"){Write-Host " Warning!!! " -n -ForegroundColor "Red"}
if("$pwd" -match "system32"){Write-Host " ☢CAUTION!!!☢ ☢CAUTION!!!☢ " -n -ForegroundColor "Red"}
write-host (shorten-path (pwd).Path) -n -f $cloc
write-host ']' -n -f $cdelim
Write-Host "(≧Д≦)" -ForegroundColor "Red"
if( (Get-Acl . | Select-Object AccessToString) -match (Get-Content Env:\USERNAME) ){
return "[☀] > "
}else{
return "[☂] > "
}
}
}
function shorten-path([string] $path) {
$loc = $path.Replace($HOME, '~')
# remove prefix for UNC paths
$loc = $loc -replace '^[^:]+::', ''
# make path shorter like tabs in Vim,
# handle paths starting with \\ and . correctly
return ($loc -replace '\\(\.?)([^\\])[^\\]*(?=\\)','\$1$2')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment