54 lines
1.6 KiB
PowerShell
54 lines
1.6 KiB
PowerShell
|
# 引入 Terminal-Icons
|
||
|
Import-Module Terminal-Icons
|
||
|
# 引入 PSReadLine
|
||
|
Import-Module PSReadLine
|
||
|
|
||
|
# 设置 PS readline
|
||
|
Set-PSReadLineOption -EditMode Windows
|
||
|
Set-PSReadLineOption -PredictionSource HistoryAndPlugin
|
||
|
Set-PSReadLineOption -PredictionViewStyle ListView
|
||
|
Set-PSReadLineOption -BellStyle None
|
||
|
# 设置 Tab 键补全
|
||
|
Set-PSReadlineKeyHandler -Key Tab -Function Complete
|
||
|
# 设置 Ctrl+z 为撤销
|
||
|
Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo
|
||
|
# 设置向上键为后向搜索历史记录
|
||
|
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
|
||
|
# 设置向下键为前向搜索历史纪录
|
||
|
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
|
||
|
|
||
|
# 如果是 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'
|
||
|
|
||
|
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)
|