This commit is contained in:
js0ny 2025-01-07 22:19:11 +00:00
commit c5292ac9de
16 changed files with 513 additions and 151 deletions

2
.gitignore vendored
View file

@ -50,4 +50,4 @@ platforms/win/komorebi/applications.json
gitconfig gitconfig
check_update *.exe

BIN
_assets/windows-1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

View file

@ -35,8 +35,8 @@ if ($currentPath -notlike "*%PATH_EXT%*") {
# Simulate XDG Base Directory Specification # Simulate XDG Base Directory Specification
$Env:XDG_CONFIG_HOME = "$Env:AppData" $Env:XDG_CONFIG_HOME = "$Env:AppData"
$Env:XDG_DATA_HOME = "$Env:LocalAppData" $Env:XDG_DATA_HOME = "$Env:LocalAppData"
$Env:XDG_CACHE_HOME = "$Env:LocalAppData\cache" $Env:XDG_CACHE_HOME = "$Env:LocalAppData\Cache"
$Env:XDG_STATE_HOME = "$Env:LocalAppData\state" $Env:XDG_STATE_HOME = "$Env:LocalAppData\State"
[System.Environment]::SetEnvironmentVariable("XDG_CONFIG_HOME", "$Env:XDG_CONFIG_HOME", "User") [System.Environment]::SetEnvironmentVariable("XDG_CONFIG_HOME", "$Env:XDG_CONFIG_HOME", "User")
[System.Environment]::SetEnvironmentVariable("XDG_DATA_HOME", "$Env:XDG_DATA_HOME", "User") [System.Environment]::SetEnvironmentVariable("XDG_DATA_HOME", "$Env:XDG_DATA_HOME", "User")
New-Item -ItemType Directory -Path "$Env:LocalAppData\cache" -Force New-Item -ItemType Directory -Path "$Env:LocalAppData\cache" -Force

View file

@ -3,14 +3,17 @@
Set-MpPreference -EnableControlledFolderAccess 1 Set-MpPreference -EnableControlledFolderAccess 1
$protected = (Get-MpPreference).ControlledFolderAccessProtectedFolders $protected = (Get-MpPreference).ControlledFolderAccessProtectedFolders
$protected += "$env:USERPROFILE\.ssh" $protected += "$Env:UserProfile\.ssh"
$protected += "$env:USERPROFILE\.config" $protected += "$Env:UserProfile\.config"
$protected += "$Env:UserProfile\Vault"
Set-MpPreference -ControlledFolderAccessProtectedFolders $protected Set-MpPreference -ControlledFolderAccessProtectedFolders $protected
$apps = (Get-MpPreference).ControlledFolderAccessAllowedApplications $apps = (Get-MpPreference).ControlledFolderAccessAllowedApplications
$apps += "$Env:Windir\System32\OpenSSH\ssh.exe" $apps += "$Env:Windir\System32\OpenSSH\ssh.exe"
$apps += "$Env:ProgramFiles\GPSoftware\Directory Opus\DOpus.exe" $apps += "$Env:ProgramFiles\GPSoftware\Directory Opus\DOpus.exe"
$apps += "$Env:UserProfile\scoop\apps\pwsh\current\pwsh.exe" $apps += (Get-Command -Name code).Source.Replace("bin\code.cmd", "Code.exe")
$apps += (Get-Command -Name pwsh).Source
$apps += (Get-Command -Name git).Source
Set-MpPreference -ControlledFolderAccessAllowedApplications $apps Set-MpPreference -ControlledFolderAccessAllowedApplications $apps
$exclusion = (Get-MpPreference).ExclusionPath $exclusion = (Get-MpPreference).ExclusionPath

View file

@ -4,10 +4,12 @@
# Less the pager. # Less the pager.
# Location: # Location:
# $XDG_CONFIG_HOME/lesskey # *nix: $XDG_CONFIG_HOME/lesskey (Or specified by the environment variable $LESSKEYIN)
# Or specified by the environment variable $LESSKEYIN # Windows: %LESSKEYIN% (environment variable, default: %UserProfile%/_lesskey)
# $Env:LESSKEYIN = $Env:AppData\less\lesskey
# Linking: # Linking:
# ln -sf $DOTFILES/common/lesskey ~/.config/lesskey # ln -sf $DOTFILES/common/lesskey ~/.config/lesskey
# New-Item -ItemType SymbolicLink -Target $DOTFILES\common\lesskey -Path $Env:LESSKEYIN
# =========================================================== # ===========================================================
# work for less -V > 582, for mac, use brew install less to override the system less # work for less -V > 582, for mac, use brew install less to override the system less
# In Windows (current version), the default pager is `more`, should be specifed to `less` by `$Env:Pager = less` # In Windows (current version), the default pager is `more`, should be specifed to `less` by `$Env:Pager = less`

View file

@ -5,26 +5,13 @@
### Load Configs ### ### Load Configs ###
$DOTFILES = Join-Path $HOME ".dotfiles" $DOTFILES = Join-Path $HOME ".dotfiles"
Get-ChildItem -Path $(Join-Path $DOTFILES "tools" "powershell") -Filter *.ps1 | ForEach-Object {. $_} Get-ChildItem -Path $(Join-Path $DOTFILES "tools" "powershell") -Filter *.ps1 | ForEach-Object { . $_ }
### Aliases ### ### Aliases ###
# Toggle Theme # # Toggle Theme #
# TODO: Change to `bat` script implementation Set-Alias "dark-mode" "$DOTFILES\platforms\win\cmd\dark-mode.bat" # Consistent with macOS (`dark-mode`)
# function Set-SystemTheme {
# $regPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize"
# $currentMode = Get-ItemProperty -Path $regPath -Name "AppsUseLightTheme"
# if ($currentMode.AppsUseLightTheme -eq 1) {
# Set-ItemProperty -Path $regPath -Name "AppsUseLightTheme" -Value 0
# Write-Host "已切换到深色模式"
# }
# else {
# Set-ItemProperty -Path $regPath -Name "AppsUseLightTheme" -Value 1
# Write-Host "已切换到浅色模式"
# }
# }
# Set-Alias "dark-mode" "Set-SystemTheme" # Consistent with macOS (`dark-mode`)
# Miscs # # Miscs #
@ -35,7 +22,7 @@ ${function:qwen} = "ollama run qwen2.5:14b"
#region conda initialize #region conda initialize
# !! Contents within this block are managed by 'conda init' !! # !! Contents within this block are managed by 'conda init' !!
If (Test-Path "$HOME\miniconda3\Scripts\conda.exe") { If (Test-Path "$HOME\miniconda3\Scripts\conda.exe") {
(& "$HOME\miniconda3\Scripts\conda.exe" "shell.powershell" "hook") | Out-String | Where-Object{$_} | Invoke-Expression (& "$HOME\miniconda3\Scripts\conda.exe" "shell.powershell" "hook") | Out-String | Where-Object { $_ } | Invoke-Expression
} }
#endregion #endregion
@ -67,10 +54,10 @@ $Env:VISUAL = "code --wait"
$Env:FILE_MANAGER = "dopus.exe" $Env:FILE_MANAGER = "dopus.exe"
${function:wsl2} = {wsl.exe --distribution Ubuntu} ${function:wsl2} = { wsl.exe --distribution kali-linux $args }
${function:wini} = { winget install $args } ${function:wini} = { winget install $args }
${function:winr} = { winget uninstall $args } ${function:winr} = { winget uninstall $args }
${function:wins} = { winget search $args } ${function:wins} = { winget search $args }
${function:winu} = { winget upgrade $args } ${function:winu} = { winget upgrade $args }
${function:killp} = {ps | ? ProcessName -like $args | kill -Force} ${function:pkill} = { ps *$args* | kill -Force }

114
platforms/win/ahk/Caps.ahk Normal file
View file

@ -0,0 +1,114 @@
#Requires AutoHotkey v2.0
#SingleInstance Force
; 全局变量声明
global g_LastCtrlKeyDownTime := 0
global g_AbortSendEsc := false
global g_ControlRepeatDetected := false
*CapsLock:: {
global g_ControlRepeatDetected
global g_LastCtrlKeyDownTime
global g_AbortSendEsc
if (g_ControlRepeatDetected) {
return
}
Send "{Ctrl down}"
g_LastCtrlKeyDownTime := A_TickCount
g_AbortSendEsc := false
g_ControlRepeatDetected := true
}
*CapsLock Up:: {
global g_ControlRepeatDetected
global g_LastCtrlKeyDownTime
global g_AbortSendEsc
Send "{Ctrl up}"
g_ControlRepeatDetected := false
if (g_AbortSendEsc) {
return
}
current_time := A_TickCount
time_elapsed := current_time - g_LastCtrlKeyDownTime
if (time_elapsed <= 250) {
SendInput "{Esc}"
}
}
; 组合所有 Ctrl 快捷键
#HotIf
~*^a::
~*^b::
~*^c::
~*^d::
~*^e::
~*^f::
~*^g::
~*^h::
~*^i::
~*^j::
~*^k::
~*^l::
~*^m::
~*^n::
~*^o::
~*^p::
~*^q::
~*^r::
~*^s::
~*^t::
~*^u::
~*^v::
~*^w::
~*^x::
~*^y::
~*^z::
~*^1::
~*^2::
~*^3::
~*^4::
~*^5::
~*^6::
~*^7::
~*^8::
~*^9::
~*^0::
~*^Space::
~*^Backspace::
~*^Delete::
~*^Insert::
~*^Home::
~*^End::
~*^PgUp::
~*^PgDn::
~*^Tab::
~*^Enter::
~*^,::
~*^.::
~*^/::
~*^;::
~*^'::
~*^[::
~*^]::
~*^\::
~*^-::
~*^=::
~*^`::
~*^F1::
~*^F2::
~*^F3::
~*^F4::
~*^F5::
~*^F6::
~*^F7::
~*^F8::
~*^F9::
~*^F10::
~*^F11::
~*^F12:: {
global g_AbortSendEsc
g_AbortSendEsc := true
}

View file

@ -0,0 +1,29 @@
#Requires AutoHotkey v2.0
q::q
w::w
e::f
r::p
t::g
y::j
u::l
i::u
o::y
p::;
a::a
s::r
d::s
f::t
g::d
h::h
j::n
k::e
l::i
`;::o
z::z
x::x
c::c
v::v
b::b
n::k
m::m

View file

@ -54,7 +54,6 @@
"memory", "memory",
"swap", "swap",
"disk", "disk",
"localip",
"battery", "battery",
"poweradapter", "poweradapter",
"locale" "locale"

View file

@ -53,14 +53,14 @@ gaps:
scale_with_dpi: true scale_with_dpi: true
# Gap between adjacent windows. # Gap between adjacent windows.
inner_gap: "20px" inner_gap: "5px"
# Gap between windows and the screen edge. # Gap between windows and the screen edge.
outer_gap: outer_gap:
top: "60px" top: "50px"
right: "20px" right: "5px"
bottom: "20px" bottom: "5px"
left: "20px" left: "5px"
window_effects: window_effects:
# Visual effects to apply to the focused window. # Visual effects to apply to the focused window.
@ -69,7 +69,7 @@ window_effects:
# ** Exclusive to Windows 11 due to API limitations. # ** Exclusive to Windows 11 due to API limitations.
border: border:
enabled: true enabled: true
color: "#8dbcff" color: "#f6a7ba"
# Remove the title bar from the window's frame. Note that this can # Remove the title bar from the window's frame. Note that this can
# cause rendering issues for some applications. # cause rendering issues for some applications.
@ -86,10 +86,10 @@ window_effects:
# Visual effects to apply to non-focused windows. # Visual effects to apply to non-focused windows.
other_windows: other_windows:
border: border:
enabled: true enabled: false
color: "#a1a1a1" color: "#a1a1a1"
hide_title_bar: hide_title_bar:
enabled: false enabled: true
corner_style: corner_style:
enabled: false enabled: false
style: "square" style: "square"
@ -134,6 +134,7 @@ window_rules:
match: match:
# Ignores any Zebar windows. # Ignores any Zebar windows.
- window_process: { equals: "zebar" } - window_process: { equals: "zebar" }
- window_process: { equals: "WindowsTerminal" }
# Ignores picture-in-picture windows for browsers. # Ignores picture-in-picture windows for browsers.
- window_title: { regex: "[Pp]icture.in.[Pp]icture" } - window_title: { regex: "[Pp]icture.in.[Pp]icture" }
@ -223,7 +224,9 @@ keybindings:
bindings: ["lwin+t"] bindings: ["lwin+t"]
# Change the focused window to be fullscreen. # Change the focused window to be fullscreen.
- commands: ["toggle-fullscreen"] # - commands: ["toggle-fullscreen"]
# bindings: ["lwin+f"]
- commands: ["shell-exec dopus.exe"]
bindings: ["lwin+f"] bindings: ["lwin+f"]
# Minimize focused window. # Minimize focused window.
@ -249,7 +252,7 @@ keybindings:
# Launch CMD terminal. Alternatively, use `shell-exec wt` or # Launch CMD terminal. Alternatively, use `shell-exec wt` or
# `shell-exec %ProgramFiles%/Git/git-bash.exe` to start Windows # `shell-exec %ProgramFiles%/Git/git-bash.exe` to start Windows
# Terminal and Git Bash respectively. # Terminal and Git Bash respectively.
- commands: ["shell-exec wt"] - commands: ["shell-exec wezterm-gui.exe start"]
bindings: ["lwin+r"] bindings: ["lwin+r"]
# Focus the next/previous active workspace defined in `workspaces` config. # Focus the next/previous active workspace defined in `workspaces` config.

View file

@ -8,6 +8,20 @@ New-Item -ItemType SymbolicLink -Path $Env:UserProfile\.glzr -Target $DOTFILES\p
The Zebar config should be downloaded from [this repository](https://github.com/js0ny/neobrutal-zebar) and extracted to the `glzr\zebar` directory. The Zebar config should be downloaded from [this repository](https://github.com/js0ny/neobrutal-zebar) and extracted to the `glzr\zebar` directory.
```powershell
Invoke-WebRequest -Uri "https://github.com/js0ny/neobrutal-zebar/releases/download/2/neobrutal.zip" -OutFile "$Env:UserProfile\.glzr\zebar\neobrutal.zip"
Expand-Archive -Path "$Env:UserProfile\.glzr\zebar\neobrutal.zip" -DestinationPath "$Env:UserProfile\.glzr\zebar"
Remove-Item -Path "$Env:UserProfile\.glzr\zebar\neobrutal.zip"
```
If `just` and `pwsh` are installed, you can build the config by running `just build-zebar`.
```powershell
git clone https://github.com/js0ny/neobrutal-zebar.git --depth 1
just init
just build
```
Or use the minimal setup, by changing `glzr\zebar\settings.json`: `startupConfigs.path` to `minimal/bar.zebar.json`. Or use the minimal setup, by changing `glzr\zebar\settings.json`: `startupConfigs.path` to `minimal/bar.zebar.json`.
```json ```json
@ -21,9 +35,3 @@ Or use the minimal setup, by changing `glzr\zebar\settings.json`: `startupConfig
] ]
} }
``` ```
```powershell
Invoke-WebRequest -Uri "https://github.com/js0ny/neobrutal-zebar/releases/download/2/neobrutal.zip" -OutFile "$Env:UserProfile\.glzr\zebar\neobrutal.zip"
Expand-Archive -Path "$Env:UserProfile\.glzr\zebar\neobrutal.zip" -DestinationPath "$Env:UserProfile\.glzr\zebar"
Remove-Item -Path "$Env:UserProfile\.glzr\zebar\neobrutal.zip"
```

View file

@ -1,50 +1,82 @@
# Windows dotfiles # Windows dotfiles
By following the Windows Directory Standard, assign the following directories corresponding to `$XDG_CONFIG` in Unix: ![Windows](../../_assets/windows-1.png)
- `%APPDATA%` - `$XDG_CONFIG_HOME` (default: `%USERPROFILE%\AppData\Roaming`) - 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 ## PowerShell Profile
This is the *[PowerShell Core](https://github.com/PowerShell/PowerShell)* profile, not the legacy *Windows 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 `~\Documents\PowerShell\Microsoft.PowerShell_profile.ps1`. 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. It is convenient to use `$PROFILE` to locate the profile file.
```pwsh ```powershell
Test-Path $PROFILE 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: To link the profile file:
```pwsh ```powershell
New-Item -ItemType SymbolicLink -Path $PROFILE -Target "$DOTFILES\win\Microsoft.PowerShell_profile.ps1" -Force 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 [`.dotfiles/.config/starship/starship_pwsh.toml`](../.config/starship/starship_pwsh.toml). This prompt config is cross-platform for powershell core, since I use the promp to identify the shell. 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` - WSL Configuration ## `.wslconfig` - WSL2 Configuration
`.wslconfig` only supports `~/.wslconfig` as the configuration path `.wslconfig` only supports `%UserProfile%\.wslconfig` as the configuration path
```pwsh ```powershell
New-Item -ItemType SymbolicLink -Path "~\.wslconfig" -Target "$DOTFILES\win\.wslconfig" -Force New-Item -ItemType SymbolicLink -Path "$Env:UserProfile\.wslconfig" -Target "$DOTFILES\win\.wslconfig" -Force
``` ```
<!--
## Windows Terminal ## Windows Terminal
Use Hard Link to sync Windows Terminal Settings since it doesn't support symlink. Use Hard Link to sync Windows Terminal Settings since it doesn't support symlink.
```pwsh ```powershell
New-Item -ItemType HardLink -Path "$Env:LocalAppData\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json" -Target "$DOTFILES\win\WindowsTerminal.json" -Force New-Item -ItemType HardLink -Path "$Env:LocalAppData\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json" -Target "$DOTFILES\win\WindowsTerminal.json" -Force
``` ```
-->
## Neovide ## Neovide
Neovide configuration is (only) stored in `%APPDATA%\neovide\config.toml` Neovide configuration is (only) stored in `%APPDATA%\neovide\config.toml`
```pwsh ```powershell
New-Item -ItemType SymbolicLink -Path "$Env:AppData\neovide\config.toml" -Target "$DOTFILES\win\neovide.toml" -Force New-Item -ItemType SymbolicLink -Path "$Env:AppData\neovide\config.toml" -Target "$DOTFILES\win\neovide.toml" -Force
``` ```

View file

@ -2,6 +2,10 @@
This repository contains dotfiles for multiple platforms, with _colemak_ as the default keyboard layout. This repository contains dotfiles for multiple platforms, with _colemak_ as the default keyboard layout.
No rice, no Unixporn/NTporn, just a simple setup that works for me.
Works for Windows, Linux and MacOS.
## Structure ## Structure
```shell ```shell
@ -15,3 +19,13 @@ This repository contains dotfiles for multiple platforms, with _colemak_ as the
├──  scripts # Scripts for various tasks ├──  scripts # Scripts for various tasks
└──  tools # Multi-file configurations (shell, neovim etc) └──  tools # Multi-file configurations (shell, neovim etc)
``` ```
## Keybindings
```
^
n
< h i >
e
v
```

View file

@ -41,6 +41,6 @@ if command -v winget.exe > /dev/null; then
fi fi
# macOS - Rime # macOS - Rime
if [ $(uname) = "Darwin"]; then if [ $(uname) = "Darwin" ]; then
bash ~/plum/rime-install bash ~/plum/rime-install
fi fi

12
tools/wezterm/.gitignore vendored Normal file
View file

@ -0,0 +1,12 @@
# $DOTFILES/tools/wezterm/
# Date: 2025-01-06
# Author: js0ny
# Location:
# $XDG_CONFIG_HOME/wezterm/wezterm.lua (works Windows)
# Linking: Link the whole directory
# ln -sf $DOTFILES/tools/wezterm $XDG_CONFIG_HOME/wezterm
# New-Item -ItemType SymbolicLink -Target $DOTFILES\tools\wezterm -Path $Env:XDG_CONFIG_HOME\wezterm
*.json
check_update

View file

@ -1,121 +1,280 @@
-- $DOTFILES/tools\wezterm\wezterm.lua -- $DOTFILES/tools/wezterm/wezterm.lua
-- Date: 2024-12-22 -- Date: 2024-12-22
-- Author: js0ny -- Author: js0ny
-- Location: --#region Import & Setup
-- $XDG_CONFIG_HOME/wezterm/wezterm.lua
-- Linking:
-- ln -sf $DOTFILES/tools/wezterm/wezterm.lua $XDG_CONFIG_HOME/wezterm/wezterm.lua
local wezterm = require 'wezterm' local wezterm = require 'wezterm'
local action = wezterm.action
local config = {} local config = {}
--#endregion
local os_type = "" --#region Helper
if package.config:sub(1,1) == "\\" then --[[
local function detect_os()
local detected_os = ""
if package.config:sub(1, 1) == "\\" then
-- Windows -- Windows
os_type = "Windows" detected_os = "Windows"
elseif package.config:sub(1,1) == "/" then elseif package.config:sub(1, 1) == "/" then
-- Unix-like (Linux, macOS, etc.) -- Unix-like (Linux, macOS, etc.)
if os.getenv("HOME") then if os.getenv("HOME") then
os_type = "Unix-like" detected_os = "Unix-like"
-- You can differentiate further by checking for macOS or Linux if needed -- You can differentiate further by checking for macOS or Linux if needed
if os.getenv("XDG_SESSION_TYPE") then if os.getenv("XDG_SESSION_TYPE") then
-- Likely Linux -- Likely Linux
os_type = "Linux" detected_os = "Linux"
elseif os.execute("uname -s | grep -i darwin") == 0 then elseif os.execute("uname -s | grep -i darwin") == 0 then
-- macOS -- macOS
os_type = "macOS" detected_os = "macOS"
end end
end end
end
return detected_os
end
--]]
--[[
wezterm.on("text-selection-callback", function(window, pane)
local text = window:get_selection_text_for_pane(pane)
end)
--]]
local function detect_os()
local os_type = ""
if wezterm.target_triple == "x86_64-pc-windows-msvc" then
os_type = "Windows"
elseif wezterm.target_triple == "x86_64-unknown-linux-gnu" then
os_type = "Linux"
elseif wezterm.target_triple == "aarch64-apple-darwin" then
os_type = "macOS"
end
return os_type
end end
print("[DEBUG] Detected OS: " .. os_type) -- OS light/dark theme detection
local function detect_theme()
end
--#endregion
--#region Constant
local os_type = detect_os()
--#endregion
-- Appearance --#region Appearance
------------------
-- Font and color scheme -- Font and color scheme
config.font = wezterm.font("FiraCode Nerd Font") -- config.font = 'FiraCode Nerd Font'
config.color_scheme = "Ayu Mirage"
config.max_fps = 120
config.font = wezterm.font({
family = "CaskaydiaCove Nerd Font",
})
config.color_scheme = "Catppuccin Frappe"
config.font_size = 12.0 config.font_size = 12.0
config.front_end = "WebGpu"
config.webgpu_power_preference = "HighPerformance"
if os_type == "Windows" then if os_type == "Windows" then
config.window_background_opacity = 0.7 config.window_background_opacity = 0.7 -- Not working under WebGpu
config.win32_system_backdrop = 'Acrylic' config.win32_system_backdrop = "Mica"
end end
-- Tab appearance -- Tab appearance
config.hide_tab_bar_if_only_one_tab = true config.hide_tab_bar_if_only_one_tab = true
config.tab_bar_at_bottom = true config.tab_bar_at_bottom = true
-- Cursor
-- config.animation_fps = 120
-- config.cursor_blink_ease_in = 'EaseOut'
-- config.cursor_blink_ease_out = 'EaseOut'
-- config.default_cursor_style = 'BlinkingBlock'
-- config.cursor_blink_rate = 650
-- Visual Bell
config.visual_bell = {
fade_in_function = 'EaseIn',
fade_in_duration_ms = 250,
fade_out_function = 'EaseOut',
fade_out_duration_ms = 250,
target = 'CursorColor',
}
--#endregion
-- Keybindings --#region Keybindings
------------------ config.leader = { key = "q", mods = "CTRL" }
config.leader = { key="q", mods="CTRL" }
config.keys = { config.keys = {
{ {
key = 'q', key = 'q',
mods = 'LEADER', mods = 'LEADER',
action = wezterm.action.SendKey {key = 'q', mods = 'CTRL'}, action = action.SendKey { key = 'q', mods = 'CTRL' },
}, },
-- Windows Management -- Windows Management
{ { -- leader keys
key = '|', key = '|',
mods = 'LEADER|SHIFT', mods = 'LEADER|SHIFT',
action = wezterm.action.SplitHorizontal{domain="CurrentPaneDomain"} action = action.SplitHorizontal { domain = "CurrentPaneDomain" }
}, },
{ {
key = '-', key = '-',
mods = 'LEADER', mods = 'LEADER',
action = wezterm.action.SplitVertical{domain="CurrentPaneDomain"} action = action.SplitVertical { domain = "CurrentPaneDomain" }
}, },
{ {
key = 'h', key = 'h',
mods = 'LEADER', mods = 'LEADER',
action = wezterm.action.ActivatePaneDirection 'Left' action = action.ActivatePaneDirection 'Left'
}, },
{ {
key = 'n', key = 'n',
mods = 'LEADER', mods = 'LEADER',
action = wezterm.action.ActivatePaneDirection 'Down' action = action.ActivatePaneDirection 'Down'
}, },
{ {
key = 'e', key = 'e',
mods = 'LEADER', mods = 'LEADER',
action = wezterm.action.ActivatePaneDirection 'Up' action = action.ActivatePaneDirection 'Up'
}, },
{ {
key = 'i', key = 'i',
mods = 'LEADER', mods = 'LEADER',
action = wezterm.action.ActivatePaneDirection 'Right' action = action.ActivatePaneDirection 'Right'
}, },
{ {
key = 'H', key = 'H',
mods = 'LEADER', mods = 'LEADER',
action = wezterm.action.AdjustPaneSize { 'Left', 5 }, action = action.AdjustPaneSize { 'Left', 5 },
}, },
{ {
key = 'N', key = 'N',
mods = 'LEADER', mods = 'LEADER',
action = wezterm.action.AdjustPaneSize { 'Down', 5 }, action = action.AdjustPaneSize { 'Down', 5 },
}, },
{ {
key = 'E', key = 'E',
mods = 'LEADER', mods = 'LEADER',
action = wezterm.action.AdjustPaneSize { 'Up', 5 }, action = action.AdjustPaneSize { 'Up', 5 },
}, },
{ {
key = 'I', key = 'I',
mods = 'LEADER', mods = 'LEADER',
action = wezterm.action.AdjustPaneSize { 'Right', 5 }, action = action.AdjustPaneSize { 'Right', 5 },
}, },
{
key = "/",
mods = "LEADER",
action = action.Search { Regex = "" }
},
{
key = "?",
mods = "LEADER|SHIFT",
action = action.Search { CaseSensitiveString = "" }
},
{
key = ";",
mods = "LEADER",
action = action.ShowLauncher
},
{
key = ":",
mods = "LEADER|SHIFT",
action = action.ActivateCommandPalette
},
{
key = "W",
mods = "CTRL",
action = action.CloseCurrentPane { confirm = true }
},
{ -- ^C to copy if selection is active, otherwise send signal
-- https://wezfurlong.org/wezterm/config/lua/keyassignment/ClearSelection.html?h=selection
key = 'c',
mods = 'CTRL',
action = wezterm.action_callback(function(window, pane)
local has_selection = window:get_selection_text_for_pane(pane) ~= ''
if has_selection then
window:perform_action(action.CopyTo 'ClipboardAndPrimarySelection', pane)
window:perform_action(action.ClearSelection, pane)
else
window:perform_action(action.SendKey { key = 'c', mods = 'CTRL' }, pane)
end
end),
},
} }
-- Environment config.mouse_bindings = {
------------------ {
if os_type == "Windows" then event = { Up = { streak = 1, button = 'Left' } },
config.default_prog = { "pwsh.exe" } mods = 'CTRL',
else action = action.OpenLinkAtMouseCursor,
config.default_prog = { "fish" } },
end {
event = { Up = { streak = 1, button = 'Left' } },
mods = 'SUPER',
action = action.OpenLinkAtMouseCursor,
},
}
--#endregion
--#region Environment
config.set_environment_variables = { config.set_environment_variables = {
WEZTERM="true", WEZTERM = "true", -- for `icat`
} }
--#endregion
--#region Launching
if os_type == "Windows" then
config.default_prog = { "pwsh.exe", "-NoLogo", "-NoProfileLoadTime" }
config.launch_menu = {
{
label = "Local - PowerShell",
args = { "pwsh.exe", "-NoLogo", "-NoProfileLoadTime" }
},
{
label = "Local - PowerShell Administator",
args = { "sudo.exe", "pwsh.exe", "-NoLogo", "-NoProfileLoadTime" }
},
{
label = "WSL1 - Arch",
args = { "wsl.exe", "-d", "Arch" }
},
{
label = "WSL2 - kali-linux",
args = { "wsl.exe", "-d", "kali-linux" }
},
{
label = "Local - NuShell",
args = { "nu" }
},
{
label = "Local - Windows PowerShell",
args = { "powershell.exe" }
},
{
label = "Local - Command Prompt",
args = { "cmd.exe" }
},
{
label = "WSL1 - Arch Zsh",
args = { "wsl.exe", "-d", "Arch", "zsh" }
},
}
else
config.default_prog = { "fish" }
config.launch_menu = {
{
label = "Local - Fish",
args = { "fish", "-l" }
},
{
label = "Local - Zsh",
args = { "zsh", "-l" }
},
{
label = "Local - PowerShell",
args = { "pwsh", "-NoLogo", "-NoProfileLoadTime", "-Login" }
},
{
label = "Local - NuShell",
args = { "nu", "-l" }
},
}
end
--#endregion
return config return config