new starship and wezterm statuses

This commit is contained in:
William 2024-09-20 12:46:08 -03:00
parent 96744317ff
commit a9f9653d1f
2 changed files with 105 additions and 84 deletions

View file

@ -50,17 +50,9 @@
tmux = {
enable = true;
clock24 = true;
terminal = "tmux-256color";
terminal = "xterm-256color";
mouse = true;
keyMode = "vi";
extraConfig = ''
set-option -ga terminal-overrides ",alacritty:Tc"
'';
};
zellij = {
enable = true;
enableBashIntegration = true;
};
starship = {
@ -69,68 +61,19 @@
enableFishIntegration = true;
settings = {
add_newline = false;
format = ''
[](main)$os[](fg:main bg:cyan)$directory[](fg:cyan bg:blue)$git_branch$git_status[](fg:blue bg:purple)$nix_shell$rust[](fg:purple bg:yellow)$time[](fg:yellow)$fill[](fg:yellow)$cmd_duration[](fg:purple bg:yellow)[](fg:blue bg:purple)[](fg:cyan bg:blue)$hostname[](main)
[ ](blue)'';
format = "$git_branch$git_status$nix_shell[ ](bold green)";
palette = "stylix";
os = {
disabled = false;
style = "bg:main fg:background";
symbols.NixOS = " ";
};
directory = {
format = "[ $path ]($style)";
style = "fg:background bg:cyan";
truncation_length = 3;
truncation_symbol = "󰇘 ";
substitutions = {
Documents = " ";
Downloads = " ";
Music = " ";
Pictures = " ";
Videos = " ";
};
};
git_branch = {
format = "[[ $symbol $branch ](fg:background bg:blue)]($style)";
style = "bg:blue";
symbol = "";
};
git_status = {
format =
"[[($all_status$ahead_behind )](fg:background bg:blue)]($style)";
style = "bg:blue";
};
right_format = "$character";
git_branch.symbol = " ";
nix_shell = {
format = "[[ $symbol ](fg:background bg:purple)]($style)";
format = "via [$symbol $state]($style) ";
heuristic = true;
style = "bg:purple";
symbol = "󱄅";
};
rust = {
format = "[[ $symbol ($version) ](fg:background bg:purple)]($style)";
style = "bg:purple";
symbol = "";
};
time = {
disabled = false;
format = "[[ $time ](fg:background bg:yellow)]($style)";
style = "bg:yellow";
time_format = "%R";
};
fill.symbol = " ";
right_format = "$cmd_duration$character";
cmd_duration = {
format = "[[ $duration ](fg:background bg:yellow)]($style)";
min_time = 0;
style = "bg:yellow";
};
hostname = {
format =
"[[$ssh_symbol](fg:background bg:cyan)[](bg:cyan fg:main)$hostname ]($style)";
ssh_only = false;
ssh_symbol = " ";
style = "fg:background bg:main";
format = "[ $duration ]($style)";
style = "yellow";
min_time = 10;
};
character = {
error_symbol = "[](bold red)";
@ -138,6 +81,7 @@
};
palettes.stylix = {
background = config.lib.stylix.colors.withHashtag.base00;
backgroundAlt = config.lib.stylix.colors.withHashtag.base01;
green = config.lib.stylix.colors.withHashtag.base0B;
cyan = config.lib.stylix.colors.withHashtag.base0C;
yellow = config.lib.stylix.colors.withHashtag.base0A;
@ -145,6 +89,8 @@
blue = config.lib.stylix.colors.withHashtag.base0D;
purple = config.lib.stylix.colors.withHashtag.base0E;
main = config.lib.stylix.colors.withHashtag.base05;
seco = config.lib.stylix.colors.withHashtag.base04;
tert = config.lib.stylix.colors.withHashtag.base06;
};
};
};

View file

@ -16,24 +16,99 @@
return 100
end
end
wezterm.on('update-right-status', function(window, pane)
-- Each element holds the text for a cell in a "powerline" style << fade
local cells = {}
-- Figure out the cwd and host of the current pane.
-- This will pick up the hostname for the remote host if your
-- shell is using OSC 7 on the remote host.
local cwd_uri = pane:get_current_working_dir()
if cwd_uri then
local cwd = ""
local hostname = ""
cwd = cwd_uri.file_path
hostname = cwd_uri.host or wezterm.hostname()
-- Remove the domain name portion of the hostname
local dot = hostname:find '[.]'
if dot then
hostname = hostname:sub(1, dot - 1)
end
if hostname == "" then
hostname = wezterm.hostname()
end
table.insert(cells, cwd)
table.insert(cells, hostname)
end
local date = wezterm.strftime '%H:%M'
table.insert(cells, date)
-- An entry for each battery (typically 0 or 1 battery)
for _, b in ipairs(wezterm.battery_info()) do
table.insert(cells, string.format('%.0f%%', b.state_of_charge * 100))
end
local SOLID_LEFT_ARROW = ''
-- Color palette for the backgrounds of each cell
local colors = {
'${config.lib.stylix.colors.withHashtag.base01}',
'${config.lib.stylix.colors.withHashtag.base02}',
'${config.lib.stylix.colors.withHashtag.base03}',
'${config.lib.stylix.colors.withHashtag.base04}',
'${config.lib.stylix.colors.withHashtag.base04}',
}
-- Foreground color for the text across the fade
local text_fg = '${config.lib.stylix.colors.withHashtag.base05}'
-- The elements to be formatted
local elements = {}
-- How many cells have been formatted
local num_cells = 0
-- Translate a cell into elements
function push(text, is_last)
local cell_no = num_cells + 1
table.insert(elements, { Foreground = { Color = text_fg } })
table.insert(elements, { Background = { Color = colors[cell_no] } })
table.insert(elements, { Text = text .. ' ' })
if not is_last then
table.insert(elements, { Foreground = { Color = colors[cell_no + 1] } })
table.insert(elements, { Text = SOLID_LEFT_ARROW })
end
num_cells = num_cells + 1
end
while #cells > 0 do
local cell = table.remove(cells, 1)
push(cell, #cells == 0)
end
window:set_right_status(wezterm.format(elements))
end)
return {
disable_default_key_bindings = true,
window_padding = {
left = "2pt",
right = "2pt",
bottom = 0,
top = 0,
bottom = "2pt",
top = "2pt",
},
use_fancy_tab_bar = true,
command_palette_font_size = 12,
initial_cols = get_initial_cols_by_hostname(),
initial_rows = 32,
inactive_pane_hsb = {
saturation = 0.7,
brightness = 0.5
brightness = 0.5,
},
hide_tab_bar_if_only_one_tab = false,
show_new_tab_button_in_tab_bar = true,
show_new_tab_button_in_tab_bar = false,
tab_bar_at_bottom = true,
use_fancy_tab_bar = false,
front_end = "WebGpu",
keys = {
{ key = 'Tab', mods = 'CTRL', action = act.ActivateTabRelative(1) },