Microsoft.PowerShell_profile.ps1

<# $PSVersionTable.PSVersion 6.2.0
.$profile # reload profile
Set-ExecutionPolicy RemoteSigned -Scope LocalMachine # Permits profiles (.ps1)
$PROFILE | Format-List * -Force
$PROFILE.CurrentUserAllHosts

$Env:userprofile
C:\Users\xxx
$profile
C:\Users\xxx\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
#>

##########################################
function prompt
{
  # $un = [Regex]::Match($CurrentUser.Name,"SOLIDWORKS\\+(.*)").Groups[1].Value
  # $hn = [Net.DNS]::GetHostName()
  # $host.ui.rawui.WindowTitle = $un + "@" + $hn #+ " Line: " + $host.UI.RawUI.CursorPosition.Y
  
  # Write-Host($un + "@" + $hn + " ") -foregroundcolor Green -nonewline; Write-Host ($(get-location)) -foregroundcolor Yellow  -nonewline
  # Write-Host(">") -nonewline -foregroundcolor Green

  $host.ui.rawui.WindowTitle = "$(Get-Location)"
  # (Get-Date).ToLongTimeString()
  # (Get-Date -UFormat %m%d_%H:%M:%S)
  Write-Host ("PS " + $( get-location) + "[" + (Get-Date -UFormat %H:%M:%S) + "]" + ">") -foregroundcolor Green -nonewline -backgroundcolor Black
  
  return " "
}

#{{{ Appearance configuration Begin
$console = $host.UI.RawUI
$console.ForegroundColor = "White"
$console.BackgroundColor = "Black"

$buffer = $console.BufferSize
$buffer.Width = 130
$buffer.Height = 9999
$console.BufferSize = $buffer

$size = $console.WindowSize
$size.Width = 160
$size.Height = 36
$console.WindowSize = $size

# $colors = $host.PrivateData
# $colors.VerboseForegroundColor = "white"
# $colors.VerboseBackgroundColor = "blue"
# $colors.WarningForegroundColor = "yellow"
# $colors.WarningBackgroundColor = "darkgreen"
# $colors.ErrorForegroundColor = "white"
# $colors.ErrorBackgroundColor = "red"
# Write-Output "This is a test message."
# Write-Verbose "This is a verbose message." -Verbose
# Write-Warning "This is a warning message."
# Write-Error "This is an error message."

# https://github.com/Microsoft/console/releases
# ColorTool.exe -b schemes\solarized_dark.itermcolors
# TODO: registry modify

Clear-Host
#}}} Appearance configuration End

# Set-Alias l "Get-ChildItem -Name"
function gci-name {Get-ChildItem -Name}
Set-Alias l gci-name
Set-Alias ll Get-ChildItem

# Set-Alias
# New-Item -Force alias:np -value C:\Windows\System32\notepad.exe | Out-Null
Set-Alias np ${env:windir}\notepad.exe

#env:path += ";C:\emacs"
# Clear-Host

# $PSReadLineOptions = @{
#     EditMode = "Emacs"
#     HistoryNoDuplicates = $true
#     HistorySearchCursorMovesToEnd = $true
#     Colors = @{
#         "Command" = "#8181f7"
#     }
# }
# Set-PSReadLineOption @PSReadLineOptions
#

Set-PSReadLineOption -EditMode Emacs -BellStyle None

####################################
# Common
function chdir_cd- { cd - }
function chdir_cd1 { cd .. }
function chdir_cd2 { cd ..\.. }
function chdir_cd3 { cd ..\..\.. }
function chdir_cd4 { cd ..\..\..\.. }
function chdir_cd5 { cd ..\..\..\..\.. }
function chdir_cd6 { cd ..\..\..\..\..\.. }
function chdir_cd7 { cd ..\..\..\..\..\..\.. }
function chdir_cd8 { cd ..\..\..\..\..\..\..\.. }
function chdir_cd9 { cd ..\..\..\..\..\..\..\..\.. }

Set-Alias cd- chdir_cd-
Set-Alias cd.. chdir_cd1
Set-Alias cd1 chdir_cd1
Set-Alias cd2 chdir_cd2
Set-Alias cd3 chdir_cd3
Set-Alias cd4 chdir_cd4
Set-Alias cd5 chdir_cd5
Set-Alias cd6 chdir_cd6
Set-Alias cd7 chdir_cd7
Set-Alias cd8 chdir_cd8
Set-Alias cd9 chdir_cd9

function usbport { Get-CimInstance Win32_PnPEntity -Filter "name like '%USB%Serial%Port%COM%'"; }

####################################
### Tips
# Get-FileHash -Algorithm MD5 filename
# Test-Path $profile
# New-Item -path $profile -type file –force

<#
PS E:\hrdump_v3\encrypt2_test_file_log[10:48:29]> gal -Definition *job

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Alias           gjb -> Get-Job
Alias           rcjb -> Receive-Job
Alias           rjb -> Remove-Job
Alias           sajb -> Start-Job
Alias           spjb -> Stop-Job
Alias           wjb -> Wait-Job
sajb {adb wait-for-device; adb root; sleep 4; adb wait-for-device; adb shell getenforce; adb logcat -b main}
rcjb -Keep -id 1
rcjb 1 |Out-File -Append main_jb.log
spjb 1
rjb 1

UART: Get serialport log
[System.IO.Ports.SerialPort]::getportnames()

# https://docs.microsoft.com/en-us/windows/desktop/wmisdk/wql-sql-for-wmi
# Get-CimInstance -Query "select * from Win32_PnPEntity where name like '%Serial%'"

Get-CimInstance Win32_PnPEntity -Filter "name like '%USB%Serial%Port%COM%'"

$port = new-Object System.IO.Ports.SerialPort COM13,115200,None,8,one
$port.Open()
Register-ObjectEvent -InputObject $port -EventName DataReceived -Action {$port.ReadLine()}

Id     Name            PSJobTypeName   State         HasMoreData     Location             Command
--     ----            -------------   -----         -----------     --------             -------
3      03ed5add-e68...                 Running       True                                 $port.ReadLine()
rcjb 3 -Keep

#$port.ReadLine()

$ join file name list
(-split $(ls -Name -af)) -join " "
(ls -n) -split "`n" -join " "

#>
#######################################

PowerShell Configuration and Color

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Console]
"ColorTable00"=dword:00312700
"ColorTable01"=dword:00c77520
"ColorTable02"=dword:00058972
"ColorTable03"=dword:00859125
"ColorTable04"=dword:00241bd0
"ColorTable05"=dword:006e1bc6
"ColorTable06"=dword:000577a5
"ColorTable07"=dword:00cbe2e9
"ColorTable08"=dword:00644d00
"ColorTable09"=dword:00838170
"ColorTable10"=dword:00615a46
"ColorTable11"=dword:008f9081
"ColorTable12"=dword:001236bd
"ColorTable13"=dword:00b95658
"ColorTable14"=dword:006f6752
"ColorTable15"=dword:00dcf4fc
"CtrlKeyShortcutsDisabled"=dword:00000000
"CursorSize"=dword:00000019
"EnableColorSelection"=dword:00000000
"ExtendedEditKey"=dword:00000001
"ExtendedEditKeyCustom"=dword:00000000
"FaceName"="新宋体"
"FilterOnPaste"=dword:00000001
"FontFamily"=dword:00000036
"FontSize"=dword:00140000
"FontWeight"=dword:00000190
"ForceV2"=dword:00000001
"FullScreen"=dword:00000000
"HistoryBufferSize"=dword:000003e7
"HistoryNoDup"=dword:00000000
"InsertMode"=dword:00000001
"LineSelection"=dword:00000001
"LineWrap"=dword:00000001
"LoadConIme"=dword:00000001
"NumberOfHistoryBuffers"=dword:000003e7
"PopupColors"=dword:000000f5
"QuickEdit"=dword:00000001
"ScreenBufferSize"=dword:270f0082
"ScreenColors"=dword:00000009
"ScrollScale"=dword:00000001
"TrimLeadingZeros"=dword:00000000
"WindowAlpha"=dword:000000ff
"WindowSize"=dword:00240082
"WordDelimiters"=dword:00000000
"CurrentPage"=dword:00000003

[HKEY_CURRENT_USER\Console\%SystemRoot%_System32_WindowsPowerShell_v1.0_powershell.exe]
"ColorTable05"=dword:00562401
"ColorTable06"=dword:00f0edee
"FaceName"="Lucida Console"
"FontFamily"=dword:00000036
"FontWeight"=dword:00000190
"PopupColors"=dword:000000f3
"QuickEdit"=dword:00000001
"ScreenBufferSize"=dword:0bb80078
"ScreenColors"=dword:00000056
"WindowSize"=dword:00320078

[HKEY_CURRENT_USER\Console\%SystemRoot%_SysWOW64_WindowsPowerShell_v1.0_powershell.exe]
"ColorTable05"=dword:00562401
"ColorTable06"=dword:00f0edee
"FaceName"="Lucida Console"
"FontFamily"=dword:00000036
"FontWeight"=dword:00000190
"PopupColors"=dword:000000f3
"QuickEdit"=dword:00000001
"ScreenBufferSize"=dword:0bb80078
"ScreenColors"=dword:00000056
"WindowSize"=dword:00320078

[HKEY_CURRENT_USER\Console\C:_Program Files_PowerShell_6_pwsh.exe]
"ScreenBufferSize"=dword:270f0078
"FontSize"=dword:00140000
"FontFamily"=dword:00000036
"FontWeight"=dword:00000190
"FaceName"="新宋体"

Download PowerShell

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值