2023-10-21 01:17:07 +08:00
|
|
|
# 引入 Terminal-Icons
|
|
|
|
Import-Module Terminal-Icons
|
|
|
|
# 引入 PSReadLine
|
|
|
|
Import-Module PSReadLine
|
|
|
|
|
|
|
|
# 设置 PS readline
|
|
|
|
Set-PSReadLineOption -EditMode Windows
|
|
|
|
Set-PSReadLineOption -PredictionViewStyle ListView
|
|
|
|
Set-PSReadLineOption -BellStyle None
|
|
|
|
# 设置 Tab 键补全
|
2024-01-26 10:49:24 +08:00
|
|
|
Set-PSReadlineKeyHandler -Chord Tab -Function MenuComplete
|
2023-10-21 01:17:07 +08:00
|
|
|
# 设置 Ctrl+z 为撤销
|
|
|
|
Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo
|
|
|
|
# 设置向上键为后向搜索历史记录
|
|
|
|
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
|
|
|
|
# 设置向下键为前向搜索历史纪录
|
|
|
|
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
|
|
|
|
|
2024-01-26 10:38:19 +08:00
|
|
|
# 判断 PowerShell 版本
|
|
|
|
if ($PSVersionTable.PSVersion.Major -lt 7) {
|
|
|
|
Set-PSReadLineOption -PredictionSource History
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Set-PSReadLineOption -PredictionSource HistoryAndPlugin
|
|
|
|
}
|
|
|
|
|
2023-10-21 02:01:56 +08:00
|
|
|
function pythons {
|
|
|
|
(8, 9, 10, 11, 12) | ForEach-Object {
|
2023-10-21 11:53:23 +08:00
|
|
|
&"python3.$_ $args"
|
2023-10-21 02:01:56 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-21 01:17:07 +08:00
|
|
|
# 如果是 windows 平台 则执行 windows 下的配置
|
|
|
|
|
|
|
|
if ($IsWindows) {
|
|
|
|
# Windows 下的 java
|
|
|
|
foreach ($java_version in 8, 16, 17) {
|
|
|
|
Invoke-Expression @"
|
|
|
|
function j$java_version {
|
|
|
|
if (`$args.Length -eq 0) {
|
|
|
|
Write-Output "Java $java_version"
|
|
|
|
`$env:java_home="C:\Program Files\BellSoft\LibericaJDK-$java_version-Full"
|
|
|
|
`$env:path="`$env:java_home\bin;`$env:path"
|
|
|
|
} else {
|
|
|
|
&"C:\Program Files\BellSoft\LibericaJDK-$java_version-Full\bin\java.exe" (`$args -join " ")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"@
|
|
|
|
}
|
|
|
|
|
|
|
|
# Windows 下的 vcpkg 初始化
|
|
|
|
Import-Module 'V:\githubs\vcpkg\scripts\posh-vcpkg'
|
2024-01-18 00:18:36 +08:00
|
|
|
|
|
|
|
# Windows 10 only
|
2024-01-26 14:08:04 +08:00
|
|
|
$is_windows_10 = [System.Environment]::OSVersion.Version.Build -le "20000"
|
2024-01-18 00:18:36 +08:00
|
|
|
if ($is_windows_10) {
|
|
|
|
# https://github.com/PowerShell/PowerShell/issues/13138
|
|
|
|
# 其实就是 patch 成 import-module appx -usewindowspowershell
|
|
|
|
$PSDefaultParameterValues['Import-Module:UseWindowsPowerShell'] = {
|
|
|
|
if ((Get-PSCallStack)[1].Position.Text -match '\bAppX\b') { $true }
|
|
|
|
}
|
|
|
|
Write-Host "loaded Windows 10 only profile"
|
|
|
|
}
|
2023-10-21 01:17:07 +08:00
|
|
|
Write-Host "loaded Windows only profile"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
# 设置 ll 为 lsd -la
|
|
|
|
function ll {
|
|
|
|
lsd -la $args
|
|
|
|
}
|
|
|
|
|
|
|
|
# 防止有的平台没有 cls 的快捷方式
|
|
|
|
Set-Alias -Name cls -Value clear
|
|
|
|
|
|
|
|
# 启动 starship
|
|
|
|
Invoke-Expression (&starship init powershell)
|