fix wezterm

This commit is contained in:
Ray Andrew 2024-11-04 23:03:49 -06:00
parent 2ddc3fff26
commit 3927ebaafa
10 changed files with 279 additions and 36 deletions

View file

@ -25,6 +25,8 @@
username = user; username = user;
homeDirectory = "/home/${user}"; homeDirectory = "/home/${user}";
activation = { }; activation = { };
sessionVariables.EDITOR = lib.getExe pkgs.vim;
}; };
programs.home-manager.enable = true; programs.home-manager.enable = true;

View file

@ -1,9 +1,15 @@
{ pkgs, lib, config, ... }: {
pkgs,
lib,
config,
...
}:
let let
w3m = lib.getExe pkgs.w3m; w3m = lib.getExe pkgs.w3m;
zathura = lib.getExe config.programs.zathura.package; zathura = lib.getExe config.programs.zathura.package;
kitty = lib.getExe config.programs.kitty.package; # term = lib.getExe config.programs.kitty.package;
term = lib.getExe config.programs.wezterm.package;
in in
{ {
home.packages = with pkgs; [ home.packages = with pkgs; [
@ -12,22 +18,23 @@ in
home.file.".mailcap" = { home.file.".mailcap" = {
text = '' text = ''
# HTML # HTML
# text/html; ${w3m} -sixel -o tmp_dir=~/.cache/w3m -o auto_image=TRUE -o display_image=1 -T text/html %s; nametemplate=%s.html text/html; ${w3m} -sixel -o tmp_dir=~/.cache/w3m -o auto_image=TRUE -o display_image=1 -T text/html %s; nametemplate=%s.html
text/html; ${w3m} -o inline_img_protocol=4 -o tmp_dir=~/.cache/w3m -o auto_image=TRUE -o display_image=1 -T text/html %s; nametemplate=%s.html # text/html; ${w3m} -o inline_img_protocol=4 -o tmp_dir=~/.cache/w3m -o auto_image=TRUE -o display_image=1 -T text/html %s; nametemplate=%s.html
# This second one is chosen by auto_view due to the copiousoutput tag # This second one is chosen by auto_view due to the copiousoutput tag
text/html; ${w3m} -I %{charset} -T text/html -cols 140 -o tmp_dir=~/.cache/w3m -o display_link_number=1 -dump; copiousoutput text/html; ${w3m} -I %{charset} -T text/html -cols 140 -o tmp_dir=~/.cache/w3m -o display_link_number=1 -dump; copiousoutput
text/plain; $EDITOR %s text/plain; vim %s
#PDFs #PDFs
application/x-pdf; ${zathura} '%s'; test=test -n "$DISPLAY" application/x-pdf; ${zathura} '%s'; test=test -n "$DISPLAY"
application/pdf; ${zathura} '%s'; test=test -n "$DISPLAY" application/pdf; ${zathura} '%s'; test=test -n "$DISPLAY"
#Images #Images
# image/png; /usr/bin/feh %s # image/png; /usr/bin/feh %s
# image/jpeg; /usr/bin/feh %s # image/jpeg; /usr/bin/feh %s
image/*; (clear && ${kitty} +kitten icat %s); needsterminal # image/*; (clear && ${term} +kitten icat %s); needsterminal
image/*; (clear && ${term} imgcat %s); needsterminal
''; '';
}; };
} }

View file

@ -1,12 +1,220 @@
{ pkgs, ... }:
{ {
programs.wezterm = { pkgs,
enable = true; config,
extraConfig = '' lib,
return { ...
-- enable_wayland = false }:
}
''; let
colors = config.lib.stylix.colors.withHashtag;
tomlFormat = pkgs.formats.toml { };
shellIntegrationStr = ''
source "${pkgs.wezterm}/etc/profile.d/wezterm.sh"
'';
in
{
home.packages = with pkgs; [
wezterm
];
programs.bash.initExtra = shellIntegrationStr;
programs.zsh.initExtra = shellIntegrationStr;
xdg.configFile."wezterm/colors/stylix.toml".source = tomlFormat.generate "stylix.toml" {
colors = with colors; {
ansi = [
base00
base08
base0B
base0A
base0D
base0E
base0C
base05
];
brights = [
base03
base08
base0B
base0A
base0D
base0E
base0C
base07
];
background = base00;
cursor_bg = base05;
cursor_fg = base00;
compose_cursor = base06;
foreground = base05;
scrollbar_thumb = base01;
selection_bg = base05;
selection_fg = base00;
split = base03;
visual_bell = base09;
tab_bar = {
background = base01;
inactive_tab_edge = base01;
active_tab = {
bg_color = base00;
fg_color = base05;
};
inactive_tab = {
bg_color = base03;
fg_color = base05;
};
inactive_tab_hover = {
bg_color = base05;
fg_color = base00;
};
new_tab = {
bg_color = base03;
fg_color = base05;
};
new_tab_hover = {
bg_color = base05;
fg_color = base00;
};
};
};
}; };
stylix.targets.wezterm.enable = true;
xdg.configFile."wezterm/wezterm.lua".text =
with colors;
with config.stylix.fonts;
lib.mkForce ''
local wezterm = require 'wezterm'
local io = require 'io'
local os = require 'os'
local act = wezterm.action
wezterm.add_to_config_reload_watch_list(wezterm.config_dir)
local config = wezterm.config_builder()
config.front_end = "WebGpu"
config.enable_wayland = true
config.enable_kitty_keyboard = true
config.enable_csi_u_key_encoding = true
config.window_padding = {
left = 0,
right = 0,
top = 0,
bottom = 0,
}
config.inactive_pane_hsb = {
saturation = 0.7,
brightness = 0.5,
}
config.exit_behavior = 'Close'
config.hide_tab_bar_if_only_one_tab = true
config.use_fancy_tab_bar = false
config.tab_bar_at_bottom = false
wezterm.on('trigger-vim-with-scrollback', function(window, pane)
-- Retrieve the text from the pane
local text = pane:get_lines_as_text(pane:get_dimensions().scrollback_rows)
-- Create a temporary file to pass to vim
local name = os.tmpname()
local f = io.open(name, 'w+')
f:write(text)
f:flush()
f:close()
-- Open a new window running vim and tell it to open the file
window:perform_action(
act.SpawnCommandInNewWindow {
args = { 'nvim', name },
},
pane
)
-- Wait "enough" time for vim to read the file before we remove it.
-- The window creation and process spawn are asynchronous wrt. running
-- this script and are not awaitable, so we just pick a number.
--
-- Note: We don't strictly need to remove this file, but it is nice
-- to avoid cluttering up the temporary directory.
wezterm.sleep_ms(1000)
os.remove(name)
end)
config.keys = {
{
key = 'Semicolon',
mods = 'CTRL|SHIFT',
action = act.EmitEvent 'trigger-vim-with-scrollback',
},
}
-- Generated by Stylix
config.color_scheme = "stylix"
config.font = wezterm.font_with_fallback {
"${monospace.name}",
"${emoji.name}",
}
config.font_size = ${builtins.toString sizes.terminal}
config.window_background_opacity = ${builtins.toString config.stylix.opacity.terminal}
config.window_frame = {
active_titlebar_bg = "${base03}",
active_titlebar_fg = "${base05}",
active_titlebar_border_bottom = "${base03}",
border_left_color = "${base01}",
border_right_color = "${base01}",
border_bottom_color = "${base01}",
border_top_color = "${base01}",
button_bg = "${base01}",
button_fg = "${base05}",
button_hover_bg = "${base05}",
button_hover_fg = "${base03}",
inactive_titlebar_bg = "${base01}",
inactive_titlebar_fg = "${base05}",
inactive_titlebar_border_bottom = "${base03}",
}
config.colors = {
tab_bar = {
background = "${base01}",
inactive_tab_edge = "${base01}",
active_tab = {
bg_color = "${base00}",
fg_color = "${base05}",
},
inactive_tab = {
bg_color = "${base03}",
fg_color = "${base05}",
},
inactive_tab_hover = {
bg_color = "${base05}",
fg_color = "${base00}",
},
new_tab = {
bg_color = "${base03}",
fg_color = "${base05}",
},
new_tab_hover = {
bg_color = "${base05}",
fg_color = "${base00}",
},
},
}
config.command_palette_bg_color = "${base01}"
config.command_palette_fg_color = "${base05}"
config.command_palette_font_size = ${builtins.toString sizes.popups}
return config
'';
# programs.wezterm = {
# enable = true;
# extraConfig = ''
# return {
# front_end = "WebGpu",
# enable_wayland = true,
# }
# '';
# };
# stylix.targets.wezterm.enable = true;
} }

View file

@ -1,13 +1,26 @@
{ pkgs, ... }: { pkgs, ... }:
{
home.packages = with pkgs; [
tmux
];
xdg.configFile."tmux/tmux.conf" = { let
source = ./tmux.conf; tmux-conf = ./tmux.conf;
in
{
# home.packages = with pkgs; [
# tmux
# ];
programs.tmux = {
enable = true;
sensibleOnTop = false;
extraConfig = ''
source-file ${tmux-conf}
'';
}; };
stylix.targets.tmux.enable = true;
# xdg.configFile."tmux/tmux.conf" = {
# source = ./tmux.conf;
# };
custom.persist = { custom.persist = {
home.directories = [ home.directories = [
".tmux" ".tmux"

View file

@ -23,6 +23,7 @@ set-option -g status-position bottom # top
set-option -g default-terminal 'screen-256color' set-option -g default-terminal 'screen-256color'
set-option -sa terminal-features ',xterm-kitty:RGB' set-option -sa terminal-features ',xterm-kitty:RGB'
set-option -as terminal-features ',screen-256color:clipboard'
set -ga terminal-overrides ',xterm*:Tc' set -ga terminal-overrides ',xterm*:Tc'
# https://github.com/folke/tokyonight.nvim#making-undercurls-work-properly-in-tmux # https://github.com/folke/tokyonight.nvim#making-undercurls-work-properly-in-tmux
@ -181,4 +182,4 @@ bind-key -T copy-mode-vi 'C-\' if-shell "$is_vim_emacs" "send-keys C-\\\\" "sele
# Browse tmux pane in nvim # Browse tmux pane in nvim
# bind [ run-shell 'kitty @ kitten ~/.local/share/nvim/lazy/kitty-scrollback.nvim/python/kitty_scrollback_nvim.py --env "TMUX=$TMUX" --env "TMUX_PANE=#{pane_id}"' # bind [ run-shell 'kitty @ kitten ~/.local/share/nvim/lazy/kitty-scrollback.nvim/python/kitty_scrollback_nvim.py --env "TMUX=$TMUX" --env "TMUX_PANE=#{pane_id}"'
bind [ run-shell 'tmux-vim-pager' # bind [ run-shell 'tmux-vim-pager'

View file

@ -165,6 +165,10 @@ in
"XF86AudioPause" = "exec --no-startup-id ${playerctl} play-pause"; "XF86AudioPause" = "exec --no-startup-id ${playerctl} play-pause";
"XF86AudioNext" = "exec --no-startup-id ${playerctl} next"; "XF86AudioNext" = "exec --no-startup-id ${playerctl} next";
"XF86AudioPrev" = "exec --no-startup-id ${playerctl} previous"; "XF86AudioPrev" = "exec --no-startup-id ${playerctl} previous";
"${modifier}+b" = "exec ${terminal} bash -c yazi";
"${modifier}+m" = "exec ${terminal} bash -c neomutt";
"${modifier}+c" = "exec ${terminal} bash -c calcure";
}; };
modes = modes =

View file

@ -14,7 +14,8 @@ let
menu = lib.getExe' pkgs.dmenu "dmenu_run"; menu = lib.getExe' pkgs.dmenu "dmenu_run";
terminal = terminal =
if config.programs.kitty.enable then if config.programs.kitty.enable then
lib.getExe' config.programs.kitty.package "kitty" # lib.getExe' config.programs.kitty.package "kitty"
lib.getExe' config.programs.wezterm.package "wezterm"
else else
lib.getExe' pkgs.xterm "xterm"; lib.getExe' pkgs.xterm "xterm";
}; };

View file

@ -15,7 +15,8 @@ let
menu = lib.getExe' config.programs.bemenu.package "bemenu-run"; menu = lib.getExe' config.programs.bemenu.package "bemenu-run";
terminal = terminal =
if config.programs.kitty.enable then if config.programs.kitty.enable then
lib.getExe' config.programs.kitty.package "kitty" # lib.getExe' config.programs.kitty.package "kitty"
lib.getExe' config.programs.wezterm.package "wezterm"
else else
lib.getExe' pkgs.foot "foot"; lib.getExe' pkgs.foot "foot";
}; };

View file

@ -63,6 +63,7 @@
config = { config = {
environment = { environment = {
variables.EDITOR = lib.getExe pkgs.vim;
systemPackages = systemPackages =
with pkgs; with pkgs;
[ [

View file

@ -1,4 +1,9 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
{ {
programs.gnupg = { programs.gnupg = {