diff --git a/.gitignore b/.gitignore index ebfba8d..94ed0c3 100644 --- a/.gitignore +++ b/.gitignore @@ -49,5 +49,3 @@ common/fzfrc platforms/win/komorebi/applications.json gitconfig - -check_update diff --git a/bootstrap/win/Defender.ps1 b/bootstrap/win/Defender.ps1 index 007c5f1..8f3ad6b 100644 --- a/bootstrap/win/Defender.ps1 +++ b/bootstrap/win/Defender.ps1 @@ -3,8 +3,9 @@ Set-MpPreference -EnableControlledFolderAccess 1 $protected = (Get-MpPreference).ControlledFolderAccessProtectedFolders -$protected += "$env:USERPROFILE\.ssh" -$protected += "$env:USERPROFILE\.config" +$protected += "$Env:UserProfile\.ssh" +$protected += "$Env:UserProfile\.config" +$protected += "$Env:UserProfile\Vault" Set-MpPreference -ControlledFolderAccessProtectedFolders $protected $apps = (Get-MpPreference).ControlledFolderAccessAllowedApplications diff --git a/common/lesskey b/common/lesskey index 8eb0c4f..de66057 100644 --- a/common/lesskey +++ b/common/lesskey @@ -4,10 +4,12 @@ # Less the pager. # Location: -# $XDG_CONFIG_HOME/lesskey -# Or specified by the environment variable $LESSKEYIN +# *nix: $XDG_CONFIG_HOME/lesskey (Or specified by the environment variable $LESSKEYIN) +# Windows: %LESSKEYIN% (environment variable, default: %UserProfile%/_lesskey) +# $Env:LESSKEYIN = $Env:AppData\less\lesskey # Linking: # 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 # In Windows (current version), the default pager is `more`, should be specifed to `less` by `$Env:Pager = less` diff --git a/platforms/win/Microsoft.PowerShell_profile.ps1 b/platforms/win/Microsoft.PowerShell_profile.ps1 index 05b468a..ef8ee96 100644 --- a/platforms/win/Microsoft.PowerShell_profile.ps1 +++ b/platforms/win/Microsoft.PowerShell_profile.ps1 @@ -5,26 +5,13 @@ ### Load Configs ### $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 ### # Toggle Theme # -# TODO: Change to `bat` script implementation -# 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`) +Set-Alias "dark-mode" "$DOTFILES\platforms\win\cmd\dark-mode.bat" # Consistent with macOS (`dark-mode`) # Miscs # @@ -35,7 +22,7 @@ ${function:qwen} = "ollama run qwen2.5:14b" #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 + (& "$HOME\miniconda3\Scripts\conda.exe" "shell.powershell" "hook") | Out-String | Where-Object { $_ } | Invoke-Expression } #endregion @@ -67,10 +54,10 @@ $Env:VISUAL = "code --wait" $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:winr} = { winget uninstall $args } ${function:wins} = { winget search $args } ${function:winu} = { winget upgrade $args } -${function:killp} = {ps | ? ProcessName -like $args | kill -Force} +${function:pkill} = { ps *$args* | kill -Force } diff --git a/platforms/win/glzr/glazewm/config.yaml b/platforms/win/glzr/glazewm/config.yaml index 79984ea..69ea13c 100644 --- a/platforms/win/glzr/glazewm/config.yaml +++ b/platforms/win/glzr/glazewm/config.yaml @@ -53,14 +53,14 @@ gaps: scale_with_dpi: true # Gap between adjacent windows. - inner_gap: "20px" + inner_gap: "5px" # Gap between windows and the screen edge. outer_gap: - top: "60px" - right: "20px" - bottom: "20px" - left: "20px" + top: "50px" + right: "5px" + bottom: "5px" + left: "5px" window_effects: # Visual effects to apply to the focused window. @@ -69,7 +69,7 @@ window_effects: # ** Exclusive to Windows 11 due to API limitations. border: enabled: true - color: "#8dbcff" + color: "#f6a7ba" # Remove the title bar from the window's frame. Note that this can # cause rendering issues for some applications. @@ -86,10 +86,10 @@ window_effects: # Visual effects to apply to non-focused windows. other_windows: border: - enabled: true + enabled: false color: "#a1a1a1" hide_title_bar: - enabled: false + enabled: true corner_style: enabled: false style: "square" @@ -134,6 +134,7 @@ window_rules: match: # Ignores any Zebar windows. - window_process: { equals: "zebar" } + - window_process: { equals: "WindowsTerminal" } # Ignores picture-in-picture windows for browsers. - window_title: { regex: "[Pp]icture.in.[Pp]icture" } @@ -249,7 +250,7 @@ keybindings: # Launch CMD terminal. Alternatively, use `shell-exec wt` or # `shell-exec %ProgramFiles%/Git/git-bash.exe` to start Windows # Terminal and Git Bash respectively. - - commands: ["shell-exec wt"] + - commands: ["shell-exec wezterm-gui.exe start"] bindings: ["lwin+r"] # Focus the next/previous active workspace defined in `workspaces` config. diff --git a/readme.md b/readme.md index a71c2e8..6a4f444 100644 --- a/readme.md +++ b/readme.md @@ -2,6 +2,10 @@ 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 ```shell @@ -15,3 +19,13 @@ This repository contains dotfiles for multiple platforms, with _colemak_ as the ├──  scripts # Scripts for various tasks └──  tools # Multi-file configurations (shell, neovim etc) ``` + +## Keybindings + +``` + ^ + n + < h i > + e + v +``` diff --git a/tools/wezterm/.gitignore b/tools/wezterm/.gitignore new file mode 100644 index 0000000..604ed6b --- /dev/null +++ b/tools/wezterm/.gitignore @@ -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 diff --git a/tools/wezterm/wezterm.lua b/tools/wezterm/wezterm.lua index 3c8affb..62ddcae 100644 --- a/tools/wezterm/wezterm.lua +++ b/tools/wezterm/wezterm.lua @@ -1,121 +1,280 @@ --- $DOTFILES/tools\wezterm\wezterm.lua +-- $DOTFILES/tools/wezterm/wezterm.lua -- Date: 2024-12-22 -- Author: js0ny --- Location: --- $XDG_CONFIG_HOME/wezterm/wezterm.lua --- Linking: --- ln -sf $DOTFILES/tools/wezterm/wezterm.lua $XDG_CONFIG_HOME/wezterm/wezterm.lua - +--#region Import & Setup local wezterm = require 'wezterm' +local action = wezterm.action local config = {} +--#endregion -local os_type = "" -if package.config:sub(1,1) == "\\" then +--#region Helper +--[[ +local function detect_os() + local detected_os = "" + if package.config:sub(1, 1) == "\\" then -- Windows - os_type = "Windows" -elseif package.config:sub(1,1) == "/" then + detected_os = "Windows" + elseif package.config:sub(1, 1) == "/" then -- Unix-like (Linux, macOS, etc.) if os.getenv("HOME") then - os_type = "Unix-like" - -- You can differentiate further by checking for macOS or Linux if needed - if os.getenv("XDG_SESSION_TYPE") then - -- Likely Linux - os_type = "Linux" - elseif os.execute("uname -s | grep -i darwin") == 0 then - -- macOS - os_type = "macOS" - end + detected_os = "Unix-like" + -- You can differentiate further by checking for macOS or Linux if needed + if os.getenv("XDG_SESSION_TYPE") then + -- Likely Linux + detected_os = "Linux" + elseif os.execute("uname -s | grep -i darwin") == 0 then + -- macOS + detected_os = "macOS" + 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 -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 -config.font = wezterm.font("FiraCode Nerd Font") -config.color_scheme = "Ayu Mirage" +-- config.font = 'FiraCode Nerd Font' + +config.max_fps = 120 +config.font = wezterm.font({ + family = "CaskaydiaCove Nerd Font", +}) +config.color_scheme = "Catppuccin Frappe" config.font_size = 12.0 +config.front_end = "WebGpu" +config.webgpu_power_preference = "HighPerformance" if os_type == "Windows" then - config.window_background_opacity = 0.7 - config.win32_system_backdrop = 'Acrylic' + config.window_background_opacity = 0.7 -- Not working under WebGpu + config.win32_system_backdrop = "Mica" end -- Tab appearance config.hide_tab_bar_if_only_one_tab = 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 ------------------- -config.leader = { key="q", mods="CTRL" } +--#region Keybindings +config.leader = { key = "q", mods = "CTRL" } config.keys = { - { - key = 'q', - mods = 'LEADER', - action = wezterm.action.SendKey {key = 'q', mods = 'CTRL'}, - }, - -- Windows Management - { - key = '|', - mods = 'LEADER|SHIFT', - action = wezterm.action.SplitHorizontal{domain="CurrentPaneDomain"} - }, - { - key = '-', - mods = 'LEADER', - action = wezterm.action.SplitVertical{domain="CurrentPaneDomain"} - }, - { - key = 'h', - mods = 'LEADER', - action = wezterm.action.ActivatePaneDirection 'Left' - }, - { - key = 'n', - mods = 'LEADER', - action = wezterm.action.ActivatePaneDirection 'Down' - }, - { - key = 'e', - mods = 'LEADER', - action = wezterm.action.ActivatePaneDirection 'Up' - }, - { - key = 'i', - mods = 'LEADER', - action = wezterm.action.ActivatePaneDirection 'Right' - }, - { - key = 'H', - mods = 'LEADER', - action = wezterm.action.AdjustPaneSize { 'Left', 5 }, - }, - { - key = 'N', - mods = 'LEADER', - action = wezterm.action.AdjustPaneSize { 'Down', 5 }, - }, - { - key = 'E', - mods = 'LEADER', - action = wezterm.action.AdjustPaneSize { 'Up', 5 }, - }, - { - key = 'I', - mods = 'LEADER', - action = wezterm.action.AdjustPaneSize { 'Right', 5 }, - }, + { + key = 'q', + mods = 'LEADER', + action = action.SendKey { key = 'q', mods = 'CTRL' }, + }, + -- Windows Management + { -- leader keys + key = '|', + mods = 'LEADER|SHIFT', + action = action.SplitHorizontal { domain = "CurrentPaneDomain" } + }, + { + key = '-', + mods = 'LEADER', + action = action.SplitVertical { domain = "CurrentPaneDomain" } + }, + { + key = 'h', + mods = 'LEADER', + action = action.ActivatePaneDirection 'Left' + }, + { + key = 'n', + mods = 'LEADER', + action = action.ActivatePaneDirection 'Down' + }, + { + key = 'e', + mods = 'LEADER', + action = action.ActivatePaneDirection 'Up' + }, + { + key = 'i', + mods = 'LEADER', + action = action.ActivatePaneDirection 'Right' + }, + { + key = 'H', + mods = 'LEADER', + action = action.AdjustPaneSize { 'Left', 5 }, + }, + { + key = 'N', + mods = 'LEADER', + action = action.AdjustPaneSize { 'Down', 5 }, + }, + { + key = 'E', + mods = 'LEADER', + action = action.AdjustPaneSize { 'Up', 5 }, + }, + { + key = 'I', + mods = 'LEADER', + 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 ------------------- -if os_type == "Windows" then - config.default_prog = { "pwsh.exe" } -else - config.default_prog = { "fish" } -end +config.mouse_bindings = { + { + event = { Up = { streak = 1, button = 'Left' } }, + mods = 'CTRL', + action = action.OpenLinkAtMouseCursor, + }, + { + event = { Up = { streak = 1, button = 'Left' } }, + mods = 'SUPER', + action = action.OpenLinkAtMouseCursor, + }, +} +--#endregion + +--#region Environment 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