From e89c6941d38ac81d48afbf9f5f761c0a940f293f Mon Sep 17 00:00:00 2001 From: Anthony Cicchetti Date: Mon, 28 Oct 2024 15:25:30 -0400 Subject: [PATCH] wezterm mux? --- hammerspoon/init.lua | 6 +- nix/home-manager/flake.lock | 48 ++++++------- nix/home-manager/modules/packages/default.nix | 2 +- wezterm/wezterm.lua | 72 +++++++++++++++++++ 4 files changed, 100 insertions(+), 28 deletions(-) diff --git a/hammerspoon/init.lua b/hammerspoon/init.lua index 6414a06..df30a40 100644 --- a/hammerspoon/init.lua +++ b/hammerspoon/init.lua @@ -23,8 +23,9 @@ end) hs.hotkey.bind({ "ctrl" }, "t", function() terminal = nil for i = 1, #TERMINAL_NAMES do - if hs.application.get(TERMINAL_NAMES[i]) then - terminal = hs.application.get(TERMINAL_NAMES[i]) + -- Can't use .get here, as there's an open bug where it just… returns a window instead sometimes + if hs.application.find(TERMINAL_NAMES[i], true) then + terminal = hs.application.find(TERMINAL_NAMES[i], true) break end end @@ -37,7 +38,6 @@ hs.hotkey.bind({ "ctrl" }, "t", function() terminal:activate() end else - print(TERMINAL_NAMES[#TERMINAL_NAMES]) hs.application.launchOrFocus(TERMINAL_NAMES[#TERMINAL_NAMES]) end end) diff --git a/nix/home-manager/flake.lock b/nix/home-manager/flake.lock index 1cf950b..232b0e9 100644 --- a/nix/home-manager/flake.lock +++ b/nix/home-manager/flake.lock @@ -23,11 +23,11 @@ "rust-analyzer-src": "rust-analyzer-src" }, "locked": { - "lastModified": 1729375822, - "narHash": "sha256-bRo4xVwUhvJ4Gz+OhWMREFMdBOYSw4Yi1Apj01ebbug=", + "lastModified": 1730097176, + "narHash": "sha256-ufvRff76Y19mkRsmx+mAnxKE9A9VaNWC2mVY6TwumOw=", "owner": "nix-community", "repo": "fenix", - "rev": "2853e7d9b5c52a148a9fb824bfe4f9f433f557ab", + "rev": "482b57f3f27a9336e0fbc62fa99ee0f624ccf4d0", "type": "github" }, "original": { @@ -114,11 +114,11 @@ ] }, "locked": { - "lastModified": 1729459288, - "narHash": "sha256-gBOVJv+q6Mx8jGvwX7cE6J8+sZmi1uxpRVsO7WxvVuQ=", + "lastModified": 1730016908, + "narHash": "sha256-bFCxJco7d8IgmjfNExNz9knP8wvwbXU4s/d53KOK6U0=", "owner": "nix-community", "repo": "home-manager", - "rev": "1e27f213d77fc842603628bcf2df6681d7d08f7e", + "rev": "e83414058edd339148dc142a8437edb9450574c8", "type": "github" }, "original": { @@ -146,11 +146,11 @@ }, "miseNixPkgs": { "locked": { - "lastModified": 1729161044, - "narHash": "sha256-H3tzH48tGPj4ZzLX2m7bsBwvtzUR/yiynefahkc6C74=", + "lastModified": 1729718832, + "narHash": "sha256-2eVW2pvSSQuQw6AjgFhYCzneXDPme8KJE82DxUUmbKo=", "owner": "konradmalik", "repo": "nixpkgs", - "rev": "198957524ffeca414d2dc92e9cd6448a646a5e0b", + "rev": "5332c996ac4538b1c22935629a5641ff9b1cade7", "type": "github" }, "original": { @@ -204,11 +204,11 @@ ] }, "locked": { - "lastModified": 1729394935, - "narHash": "sha256-2ntUG+NJKdfhlrh/tF+jOU0fOesO7lm5ZZVSYitsvH8=", + "lastModified": 1729999765, + "narHash": "sha256-LYsavZXitFjjyETZoij8usXjTa7fa9AIF3Sk3MJSX+Y=", "owner": "Mic92", "repo": "nix-index-database", - "rev": "04f8a11f247ba00263b060fbcdc95484fd046104", + "rev": "0e3a8778c2ee218eff8de6aacf3d2fa6c33b2d4f", "type": "github" }, "original": { @@ -262,11 +262,11 @@ "poetry2nix": "poetry2nix" }, "locked": { - "lastModified": 1729434130, - "narHash": "sha256-0b23Ko4EcXHLrbZUK8Pd/oUGZQy9ulsg9g76DiIGW/s=", + "lastModified": 1730039146, + "narHash": "sha256-2NF6Wxl0s9rbl05aZcixw3uH6hks4DITGszZLhmj88g=", "owner": "NixNeovim", "repo": "NixNeovimPlugins", - "rev": "38d7b0a3dfc7d3cd247deeac13d6c4a17ae93c66", + "rev": "1e1e7f80868778ef820df27e28054eb6bf370c60", "type": "github" }, "original": { @@ -292,11 +292,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1729475264, - "narHash": "sha256-UomFmaokBHdzQcgagQEq09Dd5NJhKdn9+h92vyt04BQ=", + "lastModified": 1730123274, + "narHash": "sha256-kj/6VN+3i7Pwx/TzHTliUNBK0qAFg88mwVjkrBegydg=", "owner": "nixos", "repo": "nixpkgs", - "rev": "aca8144f8aeca1044ad6bc29ad9cae0bd12dfb19", + "rev": "9b2bdcc99abfd60ccac074cc63541f757d21ec43", "type": "github" }, "original": { @@ -397,11 +397,11 @@ "rust-analyzer-src": { "flake": false, "locked": { - "lastModified": 1729255720, - "narHash": "sha256-yODOuZxBkS0UfqMa6nmbqNbVfIbsu0tYLbV5vZzmsqI=", + "lastModified": 1730028316, + "narHash": "sha256-FsPsSjqnqMHBgDdM24DFLw4YOw0mFKYFJBcLaI6CvI8=", "owner": "rust-lang", "repo": "rust-analyzer", - "rev": "72b214fbfbe6f7b95a7877b962783bd42062cc0a", + "rev": "3b3a87fe9bd3f2a79942babc1d1e385b6805c384", "type": "github" }, "original": { @@ -508,11 +508,11 @@ "rust-overlay": "rust-overlay_2" }, "locked": { - "lastModified": 1728141581, - "narHash": "sha256-+wg0Avbw/MC2x3CQK4LyJHCPf+oPllJZzU2p+S/B7MU=", + "lastModified": 1729787428, + "narHash": "sha256-kGSM7b4+X5LObd6AdgQZABU241ZzHGm24xaiy33kwBI=", "owner": "dj95", "repo": "zjstatus", - "rev": "6d13e481aceacd3efe583fb6c442f30e8909f555", + "rev": "c74e310c35fb7ec6b59a1c73720db4d6d8e236a1", "type": "github" }, "original": { diff --git a/nix/home-manager/modules/packages/default.nix b/nix/home-manager/modules/packages/default.nix index 12b53f5..cfb6813 100644 --- a/nix/home-manager/modules/packages/default.nix +++ b/nix/home-manager/modules/packages/default.nix @@ -17,7 +17,7 @@ in { ]; home.packages = with pkgs; [ - _1password + _1password-cli # bandwhich bat bottom diff --git a/wezterm/wezterm.lua b/wezterm/wezterm.lua index d99a845..ca787cd 100644 --- a/wezterm/wezterm.lua +++ b/wezterm/wezterm.lua @@ -1,4 +1,5 @@ local wezterm = require("wezterm") +local act = wezterm.action -- Allow working with both the current release and the nightly local config = {} @@ -78,4 +79,75 @@ config.hide_tab_bar_if_only_one_tab = true config.front_end = "WebGpu" +-- Wezterm Mux +config.unix_domains = { { name = "unix" } } +config.default_gui_startup_args = { "connect", "unix" } + +-- Some keybinds… A lot of keybinds +local copy_mode = nil +if wezterm.gui then + copy_mode = wezterm.gui.default_key_tables().copy_mode + table.insert(copy_mode, { key = "k", mods = "CTRL", action = act.CopyMode({ MoveByPage = -0.5 }) }) + table.insert(copy_mode, { key = "j", mods = "CTRL", action = act.CopyMode({ MoveByPage = 0.5 }) }) +end +config.leader = { key = "a", mods = "CTRL", timeout_milliseconds = 1000 } +config.keys = { + { + key = "|", + mods = "LEADER|SHIFT", + action = act.SplitHorizontal({ domain = "CurrentPaneDomain" }), + }, + { + key = "a", + mods = "LEADER|CTRL", + action = act.SendKey({ key = "a", mods = "CTRL" }), + }, + { + key = "-", + mods = "LEADER", + action = act.SplitVertical({ domain = "CurrentPaneDomain" }), + }, + { + key = "n", + mods = "LEADER", + action = act.ActivateKeyTable({ + name = "manage_panes", + one_shot = false, + timeout_milliseconds = 5000, + until_unknown = true, + }), + }, + + { + key = "Escape", + mods = "LEADER", + action = act.ActivateCopyMode, + }, + { key = "Tab", mods = "LEADER", action = act.QuickSelect }, + { key = "c", mods = "LEADER", action = act.SpawnTab("CurrentPaneDomain") }, +} +config.key_tables = { + manage_panes = { + { key = "LeftArrow", action = act.AdjustPaneSize({ "Left", 1 }) }, + { key = "h", action = act.AdjustPaneSize({ "Left", 1 }) }, + { key = "h", mods = "SHIFT", action = act.ActivatePaneDirection("Left") }, + + { key = "RightArrow", action = act.AdjustPaneSize({ "Right", 1 }) }, + { key = "l", action = act.AdjustPaneSize({ "Right", 1 }) }, + { key = "l", mods = "SHIFT", action = act.ActivatePaneDirection("Right") }, + + { key = "UpArrow", action = act.AdjustPaneSize({ "Up", 1 }) }, + { key = "k", action = act.AdjustPaneSize({ "Up", 1 }) }, + { key = "k", mods = "SHIFT", action = act.ActivatePaneDirection("Up") }, + + { key = "DownArrow", action = act.AdjustPaneSize({ "Down", 1 }) }, + { key = "j", action = act.AdjustPaneSize({ "Down", 1 }) }, + { key = "j", mods = "SHIFT", action = act.ActivatePaneDirection("Down") }, + + -- Cancel the mode by pressing escape + { key = "Escape", action = "PopKeyTable" }, + }, + copy_mode = copy_mode, +} + return config