chezmoi: windows migration dir

This commit is contained in:
js0ny 2025-10-20 03:58:34 +01:00
parent 52b70819bf
commit c24adf35d4
51 changed files with 3403 additions and 3840 deletions

View file

@ -0,0 +1,89 @@
# $DOTFILES/platforms\win\Microsoft.PowerShell_profile.ps1
# Date: 2024-12-01
# Author: js0ny
# PowerShell profile for Windows
### Load Configs ###
$DOTFILES = Join-Path $HOME ".dotfiles"
Get-ChildItem -Path $(Join-Path $DOTFILES "tools" "powershell") -Filter *.ps1 | ForEach-Object { . $_ }
### Aliases ###
# Toggle Theme #
Set-Alias "dark-mode" "$DOTFILES\platforms\win\cmd\dark-mode.bat" # Consistent with macOS (`dark-mode`)
# Miscs #
### Misc ###
${function:qwen} = "ollama run qwen2.5:14b"
## Conda ##
#region conda initialize
# !! Contents within this block are managed by 'conda init' !!
If (Test-Path "$HOME\miniconda3\Scripts\conda.exe") {
(& "$HOME\miniconda3\Scripts\conda.exe" "shell.powershell" "hook") | Out-String | Where-Object { $_ } | Invoke-Expression
}
#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
#}
#Remove-Variable SystemlogFilePath
#Remove-Variable __lastStartup
#Remove-Variable _currentDate
# Set default applications
$Env:PAGER = "less"
$Env:EDITOR = "code --wait"
$Env:VISUAL = "code --wait"
$Env:FILE_MANAGER = "dopus.exe"
${function:wini} = { winget install $args }
${function:winr} = { winget uninstall $args }
${function:wins} = { winget search $args }
${function:winu} = { winget upgrade $args }
${function:pkill} = { Get-Process *$args* | Stop-Process -Force }
${function:tmux} = { wsl.exe tmux $args }
if (Get-Command "sfsu.exe" -ErrorAction SilentlyContinue) {
Invoke-Expression (&sfsu.exe hook)
}
# Elevate in current shell
# Set Windows Sudo to `inlined` sudo
${function:su} = { sudo.exe pwsh }
function Show-WindowsNotification {
param (
[string]$Title,
[Parameter(ValueFromPipeline=$true)]
[string]$Message
)
Add-Type -AssemblyName System.Windows.Forms
$notifyIcon = New-Object System.Windows.Forms.NotifyIcon
$notifyIcon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon((Get-Command pwsh).Source)
$notifyIcon.Visible = $true
$notifyIcon.ShowBalloonTip(0,$Title,$Message,[System.Windows.Forms.ToolTipIcon]::Info)
}
Import-Module "$($(Get-Item $(Get-Command scoop.ps1).Path).Directory.Parent.FullName)\modules\scoop-completion"

View file

@ -0,0 +1,90 @@
Shortcuts [
[
Cmd = CmdToggleBookmark
Key = Ctrl + \\
]
[
Cmd = CmdRenameFile
Key = R
]
[
Cmd = CmdFindNext
Key = k
]
[
Cmd = CmdFindPrev
Key = K
]
[
Cmd = CmdScrollUp
Key = e
]
[
Cmd = CmdScrollDown
Key = n
]
[
Cmd = CmdScrollUpHalfPage
Key = E
]
[
Cmd = CmdScrollDownHalfPage
Key = N
]
[
Cmd = CmdScrollRight
Key = i
]
[
Cmd = CmdInvertColors
Key = l
]
[
Cmd = CmdPrevTab
Key = Shift+H
]
[
Cmd = CmdNextTab
Key = Shift+I
]
[
Cmd = CmdGoToFirstPage
Key = g
]
[
Cmd = CmdGoToLastPage
Key = G
]
[
Cmd = CmdGoToPage
Key = :
]
[
Cmd = CmdRotateLeft
Key = {
]
[
Cmd = CmdRotateRight
Key = }
]
[
Cmd = CmdNavigateBack
Key = [
]
[
Cmd = CmdNavigateForward
Key = ]
]
[
Cmd = CmdNavigateBack
Key = b
]
[
Cmd = CmdNavigateForward
Key = f
]
[
Cmd = CmdHelpOpenKeyboardShortcuts
Key = ?
]
]

View file

@ -0,0 +1,57 @@
// %UserProfile%\.config\fastfetch\config.jsonc
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"logo": {
// "type": "auto",
"source": "Windows 7",
"padding": {
"top": 2,
"left": 1,
"right": 2
}
},
"general": {
"multithreading": true
},
"display": {
"separator": " ",
"key": {
"width": 10,
"paddingLeft": 2,
"type": "icon"
}
},
"modules": [
{
"type": "title",
"format": "{#1}───────────── {#}{user-name-colored}@{host-name-colored}"
},
{
"type": "colors",
"symbol": "diamond",
"paddingLeft": 15
},
"os",
"host",
"kernel",
"uptime",
{
"type": "packages"
},
"shell",
"display",
"icons",
"font",
"cursor",
"terminal",
"terminalfont",
"cpu",
"gpu",
"memory",
"swap",
"disk",
"battery",
"poweradapter",
"locale"
]
}

18
misc/windows/neovide.toml Normal file
View file

@ -0,0 +1,18 @@
fork = false
frame = "full"
idle = true
maximized = false
no-multigrid = false
srgb = false
tabs = true
theme = "auto"
title-hidden = true
vsync = false
wsl = true
[font]
normal = [
"Iosevka Nerd Font",
"霞鹜文楷等宽",
] # Will use the bundled Fira Code Nerd Font by default
size = 14.0

82
misc/windows/readme.md Normal file
View file

@ -0,0 +1,82 @@
# Windows dotfiles
![Windows](../../_assets/windows-1.png)
- Terminal Emulator: [WezTerm](../../tools/wezterm/)
- Tiling Window Manager: [GlazeWM](./glzr/glazewm/config.yaml)
- Status Bar: [Zebar](./glzr/zebar/settings.json)
- Quake Terminal: [Windows Terminal](./WindowsTerminal.json)
- Shell: [PowerShell Core](../../tools/powershell/readme.md)
- WSL1: [Arch Linux](https://github.com/yuk7/ArchWSL)
- WSL2: kali-linux
By following the Windows Directory Standard, assign the following directories corresponding to `$XDG_CONFIG` in Unix, some of the software(like `wezterm`) will use these directories as the default configuration path:
| Windows Path | XDG-Equivalent | Default |
|------------|----------|----------|
| `%APPDATA%` | `$XDG_CONFIG_HOME` | `%USERPROFILE%\AppData\Roaming` |
| `%LOCALAPPDATA%` | `$XDG_DATA_HOME` | `%USERPROFILE%\AppData\Local` |
| `%LOCALAPPDATA%\Cache` | `$XDG_CACHE_HOME` | `%USERPROFILE%\AppData\Local\Cache` |
| `%LOCALAPPDATA%\State` | `$XDG_STATE_HOME` | `%USERPROFILE%\AppData\Local\State` |
An example bootstrap script is provided in [bootstrap/Windows.ps1](../../bootstrap/Windows.ps1), which will create necessary directories and link the files.
## PowerShell Profile
This is the *[PowerShell Core](https://github.com/PowerShell/PowerShell)* profile, not the legacy *Windows PowerShell* profile, which is faster(`powershell` vs `pwsh`, `pwsh` types 6 letters less lol), cross-platform and compatible with Unix.
By default, PowerShell profile is stored in `%UserProfile%\Documents\PowerShell\Microsoft.PowerShell_profile.ps1`.
It is convenient to use `$PROFILE` to locate the profile file.
```powershell
Test-Path $PROFILE
```
Just like Unix Shell, there are configs work for different sessions. To locate them, use `select *` followed by `$PROFILE`.
If you want to change the `AllUsers` scoped profile, do not install `pwsh` via `winget`, use `scoop` instead, since `winget` will install `pwsh` to `%ProgramFiles%\PowerShell\7\pwsh.exe`, which is read-only even with Administrator privileges.
```powershell
PS > $PROFILE | Select *
AllUsersAllHosts : C:\Users\jsony\scoop\apps\pwsh\current\profile.ps1
AllUsersCurrentHost : C:\Users\jsony\scoop\apps\pwsh\current\Microsoft.PowerShell_profile.ps1
CurrentUserAllHosts : C:\Users\jsony\Documents\PowerShell\profile.ps1
CurrentUserCurrentHost : C:\Users\jsony\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
Length : 68
```
Note that the variable `$PROFILE.*` are constants, the only way to change it is to compile your own `pwsh`
To link the profile file:
```powershell
New-Item -ItemType SymbolicLink -Path $PROFILE -Target "$DOTFILES\win\Microsoft.PowerShell_profile.ps1" -Force
```
I use [starship](https://starship.rs/) to customize the prompt, which is located in [`tools/starship/starship_pwsh.toml`](../../tools/starship/starship_pwsh.toml). This prompt config is cross-platform for powershell core, since I use the prompt to identify the shell.
## `.wslconfig` - WSL2 Configuration
`.wslconfig` only supports `%UserProfile%\.wslconfig` as the configuration path
```powershell
New-Item -ItemType SymbolicLink -Path "$Env:UserProfile\.wslconfig" -Target "$DOTFILES\win\.wslconfig" -Force
```
<!--
## Windows Terminal
Use Hard Link to sync Windows Terminal Settings since it doesn't support symlink.
```powershell
New-Item -ItemType HardLink -Path "$Env:LocalAppData\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json" -Target "$DOTFILES\win\WindowsTerminal.json" -Force
```
-->
## Neovide
Neovide configuration is (only) stored in `%APPDATA%\neovide\config.toml`
```powershell
New-Item -ItemType SymbolicLink -Path "$Env:AppData\neovide\config.toml" -Target "$DOTFILES\win\neovide.toml" -Force
```

View file

@ -0,0 +1,10 @@
if (Get-Command "kmonad" -ErrorAction SilentlyContinue) {
$KMonadPath = (Get-Command "kmonad").Source
}
else {
$KMonadPath = "D:\bin\kmonad.exe"
}
$KMonadConfig = "$Env:DOTFILES\tools\kmonad\windows.kbd"
Start-Process -FilePath $KMonadPath -ArgumentList $KMonadConfig -WindowStyle Hidden

45
misc/windows/vsvimrc Normal file
View file

@ -0,0 +1,45 @@
" This is the `vimrc` config for VSVim (Visual Studio Vim Emulator)
" Put it in %Vim%\.vsvimrc
" Colemak Keys
" Arrow remap
noremap n j
noremap e k
noremap i l
nnoremap N 5j
nnoremap E 5k
vnoremap H ^
xnoremap H ^
onoremap H ^
vnoremap I $
xnoremap I $
onoremap I $
" Similar position to i
noremap l i
noremap L I
" ne[k]st
noremap k n
noremap K N
" [j]ump
noremap j e
noremap J E
" Normal minimal setup
noremap Y y$
set expandtab
set tabstop=4
set shiftwidth=4
set autoindent
set smartindent
set wrap
set scrolloff=3
set hlsearch
set incsearch
set ignorecase
set smartcase
set number
set relativenumber