This commit is contained in:
js0ny 2024-08-04 13:26:09 +08:00
parent b6aeb26915
commit f04850314f
5 changed files with 135 additions and 37 deletions

View file

@ -1,8 +1,11 @@
### Variables ###
$EDITOR = "code"
$DOTFILES = "$HOME\Documents\.dotfiles"
### Load Configs ###
Get-ChildItem -Path $DOTFILES\powershell -Filter *.ps1 | ForEach-Object {. $_}
### PSReadLine ###
Set-PSReadLineOption -EditMode vi # Vi Keybindings
@ -12,7 +15,14 @@ Set-PSReadLineOption -ContinuationPrompt "`e[36m CR > " # Continuation Prompt
### Keybindings ###
Set-PSReadLineKeyHandler -Chord "Ctrl+f" -Function ForwardWord
Set-PSReadLineKeyHandler -Chord "Ctrl+Shift+f" -Function ForwardWord
Set-PSReadLineKeyHandler -Chord "Ctrl+Shift+b" -Function BackwardWord
Set-PSReadLineKeyHandler -Chord "Alt+f" -Function ForwardChar
Set-PSReadLineKeyHandler -Chord "Ctrl+b" -Function BackwardChar
Set-PSReadLineKeyHandler -Chord "Ctrl+p" -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Chord "Ctrl+n" -Function HistorySearchForward
Set-PSReadLineKeyHandler -Chord "Ctrl+a" -Function BeginningOfLine
Set-PSReadLineKeyHandler -Chord "Ctrl+e" -Function EndOfLine
### Navigator ###
@ -42,8 +52,8 @@ Set-Alias "open" "explorer.exe"
# Shell Configurations #
${function:shcfg} = { $EDITOR $PROFILE }
${function:reload} = { Invoke-Expression $PROFILE }
${function:shcfg} = { code $PROFILE }
${function:reload} = { . $PROFILE }
${function:pulldots} = { Set-Location -Path $DOTFILES && git pull }
Set-Alias "pwshcfg" "shcfg"
@ -54,7 +64,7 @@ ${function:csi} = { dotnet script }
# C & C++ #
Set-Alias "cl" "clang"
Set-Alias "clp" "clang++"
Set-Alias "clpp" "clang++"
Set-Alias "clang" "clang -std=c99"
Set-Alias "clang++" "clang++ -std=c++2b"
@ -83,6 +93,11 @@ Set-Alias "pymkenv" "conda create --name"
# Set-Alias "gps" "git push"
# WSL #
${function:wsl1} = {wsl.exe --distribution Debian}
${function:wsl2} = {wsl.exe --distribution Ubuntu-22.04}
# Editors #
Set-Alias "v" "nvim"
@ -123,4 +138,25 @@ Import-Module CompletionPredictor
If (Test-Path "$HOME\miniconda3\Scripts\conda.exe") {
(& "$HOME\miniconda3\Scripts\conda.exe" "shell.powershell" "hook") | Out-String | Where-Object{$_} | Invoke-Expression
}
#endregion
#endregion
### Check Start Up ###
$SystemlogFilePath = "$env:USERPROFILE\.PowerShellStartup.log"
# 检查日志文件是否存在
if (-not (Test-Path $SystemlogFilePath)) {
New-Item -Path $SystemlogFilePath -ItemType File -Force | Out-Null
}
# 读取日志文件的最后一行(即上次启动日期)
$__lastStartup = Get-Content -Path $SystemlogFilePath -Tail 1 -ErrorAction SilentlyContinue
$_currentDate = (Get-Date).ToString("yyyy-MM-dd")
if (-not ($__lastStartup -eq $_currentDate)) {
Get-Date
Update-ForexData &
Write-Host "今天是第一次启动 PowerShell。"
# 记录当前日期到日志文件
$_currentDate | Out-File -FilePath $SystemlogFilePath -Append
}

View file

@ -55,6 +55,10 @@
},
"keys": "ctrl+k"
},
{
"command": "paste",
"keys": "ctrl+v"
},
{
"command":
{
@ -64,8 +68,16 @@
"keys": "ctrl+shift+k"
},
{
"command": "paste",
"keys": "ctrl+v"
"command": "find",
"keys": "ctrl+shift+f"
},
{
"command":
{
"action": "resizePane",
"direction": "left"
},
"keys": "ctrl+shift+h"
},
{
"command":
@ -79,14 +91,10 @@
{
"command":
{
"action": "resizePane",
"direction": "left"
"action": "splitPane",
"split": "right"
},
"keys": "ctrl+shift+h"
},
{
"command": "find",
"keys": "ctrl+shift+f"
"keys": "alt+shift+/"
},
{
"command":
@ -96,14 +104,6 @@
},
"keys": "ctrl+j"
},
{
"command":
{
"action": "splitPane",
"split": "right"
},
"keys": "alt+shift+/"
},
{
"command":
{
@ -173,13 +173,6 @@
"scrollbarState": "hidden",
"source": "Windows.Terminal.PowershellCore"
},
{
"colorScheme": "One Half Dark",
"guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
"hidden": false,
"name": "Ubuntu",
"source": "Windows.Terminal.Wsl"
},
{
"guid": "{3c5d580b-1c52-55ce-89c9-57119457e5a7}",
"hidden": false,
@ -225,6 +218,18 @@
"hidden": false,
"name": "Debian",
"source": "Windows.Terminal.Wsl"
},
{
"guid": "{17bf3de4-5353-5709-bcf9-835bd952a95e}",
"hidden": true,
"name": "Ubuntu-22.04",
"source": "Windows.Terminal.Wsl"
},
{
"guid": "{e5a83caa-4c73-52b3-ae6b-bc438d721ef9}",
"hidden": false,
"name": "Ubuntu 22.04.3 LTS",
"source": "CanonicalGroupLimited.Ubuntu22.04LTS_79rhkp1fndgsc"
}
]
},
@ -414,6 +419,29 @@
"white": "#D3D7CF",
"yellow": "#C4A000"
},
{
"background": "#300A24",
"black": "#171421",
"blue": "#0037DA",
"brightBlack": "#767676",
"brightBlue": "#08458F",
"brightCyan": "#2C9FB3",
"brightGreen": "#26A269",
"brightPurple": "#A347BA",
"brightRed": "#C01C28",
"brightWhite": "#F2F2F2",
"brightYellow": "#A2734C",
"cursorColor": "#FFFFFF",
"cyan": "#3A96DD",
"foreground": "#FFFFFF",
"green": "#26A269",
"name": "Ubuntu-22.04-ColorScheme",
"purple": "#881798",
"red": "#C21A23",
"selectionBackground": "#FFFFFF",
"white": "#CCCCCC",
"yellow": "#A2734C"
},
{
"background": "#300A24",
"black": "#171421",