From 29c17de18faf3fd130b4f09a0e24f321dcf98df0 Mon Sep 17 00:00:00 2001 From: js0ny Date: Fri, 9 Aug 2024 16:16:17 +0800 Subject: [PATCH] Sync from Windows --- .npmrc | 3 +- win/Microsoft.PowerShell_profile.ps1 | 57 ++++++++++++-------------- win/WindowsTerminal.json | 61 +++++++++++++++------------- 3 files changed, 60 insertions(+), 61 deletions(-) diff --git a/.npmrc b/.npmrc index 1cf6c9c..7549542 100644 --- a/.npmrc +++ b/.npmrc @@ -1,2 +1 @@ -proxy=http://127.0.0.1:7890 -https-proxy=http://127.0.0.1:7890 +registry=https://registry.npmmirror.com diff --git a/win/Microsoft.PowerShell_profile.ps1 b/win/Microsoft.PowerShell_profile.ps1 index 7dbf680..8cd0628 100644 --- a/win/Microsoft.PowerShell_profile.ps1 +++ b/win/Microsoft.PowerShell_profile.ps1 @@ -48,7 +48,13 @@ ${function:doku} = { Set-Location -Path ~\MyDocuments && Get-ChildItem } # Shell Equivalents # Set-Alias "touch" "New-Item" -Set-Alias "open" "explorer.exe" +function open { + if ($args.Count -eq 0) { + explorer.exe . + } else { + explorer.exe $args[0] + } +} # Shell Configurations # @@ -63,20 +69,20 @@ ${function:csi} = { dotnet script } # C & C++ # -Set-Alias "cl" "clang" -Set-Alias "clpp" "clang++" -Set-Alias "clang" "clang -std=c99" -Set-Alias "clang++" "clang++ -std=c++2b" +# Set-Alias "cl" "clang" +# Set-Alias "clpp" "clang++" +# ${function:clang} = { clang -std=c99 $args[0] } +# ${function:clang++} = { clang -std=c++2b $args[0] } # Python & Conda # Set-Alias "python3" "python" Set-Alias "pip3" "pip" Set-Alias "py" "python" -Set-Alias "pyact" "conda activate" -Set-Alias "pylsenv" "conda env list" -Set-Alias "pydeact" "conda deactivate" -Set-Alias "pymkenv" "conda create --name" +${function:pyact} = { conda activate $args[0] } +${function:pylsenvs} = { conda env list } +${function:pydact} = { conda deactivate } +${function:pymkenv} = { conda create --name $args[0] } # # Git # @@ -106,33 +112,23 @@ Set-Alias "gvi" "neovide" # Miscs # -Set-Alias mcd CreateAndSet-Directory ### Functions ### -function tc { param ( [string] $filename) - New-Item $filename && code $filename -} - -function tv { param ( [string] $filename) - New-Item $filename && nvim $filename -} - -function cdls { param( [string] $dirname) - Set-Location $dirname && Get-ChildItem -} +function mkcd { param ( [string] $dirname) mkdir $dirname && Set-Location $dirname} +function tc { param ( [string] $filename) New-Item $filename && code $filename } +function tv { param ( [string] $filename) New-Item $filename && nvim $filename } +function cdls { param( [string] $dirname) Set-Location $dirname && Get-ChildItem } ### Modules ### -$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" -if (Test-Path($ChocolateyProfile)) { Import-Module "$ChocolateyProfile" } - Import-Module -Name Microsoft.WinGet.CommandNotFound #f45873b3-b655-43a6-b217-97c00aa0db58 - Import-Module CompletionPredictor ### Misc ### +## Conda ## + #region conda initialize # !! Contents within this block are managed by 'conda init' !! If (Test-Path "$HOME\miniconda3\Scripts\conda.exe") { @@ -140,19 +136,15 @@ If (Test-Path "$HOME\miniconda3\Scripts\conda.exe") { } #endregion -### Check Start Up ### - +## 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 & @@ -160,3 +152,8 @@ if (-not ($__lastStartup -eq $_currentDate)) { # 记录当前日期到日志文件 $_currentDate | Out-File -FilePath $SystemlogFilePath -Append } + +## Chocolatey ## + +$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" +if (Test-Path($ChocolateyProfile)) { Import-Module "$ChocolateyProfile" } diff --git a/win/WindowsTerminal.json b/win/WindowsTerminal.json index 564595b..6842854 100644 --- a/win/WindowsTerminal.json +++ b/win/WindowsTerminal.json @@ -3,6 +3,14 @@ "$schema": "https://aka.ms/terminal-profiles-schema", "actions": [ + { + "command": + { + "action": "copy", + "singleLine": false + }, + "keys": "ctrl+c" + }, { "command": "unbound", "keys": "alt+shift+plus" @@ -39,22 +47,6 @@ "command": "unbound", "keys": "alt+shift+left" }, - { - "command": - { - "action": "copy", - "singleLine": false - }, - "keys": "ctrl+c" - }, - { - "command": - { - "action": "moveFocus", - "direction": "up" - }, - "keys": "ctrl+k" - }, { "command": "paste", "keys": "ctrl+v" @@ -68,8 +60,12 @@ "keys": "ctrl+shift+k" }, { - "command": "find", - "keys": "ctrl+shift+f" + "command": + { + "action": "moveFocus", + "direction": "up" + }, + "keys": "ctrl+k" }, { "command": @@ -79,6 +75,10 @@ }, "keys": "ctrl+shift+h" }, + { + "command": "find", + "keys": "ctrl+shift+f" + }, { "command": { @@ -88,14 +88,6 @@ }, "keys": "alt+shift+d" }, - { - "command": - { - "action": "splitPane", - "split": "right" - }, - "keys": "alt+shift+/" - }, { "command": { @@ -104,6 +96,14 @@ }, "keys": "ctrl+j" }, + { + "command": + { + "action": "splitPane", + "split": "right" + }, + "keys": "alt+shift+/" + }, { "command": { @@ -158,7 +158,9 @@ "font": { "face": "CaskaydiaCove Nerd Font" - } + }, + "opacity": 95, + "useAcrylic": true }, "list": [ @@ -169,9 +171,10 @@ "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}", "hidden": false, "name": "PowerShell", - "opacity": 100, + "opacity": 30, "scrollbarState": "hidden", - "source": "Windows.Terminal.PowershellCore" + "source": "Windows.Terminal.PowershellCore", + "useAcrylic": true }, { "guid": "{3c5d580b-1c52-55ce-89c9-57119457e5a7}",