Skip to content

Commit c6885bb

Browse files
committed
initial commit
0 parents  commit c6885bb

File tree

5 files changed

+189
-0
lines changed

5 files changed

+189
-0
lines changed

dev-shell.nix

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{ mkShell, wezterm, wez-tmux, writeTextFile }:
2+
3+
let
4+
config = writeTextFile {
5+
name = "wez-tmux-dev-shell-config.lua";
6+
text = ''
7+
package.path = package.path .. ";${wez-tmux}/?.lua"
8+
9+
local wezterm = require("wezterm")
10+
11+
local config = {}
12+
13+
if wezterm.config_builder then
14+
config = wezterm.config_builder()
15+
end
16+
17+
config.leader = { key = "b", mods = "CTRL" }
18+
19+
require("plugin").apply_to_config(config, {})
20+
21+
return config
22+
'';
23+
};
24+
in
25+
mkShell {
26+
name = "wez-tmux-dev-shell";
27+
28+
packages = [ wezterm ];
29+
30+
shellHook = ''
31+
alias wezterm="wezterm --config-file ${config}"
32+
'';
33+
}

flake.lock

+61
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
inputs = {
3+
flake-utils.url = "github:numtide/flake-utils";
4+
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6+
};
7+
8+
outputs = { self, flake-utils, nixpkgs }:
9+
let
10+
inherit (flake-utils.lib) eachDefaultSystem;
11+
in
12+
eachDefaultSystem (system:
13+
let
14+
pkgs = import nixpkgs { inherit system; };
15+
wez-tmux = pkgs.callPackage ./package.nix { };
16+
in
17+
{
18+
packages = { default = wez-tmux; };
19+
20+
devShells = {
21+
default = pkgs.callPackage ./dev-shell.nix {
22+
inherit wez-tmux;
23+
};
24+
};
25+
});
26+
}

package.nix

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{ lib, stdenv }:
2+
3+
stdenv.mkDerivation {
4+
name = "wez-tmux";
5+
6+
src = ./.;
7+
8+
dontBuild = true;
9+
10+
installPhase = ''
11+
cp -r plugin $out;
12+
'';
13+
}

plugin/init.lua

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
local M = {}
2+
3+
local wezterm = require("wezterm")
4+
local act = wezterm.action
5+
6+
---@param config unknown
7+
---@param opts { leader: { key: string, mods: string? }? }
8+
function M.apply_to_config(config, opts)
9+
local leader = opts.leader or { key = "b", mods = "CTRL" }
10+
11+
config.leader = leader
12+
13+
local keys = {
14+
{ key = leader.key, mods = "LEADER|" .. leader.mods, action = act.SendKey(leader) },
15+
16+
-- Tabs
17+
{ key = "c", mods = "LEADER", action = act.SpawnTab("CurrentPaneDomain") },
18+
{ key = "&", mods = "LEADER", action = act.CloseCurrentTab({ confirm = true }) },
19+
{ key = "p", mods = "LEADER", action = act.ActivateTabRelative(-1) },
20+
{ key = "n", mods = "LEADER", action = act.ActivateTabRelative(1) },
21+
{ key = "l", mods = "LEADER", action = act.ActivateLastTab },
22+
23+
-- Panes
24+
{ key = "%", mods = "LEADER", action = act.SplitHorizontal({ domain = "CurrentPaneDomain" }) },
25+
{ key = "\"", mods = "LEADER", action = act.SplitVertical({ domain = "CurrentPaneDomain" }) },
26+
{ key = "{", mods = "LEADER", action = act.RotatePanes("CounterClockwise") },
27+
{ key = "}", mods = "LEADER", action = act.RotatePanes("Clockwise") },
28+
{ key = "LeftArrow", mods = "LEADER", action = act.ActivatePaneDirection("Left") },
29+
{ key = "DownArrow", mods = "LEADER", action = act.ActivatePaneDirection("Down") },
30+
{ key = "UpArrow", mods = "LEADER", action = act.ActivatePaneDirection("Up") },
31+
{ key = "RightArrow", mods = "LEADER", action = act.ActivatePaneDirection("Right") },
32+
{ key = "q", mods = "LEADER", action = act.PaneSelect({ mode = "Activate" }) },
33+
{ key = "z", mods = "LEADER", action = act.TogglePaneZoomState },
34+
{ key = "LeftArrow", mods = "LEADER|CTRL", action = act.AdjustPaneSize({ "Left", 5 }) },
35+
{ key = "DownArrow", mods = "LEADER|CTRL", action = act.AdjustPaneSize({ "Down", 5 }) },
36+
{ key = "UpArrow", mods = "LEADER|CTRL", action = act.AdjustPaneSize({ "Up", 5 }) },
37+
{ key = "RightArrow", mods = "LEADER|CTRL", action = act.AdjustPaneSize({ "Right", 5 }) },
38+
{ key = "x", mods = "LEADER", action = act.CloseCurrentPane({ confirm = true }) },
39+
40+
-- Copy Mode
41+
{ key = "[", mods = "LEADER", action = act.ActivateCopyMode },
42+
}
43+
44+
for i = 1, 9 do
45+
table.insert(keys, { key = tostring(i), mods = "LEADER", action = act.ActivateTab(i - 1) })
46+
end
47+
48+
if not config.keys then
49+
config.keys = {}
50+
end
51+
for _, key in ipairs(keys) do
52+
table.insert(config.keys, key)
53+
end
54+
end
55+
56+
return M

0 commit comments

Comments
 (0)