From fdc85e5569d11538b00f6f86a0bc51e8912fad29 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Tue, 15 Nov 2022 18:36:41 +0100 Subject: [PATCH 01/14] sh: Replace kitty invocations with wezterm --- README.md | 4 ++-- sh/.config/sh/env | 4 ++-- wayland/.config/waybar/config | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index a6bca26..83ce55f 100644 --- a/README.md +++ b/README.md @@ -48,8 +48,8 @@ Enjoy! * [`waybar`](https://github.com/Alexays/Waybar) - Easily customizable statusbar for wayland * [`bemenu`](https://github.com/Cloudef/bemenu) - Extended dmenu replacement for wayland, X11 and ncurses * [`fontconfig`] - System-wide font replacements and styling settings -* [`kitty`](https://sw.kovidgoyal.net/kitty/) - Terminal emulator (GPU accelerated and configurable) -* [`tmux`](https://github.com/tmux/tmux/) - terminal multiplexer +* [`wezterm`](https://wezfurlong.org/wezterm/) - Terminal emulator (fast, understandable and lua configurable) +* [`tmux`](https://github.com/tmux/tmux/) - terminal multiplexer (slowly migrating away in favor of wezterm) * [`nvim`](https://neovim.io/) - Neovim configuration * [`vifm`](https://github.com/vifm/vifm) - vim-like file-manager * [`qutebrowser`](https://github.com/qutebrowser/qutebrowser) - vim-key enabled web browser diff --git a/sh/.config/sh/env b/sh/.config/sh/env index db99a4e..fceba1b 100644 --- a/sh/.config/sh/env +++ b/sh/.config/sh/env @@ -22,7 +22,7 @@ export BIBFILE="${BIBFILE:-$LIBRARYROOT/academia/academia.bib}" # these are my personal 'important' application settings export EDITOR="nvim" export BROWSER="qutebrowser" -export TERMINAL="kitty" +export TERMINAL="wezterm" export PAGER="less" export FILEREADER="zathura" @@ -42,5 +42,5 @@ export SHELL=${SHELL:-/bin/bash} export TERM=xterm-256color if exist fzf; then - export FZF_DEFAULT_OPTS="--bind 'tab:toggle+down,shift-tab:toggle+up,ctrl-g:top,ctrl-t:toggle-preview,ctrl-d:preview-half-page-down,ctrl-u:preview-half-page-up' --color=light -1 -m --delimiter :" + export FZF_DEFAULT_OPTS="--bind 'tab:toggle+down,shift-tab:toggle+up,ctrl-g:top,ctrl-t:toggle-preview,ctrl-d:preview-half-page-down,ctrl-u:preview-half-page-up' --color=light -1 -m --delimiter :" fi diff --git a/wayland/.config/waybar/config b/wayland/.config/waybar/config index 4bd87ed..6ead0b9 100644 --- a/wayland/.config/waybar/config +++ b/wayland/.config/waybar/config @@ -12,7 +12,7 @@ "return-type": "json", "exec": "~/.config/waybar/modules/archupdates 5 json", "interval": 3600, - "on-click": "kitty --class float topgrade" + "on-click": "$TERMINAL start --class float topgrade" }, "backlight": { "device": "intel_backlight", @@ -45,8 +45,8 @@ "warning": 50, "critical": 80 }, - "on-click": "kitty --class float top", - "on-click-right": "kitty --class float glances" + "on-click": "$TERMINAL start --class float top", + "on-click-right": "$TERMINAL start --class float glances" }, "custom/events": { "format": "{}", @@ -115,7 +115,7 @@ "tooltip-format-ethernet": "{ifname} ", "tooltip-format-disconnected": "Disconnected", "max-length": 50, - "on-click": "kitty --class float nmtui", + "on-click": "$TERMINAL start --class float nmtui", // "on-click-right": "sudo rfkill toggle wlan" }, "pulseaudio": { @@ -132,7 +132,7 @@ "default": ["", ""] }, "scroll-step": 1, - "on-click": "kitty --class float pulsemixer", + "on-click": "$TERMINAL start --class float pulsemixer", "on-scroll-up": "pactl set-sink-volume @DEFAULT_SINK@ +1%", "on-scroll-down": "pactl set-sink-volume @DEFAULT_SINK@ -1%" }, @@ -146,7 +146,7 @@ "critical-threshold": 80, // "format-critical": "{temperatureC}° ", "format": "{temperatureC}° ", - "on-click": "kitty --class float watch sensors" + "on-click": "$TERMINAL start --class float watch sensors" }, "tray": { "icon-size": 21, @@ -176,6 +176,6 @@ "exec": "wc -l ~/.local/share/vidl/vidl_queue | cut -d' ' -f1", "exec-if": "[ -f ~/.local/share/vidl/vidl_queue ]", "interval": 5, - "on-click": "kitty --class float nvim ~/.local/share/vidl/vidl_queue" + "on-click": "$TERMINAL start --class float nvim ~/.local/share/vidl/vidl_queue" }, } From cf7d89078733b9e6305ca655e3a2cc3e75952d0a Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Tue, 15 Nov 2022 18:39:25 +0100 Subject: [PATCH 02/14] sh: Add timg aliases Added shell aliases for 'image listings' which aims to mimic the `ls` command in a very simple way. Invoke it via `il` to display a grid of all images residing in current directory. Images are being detected not by their extension but by running a `file` operation on, so in very large directories this might take a little (though, your terminal will probably buckle under the weight of displaying thousands of images anyway, so use with care). `IL` provides the same functionality but recurses into an arbitrary amount of subdirectories. Very useful to get an overview of a certain directory and its children but, again, think for a second before using since this could easily spew thousands of pictures into your term. --- sh/.config/sh/alias.d/timg.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 sh/.config/sh/alias.d/timg.sh diff --git a/sh/.config/sh/alias.d/timg.sh b/sh/.config/sh/alias.d/timg.sh new file mode 100644 index 0000000..fb0d7e0 --- /dev/null +++ b/sh/.config/sh/alias.d/timg.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env sh +# Add simple 'image ls' for a directory using timg +# +# Prints a thumbnail gallery right in the terminal. +# WILL stutter when you go crazy in a hundred/thousand +# picture folder. + +if exist timg; then + il() { + images=$(find . -maxdepth 1 -type f -exec file --mime-type {} \+ | awk -F: '{if ($2 ~/image\//) print $1}') + if [ -z "$images" ]; then { + echo no images found. + return + }; fi + echo "$images" | timg --grid=4x3 --upscale=i --center --title --frames=1 -f - + } + IL() { + images=$(find . -type f -exec file --mime-type {} \+ | awk -F: '{if ($2 ~/image\//) print $1}') + if [ -z "$images" ]; then { + echo no images found. + return + }; fi + echo "$images" | timg --grid=4x3 --upscale=i --center --title --frames=1 -f - + } + qr() { + # if we are in a pipe, read from stdin and set fct arguments to it + if [ ! -t 0 ]; then + set -- "$(cat /dev/stdin)" + fi + qrencode -s1 -m2 "$@" -o- | timg --upscale=i - + } +fi From e884c94a99ec55e970b48112a3fab49321116a30 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 16 Nov 2022 18:28:33 +0100 Subject: [PATCH 03/14] qutebrowser: Fix terminal calls for wezterm --- qutebrowser/.config/qutebrowser/config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qutebrowser/.config/qutebrowser/config.py b/qutebrowser/.config/qutebrowser/config.py index 925e392..2c8974f 100644 --- a/qutebrowser/.config/qutebrowser/config.py +++ b/qutebrowser/.config/qutebrowser/config.py @@ -17,7 +17,7 @@ c.completion.web_history.max_items = 1000 c.hints.uppercase = True c.editor.command = [ term, - "-e", + "start", "nvim", "-f", "{file}", @@ -29,9 +29,9 @@ c.editor.command = [ c.fileselect.handler = "external" picker = [ term, + "start", "--class", "float", - "-e", "vifm", "--choose-files", "{}", From 848f105df8afcd17c19e760d27ebc974daf0de28 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 16 Nov 2022 18:29:02 +0100 Subject: [PATCH 04/14] wezterm: Add config --- wezterm/.config/wezterm/maps.lua | 78 ++++++++++++++++++++ wezterm/.config/wezterm/wezterm.lua | 107 ++++++++++++++++++++++++++++ 2 files changed, 185 insertions(+) create mode 100644 wezterm/.config/wezterm/maps.lua create mode 100644 wezterm/.config/wezterm/wezterm.lua diff --git a/wezterm/.config/wezterm/maps.lua b/wezterm/.config/wezterm/maps.lua new file mode 100644 index 0000000..5ffe960 --- /dev/null +++ b/wezterm/.config/wezterm/maps.lua @@ -0,0 +1,78 @@ +local act = require('wezterm').action +local keys = { + { key = 'O', mods = 'CTRL', action = act.ShowDebugOverlay }, + + { -- vertical pane + key = '\\', + mods = 'LEADER', + action = act.SplitHorizontal { domain = 'CurrentPaneDomain' } + }, { -- horizontal pane + key = '-', + mods = 'LEADER', + action = act.SplitVertical { domain = 'CurrentPaneDomain' } + }, { key = 'h', mods = 'CTRL', action = act.ActivatePaneDirection 'Left' }, + { key = 'j', mods = 'CTRL', action = act.ActivatePaneDirection 'Down' }, + { key = 'k', mods = 'CTRL', action = act.ActivatePaneDirection 'Up' }, + { key = 'l', mods = 'CTRL', action = act.ActivatePaneDirection 'Right' }, + { key = 'z', mods = 'LEADER', action = act.TogglePaneZoomState }, + { key = ' ', mods = 'LEADER', action = act.RotatePanes 'Clockwise' }, + { key = 'q', mods = 'LEADER', action = act.PaneSelect { mode = 'Activate' } }, + { + key = 'Q', + mods = 'LEADER', + action = act.PaneSelect { mode = 'SwapWithActive' } + }, { key = 'c', mods = 'LEADER', action = act.SpawnTab 'CurrentPaneDomain' }, + + { key = 't', mods = 'LEADER', action = act.ShowTabNavigator }, + { key = '[', mods = 'LEADER', action = act.ActivateCopyMode }, { + key = 'r', + mods = 'LEADER', + action = act.ActivateKeyTable { + name = 'resize_pane', + one_shot = false, + timeout_milliseconds = 2000 + } + }, { key = 'F', mods = 'LEADER', action = act.QuickSelect }, { + key = '/', + mods = 'LEADER', + action = act.Search('CurrentSelectionOrEmptyString') + }, { + key = 'b', + mods = 'LEADER', + action = act.ActivateKeyTable { name = 'scroll_mode', one_shot = false } + } + +} +-- Leader + number to activate that tab +for i = 1, 8 do + table.insert(keys, { + key = tostring(i), + mods = 'LEADER', + action = act.ActivateTab(i - 1) + }) +end +-- key table sub modes +local key_tables = { + -- mode to change size of any panes + resize_pane = { + { key = 'h', action = act.AdjustPaneSize { 'Left', 1 } }, + { key = 'l', action = act.AdjustPaneSize { 'Right', 1 } }, + { key = 'k', action = act.AdjustPaneSize { 'Up', 1 } }, + { key = 'j', action = act.AdjustPaneSize { 'Down', 1 } }, + { key = 'Escape', action = 'PopKeyTable' } + }, + scroll_mode = { + { key = 'y', mods = 'CTRL', action = act.ScrollByLine(-1) }, + { key = 'e', mods = 'CTRL', action = act.ScrollByLine(1) }, + { key = 'f', mods = 'CTRL', action = act.ScrollByPage(1) }, + { key = 'b', mods = 'CTRL', action = act.ScrollByPage(-1) }, + { key = 'd', mods = 'CTRL', action = act.ScrollByPage(0.5) }, + { key = 'u', mods = 'CTRL', action = act.ScrollByPage(-0.5) }, + { key = 'g', mods = 'CTRL', action = act.ScrollToTop }, + { key = 'G', mods = 'CTRL', action = act.ScrollToBottom }, + { key = '[', mods = 'CTRL', action = act.ScrollToPrompt(-1) }, + { key = ']', mods = 'CTRL', action = act.ScrollToPrompt(1) }, + { key = 'Escape', action = 'PopKeyTable' } + } +} +return { keys = keys, key_tables = key_tables } diff --git a/wezterm/.config/wezterm/wezterm.lua b/wezterm/.config/wezterm/wezterm.lua new file mode 100644 index 0000000..efcafd4 --- /dev/null +++ b/wezterm/.config/wezterm/wezterm.lua @@ -0,0 +1,107 @@ +local wezterm = require 'wezterm' +local mux = wezterm.mux + +local maps = require 'maps' + +-- STATUSBAR +-- show currently active key table in lower right status bar +-- mimicking Vim modes +wezterm.on('update-right-status', function(window, _) + local keytable = window:active_key_table() + if keytable then + keytable = 'MODE: ' .. keytable + else + keytable = '' + end + local workspace = window:active_workspace() + if workspace and workspace ~= 'default' then + workspace = 'WORKSPACE: ' .. workspace + else + workspace = '' + end + + local status = keytable .. ' ' .. workspace + window:set_left_status(status or '') + + -- "Wed Mar 3 08:14" + local date = wezterm.strftime '%a %b %-d %H:%M ' + + local bat = '' + for _, b in ipairs(wezterm.battery_info()) do + bat = + '🔋 ' .. string.format('%.0f%%', b.state_of_charge * 100) .. ' ' .. + b.state + end + + window:set_right_status(wezterm.format {{Text = bat .. ' ' .. date}}) +end) + +wezterm.on("set-up-dotfile-workspace", function(window, pane) + -- Set a workspace for coding on a current project + -- Top pane is for the editor, bottom pane is for the build tool + local project_dir = wezterm.home_dir .. '/projects/test/quarto/quarto-test' + local tab, build_pane, window = mux.spawn_window { + workspace = 'coding', + cwd = project_dir, + args = args + } + local editor_pane = build_pane:split{ + direction = 'Top', + size = 0.6, + cwd = project_dir + } + build_pane:send_text 'quarto check' + mux.set_active_workspace 'coding' +end) +-- +-- wezterm.on('gui-startup', function(cmd) +-- -- allow `wezterm start -- something` to affect what we spawn +-- -- in our initial window +-- local args = {} +-- if cmd then args = cmd.args end +-- +-- -- Set a workspace for coding on a current project +-- -- Top pane is for the editor, bottom pane is for the build tool +-- local project_dir = wezterm.home_dir .. '/projects/test/quarto/quarto-test' +-- local tab, build_pane, window = mux.spawn_window { +-- workspace = 'coding', +-- cwd = project_dir, +-- args = args +-- } +-- local editor_pane = build_pane:split { +-- direction = 'Top', +-- size = 0.6, +-- cwd = project_dir +-- } +-- build_pane:send_text 'quarto check' +-- +-- -- A workspace for interacting with a local machine that +-- -- runs some docker containners for home automation +-- local tab, pane, window = mux.spawn_window { +-- workspace = 'toppy', +-- args = { 'top' } +-- } +-- +-- -- We want to startup in the coding workspace +-- mux.set_active_workspace 'coding' +-- end) + +return { + enable_wayland = true, + + hide_tab_bar_if_only_one_tab = true, + use_fancy_tab_bar = false, + tab_bar_at_bottom = true, + window_padding = {left = 0, right = 0, top = 0, bottom = 0}, + + color_scheme = "Nord (base16)", + -- default_prog = {"nu"}, + scrollback_lines = 10000, + + font = wezterm.font('Liga Iosevka'), + line_height = 1.0, + + leader = {key = 'a', mods = 'CTRL', timeout_milliseconds = 1500}, + keys = maps.keys, + key_tables = maps.key_tables +} From 5dc8e5afcebcdf2736539958b800a9813d273189 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 25 Nov 2022 16:21:20 +0100 Subject: [PATCH 05/14] wezterm: Add event handling --- wezterm/.config/wezterm/events.lua | 63 ++++++++++++++++++++++ wezterm/.config/wezterm/maps.lua | 61 +++++++++++++++++----- wezterm/.config/wezterm/statusbar.lua | 46 ++++++++++++++++ wezterm/.config/wezterm/wezterm.lua | 75 ++++++++------------------- 4 files changed, 180 insertions(+), 65 deletions(-) create mode 100644 wezterm/.config/wezterm/events.lua create mode 100644 wezterm/.config/wezterm/statusbar.lua diff --git a/wezterm/.config/wezterm/events.lua b/wezterm/.config/wezterm/events.lua new file mode 100644 index 0000000..fd6aab8 --- /dev/null +++ b/wezterm/.config/wezterm/events.lua @@ -0,0 +1,63 @@ +local wezterm = require 'wezterm' +local io = require 'io' +local os = require 'os' +local act = wezterm.action + +local function setup() + local function isViProcess(pane) + local proc = pane:get_foreground_process_name() + if (proc:find('vim') or proc:find('nvim')) then return true end + return false + end + + local function conditionalActivatePane(window, pane, pane_direction, + vim_direction) + if (isViProcess(pane)) then + window:perform_action(act.Multiple { + act.SendKey { key = 'w', mods = 'CTRL' }, + act.SendKey { key = vim_direction } + }, pane) + else + window:perform_action(act.ActivatePaneDirection(pane_direction), + pane) + end + end + + wezterm.on('ActivatePaneDirection-right', function(window, pane) + conditionalActivatePane(window, pane, 'Right', 'l') + end) + wezterm.on('ActivatePaneDirection-left', function(window, pane) + conditionalActivatePane(window, pane, 'Left', 'h') + end) + wezterm.on('ActivatePaneDirection-up', function(window, pane) + conditionalActivatePane(window, pane, 'Up', 'k') + end) + wezterm.on('ActivatePaneDirection-down', function(window, pane) + conditionalActivatePane(window, pane, 'Down', 'j') + end) + + -- Retrieve the current scrollback text and send to editor + wezterm.on('edit-scrollback', function(window, pane) + local viewport_text = pane:get_lines_as_text(10000) + + -- Create a temporary file to pass to vim + local name = os.tmpname() + + local f = io.open(name, 'w+') + if f == nil then return false end + f:write(viewport_text) + f:flush() + f:close() + + -- Open a new window running vim and tell it to open the file + window:perform_action(act.SpawnCommandInNewTab { + args = { (os.getenv('EDITOR') or 'vi'), name } + }, pane) + + -- Wait time for vim to read the file before we remove it. + wezterm.sleep_ms(1000) + os.remove(name) + end) +end + +return { setup = setup } diff --git a/wezterm/.config/wezterm/maps.lua b/wezterm/.config/wezterm/maps.lua index 5ffe960..01149b2 100644 --- a/wezterm/.config/wezterm/maps.lua +++ b/wezterm/.config/wezterm/maps.lua @@ -1,7 +1,11 @@ -local act = require('wezterm').action +local wezterm = require('wezterm') +local act = wezterm.action + local keys = { { key = 'O', mods = 'CTRL', action = act.ShowDebugOverlay }, + { key = '[', mods = 'CTRL', action = act.ScrollToPrompt(-1) }, + { key = ']', mods = 'CTRL', action = act.ScrollToPrompt(1) }, { -- vertical pane key = '\\', mods = 'LEADER', @@ -10,11 +14,26 @@ local keys = { key = '-', mods = 'LEADER', action = act.SplitVertical { domain = 'CurrentPaneDomain' } - }, { key = 'h', mods = 'CTRL', action = act.ActivatePaneDirection 'Left' }, - { key = 'j', mods = 'CTRL', action = act.ActivatePaneDirection 'Down' }, - { key = 'k', mods = 'CTRL', action = act.ActivatePaneDirection 'Up' }, - { key = 'l', mods = 'CTRL', action = act.ActivatePaneDirection 'Right' }, - { key = 'z', mods = 'LEADER', action = act.TogglePaneZoomState }, + }, -- pane movement keys + { + key = 'h', + mods = 'CTRL', + action = act.EmitEvent 'ActivatePaneDirection-left' + }, + { + key = 'j', + mods = 'CTRL', + action = act.EmitEvent 'ActivatePaneDirection-down' + }, + { + key = 'k', + mods = 'CTRL', + action = act.EmitEvent 'ActivatePaneDirection-up' + }, { + key = 'l', + mods = 'CTRL', + action = act.EmitEvent 'ActivatePaneDirection-right' + }, { key = 'z', mods = 'LEADER', action = act.TogglePaneZoomState }, { key = ' ', mods = 'LEADER', action = act.RotatePanes 'Clockwise' }, { key = 'q', mods = 'LEADER', action = act.PaneSelect { mode = 'Activate' } }, { @@ -22,24 +41,38 @@ local keys = { mods = 'LEADER', action = act.PaneSelect { mode = 'SwapWithActive' } }, { key = 'c', mods = 'LEADER', action = act.SpawnTab 'CurrentPaneDomain' }, - - { key = 't', mods = 'LEADER', action = act.ShowTabNavigator }, + { key = ',', mods = 'LEADER', action = act.MoveTabRelative(-1) }, + { key = '.', mods = 'LEADER', action = act.MoveTabRelative(1) }, -- workspace selection + { + key = 's', + mods = 'LEADER', + action = act.ShowLauncherArgs { flags = 'FUZZY|WORKSPACES' } + }, { key = 't', mods = 'LEADER', action = act.ShowTabNavigator }, { key = '[', mods = 'LEADER', action = act.ActivateCopyMode }, { key = 'r', mods = 'LEADER', action = act.ActivateKeyTable { name = 'resize_pane', one_shot = false, - timeout_milliseconds = 2000 + timeout_milliseconds = 2000, + replace_current = true } }, { key = 'F', mods = 'LEADER', action = act.QuickSelect }, { key = '/', mods = 'LEADER', action = act.Search('CurrentSelectionOrEmptyString') }, { - key = 'b', + key = 'f', mods = 'LEADER', - action = act.ActivateKeyTable { name = 'scroll_mode', one_shot = false } + action = act.ActivateKeyTable { + name = 'scroll_mode', + one_shot = false, + replace_current = true + } + }, { key = 'e', mods = 'LEADER', action = act.EmitEvent 'edit-scrollback' }, { + key = 'l', + mods = 'LEADER', + action = act.EmitEvent 'ActivatePaneDirection-Right' } } @@ -59,6 +92,10 @@ local key_tables = { { key = 'l', action = act.AdjustPaneSize { 'Right', 1 } }, { key = 'k', action = act.AdjustPaneSize { 'Up', 1 } }, { key = 'j', action = act.AdjustPaneSize { 'Down', 1 } }, + { key = 'H', action = act.AdjustPaneSize { 'Left', 10 } }, + { key = 'L', action = act.AdjustPaneSize { 'Right', 10 } }, + { key = 'K', action = act.AdjustPaneSize { 'Up', 10 } }, + { key = 'J', action = act.AdjustPaneSize { 'Down', 10 } }, { key = 'Escape', action = 'PopKeyTable' } }, scroll_mode = { @@ -70,8 +107,6 @@ local key_tables = { { key = 'u', mods = 'CTRL', action = act.ScrollByPage(-0.5) }, { key = 'g', mods = 'CTRL', action = act.ScrollToTop }, { key = 'G', mods = 'CTRL', action = act.ScrollToBottom }, - { key = '[', mods = 'CTRL', action = act.ScrollToPrompt(-1) }, - { key = ']', mods = 'CTRL', action = act.ScrollToPrompt(1) }, { key = 'Escape', action = 'PopKeyTable' } } } diff --git a/wezterm/.config/wezterm/statusbar.lua b/wezterm/.config/wezterm/statusbar.lua new file mode 100644 index 0000000..020d882 --- /dev/null +++ b/wezterm/.config/wezterm/statusbar.lua @@ -0,0 +1,46 @@ +local wezterm = require 'wezterm' + +local function basename(s) return string.gsub(s or '', '(.*[/\\])(.*)', '%2') end + +local SEPARATOR = ' | ' +local function setup() + -- STATUSBAR + -- show currently active key table in lower right status bar + -- mimicing Vim modes + wezterm.on('update-status', function(window, pane) + local displayed = { left = {}, right = {} } + local keytable = window:active_key_table() + if keytable then + displayed.left[#displayed.left + 1] = 'MODE: ' .. keytable + end + + local workspace = window:active_workspace() + if workspace and workspace ~= 'default' then + displayed.left[#displayed.left + 1] = 'WORKSPACE: ' .. workspace + end + + local bat = '' + for _, b in ipairs(wezterm.battery_info()) do + bat = '🔋 ' .. string.format('%.0f%%', b.state_of_charge * 100) .. + ' ' .. b.state + end + displayed.right[#displayed.right + 1] = bat + + local currentprogram = pane:get_foreground_process_name() + displayed.right[#displayed.right + 1] = basename(currentprogram) + + local statusleft = '' + for _, v in ipairs(displayed.left) do + statusleft = statusleft .. v .. SEPARATOR + end + local statusright = '' + for _, v in ipairs(displayed.right) do + statusright = statusright .. v .. SEPARATOR + end + + window:set_left_status(statusleft or '') + window:set_right_status(statusright or '') + end) +end + +return { setup = setup } diff --git a/wezterm/.config/wezterm/wezterm.lua b/wezterm/.config/wezterm/wezterm.lua index efcafd4..33a7923 100644 --- a/wezterm/.config/wezterm/wezterm.lua +++ b/wezterm/.config/wezterm/wezterm.lua @@ -3,56 +3,26 @@ local mux = wezterm.mux local maps = require 'maps' --- STATUSBAR --- show currently active key table in lower right status bar --- mimicking Vim modes -wezterm.on('update-right-status', function(window, _) - local keytable = window:active_key_table() - if keytable then - keytable = 'MODE: ' .. keytable - else - keytable = '' - end - local workspace = window:active_workspace() - if workspace and workspace ~= 'default' then - workspace = 'WORKSPACE: ' .. workspace - else - workspace = '' - end +require 'statusbar'.setup() +require 'events'.setup() - local status = keytable .. ' ' .. workspace - window:set_left_status(status or '') - - -- "Wed Mar 3 08:14" - local date = wezterm.strftime '%a %b %-d %H:%M ' - - local bat = '' - for _, b in ipairs(wezterm.battery_info()) do - bat = - '🔋 ' .. string.format('%.0f%%', b.state_of_charge * 100) .. ' ' .. - b.state - end - - window:set_right_status(wezterm.format {{Text = bat .. ' ' .. date}}) -end) - -wezterm.on("set-up-dotfile-workspace", function(window, pane) - -- Set a workspace for coding on a current project - -- Top pane is for the editor, bottom pane is for the build tool - local project_dir = wezterm.home_dir .. '/projects/test/quarto/quarto-test' - local tab, build_pane, window = mux.spawn_window { - workspace = 'coding', - cwd = project_dir, - args = args - } - local editor_pane = build_pane:split{ - direction = 'Top', - size = 0.6, - cwd = project_dir - } - build_pane:send_text 'quarto check' - mux.set_active_workspace 'coding' -end) +-- wezterm.on("set-up-dotfile-workspace", function(window, pane) +-- -- Set a workspace for coding on a current project +-- -- Top pane is for the editor, bottom pane is for the build tool +-- local project_dir = wezterm.home_dir .. '/projects/test/quarto/quarto-test' +-- local tab, build_pane, window = mux.spawn_window { +-- workspace = 'coding', +-- cwd = project_dir, +-- args = args +-- } +-- local editor_pane = build_pane:split{ +-- direction = 'Top', +-- size = 0.6, +-- cwd = project_dir +-- } +-- build_pane:send_text 'quarto check' +-- mux.set_active_workspace 'coding' +-- end) -- -- wezterm.on('gui-startup', function(cmd) -- -- allow `wezterm start -- something` to affect what we spawn @@ -92,16 +62,17 @@ return { hide_tab_bar_if_only_one_tab = true, use_fancy_tab_bar = false, tab_bar_at_bottom = true, - window_padding = {left = 0, right = 0, top = 0, bottom = 0}, + window_padding = { left = 0, right = 0, top = 0, bottom = 0 }, + + color_scheme = "Mexico Light (base16)", - color_scheme = "Nord (base16)", -- default_prog = {"nu"}, scrollback_lines = 10000, font = wezterm.font('Liga Iosevka'), line_height = 1.0, - leader = {key = 'a', mods = 'CTRL', timeout_milliseconds = 1500}, + leader = { key = 'a', mods = 'CTRL', timeout_milliseconds = 1500 }, keys = maps.keys, key_tables = maps.key_tables } From e92e7e5b1ca55269bdb3ca3031d30563a8d8abd4 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 25 Nov 2022 17:00:00 +0100 Subject: [PATCH 06/14] vifm: Change default image opener to timg Changed opening images by default to do so on the commandline itself, using timg. Other openers can still be invoked through the `:file` command like before. --- vifm/.config/vifm/vifmrc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/vifm/.config/vifm/vifmrc b/vifm/.config/vifm/vifmrc index 5483da3..f1938f2 100644 --- a/vifm/.config/vifm/vifmrc +++ b/vifm/.config/vifm/vifmrc @@ -392,6 +392,8 @@ filextype *.avi,*.mp4,*.wmv,*.dat,*.3gp,*.ogv,*.mkv,*.mpg,*.mpeg,*.vob, \*.as[fx] \ {View using unique mplayer instance} \ umpv %f &, + \ {View in timg} + \ timg --title --center --clear %f; read -k 1 -s -r, \ {View using ffplay} \ ffplay -fs -autoexit %f, \ {View using Dragon} @@ -425,6 +427,8 @@ fileviewer *.[1-8] man ./%c | col -b " Gif filextype *.gif + \ {View in timg} + \ timg --loops=2 --title --center --clear %f; read -k 1 -s -r, \ {Loop} \ mpv --loop=inf %f %i &, fileviewer *.gif @@ -434,6 +438,8 @@ fileviewer *.gif " Images filextype *.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm + \ {View in timg} + \ timg --title --center --clear %f; read -k 1 -s -r, \ {View in nsxiv directory viewer} \ vifm-thumbnailer %c, \ {View in nsxiv} @@ -447,9 +453,7 @@ filextype *.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm \ {View in gpicview} \ gpicview %c, fileviewer *.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm - \ kitty +kitten icat --silent --transfer-mode=stream --place=%pwx%ph@%pxx%py %c %N - \ %pc - \ kitty +kitten icat --clear --silent %pd + \ timg -g%pwx%ph -pq %c " OpenRaster filextype *.ora From dff4308b4d6caeb0cead1cac7297f5bd19a55ef5 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 25 Nov 2022 17:01:32 +0100 Subject: [PATCH 07/14] nvim: Change to Navigator fork supporting wezterm Changed to personal fork of Navigator which supports wezterm for the time being - until the changes are merged in some fashion upstream. --- nvim/.config/nvim/lua/plugins.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua index 5bc3c37..c2990d4 100644 --- a/nvim/.config/nvim/lua/plugins.lua +++ b/nvim/.config/nvim/lua/plugins.lua @@ -21,7 +21,8 @@ require("packer").startup(function() -- vim plugs -- essential use { - 'numToStr/Navigator.nvim', + 'marty-oehme/Navigator.nvim', + branch = 'feat/add-wezterm-navigation', config = function() require('Navigator').setup() end } -- allow seamless navigation between vim buffers and tmux splits use 'jeffkreeftmeijer/vim-numbertoggle' -- toggles numbers to absolute for all buffers but the current which is relative From ea3779399752ea414400d1c42a547de85dac3aab Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 8 Dec 2022 13:05:36 +0100 Subject: [PATCH 08/14] wezterm: Default to dark theme and general font Generalized the font used from special ligaturized Iosevka to the standard Iosevka installed in the bootstrap process. Changed from a blindingly bright default color scheme to a nice dark one (Nord). --- wezterm/.config/wezterm/wezterm.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wezterm/.config/wezterm/wezterm.lua b/wezterm/.config/wezterm/wezterm.lua index 33a7923..24905df 100644 --- a/wezterm/.config/wezterm/wezterm.lua +++ b/wezterm/.config/wezterm/wezterm.lua @@ -64,12 +64,12 @@ return { tab_bar_at_bottom = true, window_padding = { left = 0, right = 0, top = 0, bottom = 0 }, - color_scheme = "Mexico Light (base16)", + color_scheme = "Nord (base16)", -- default_prog = {"nu"}, scrollback_lines = 10000, - font = wezterm.font('Liga Iosevka'), + font = wezterm.font('Iosevka'), line_height = 1.0, leader = { key = 'a', mods = 'CTRL', timeout_milliseconds = 1500 }, From b33ae09a3335f8dfceafadeb379213fc5d9d5523 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 8 Dec 2022 13:28:00 +0100 Subject: [PATCH 09/14] nvim: Disable automatic formatting on save Had to disable automatic formatting since it was messing with my contributions to other git projects, if they did either not have a formatter enabled (most of the time) or had different formatters or those set up differently than this setup (fixable, but I don't think it's worth the time). Instead, formatting can be invoked with `f`/`F` to format or format and save respectively. --- nvim/.config/nvim/lua/maps.lua | 5 +++++ nvim/.config/nvim/lua/plug/_format.lua | 16 +++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/nvim/.config/nvim/lua/maps.lua b/nvim/.config/nvim/lua/maps.lua index cc8a371..7c889a0 100644 --- a/nvim/.config/nvim/lua/maps.lua +++ b/nvim/.config/nvim/lua/maps.lua @@ -184,6 +184,11 @@ map.n.nore.silent['q'] = 'gqap' map.x.nore.silent['q'] = 'gq' map.n.nore.silent['Q'] = 'vapJgqap' +-- FORMAT code with +-- PLUGIN: formatter.nvim +map.n.nore.silent['f'] = ':FormatLock' +map.n.nore.silent['F'] = ':FormatWriteLock' + -- Enter distraction free prose mode with F11 map.n.nore.silent[''] = ':ZenMode' diff --git a/nvim/.config/nvim/lua/plug/_format.lua b/nvim/.config/nvim/lua/plug/_format.lua index e4cdeac..88c461b 100644 --- a/nvim/.config/nvim/lua/plug/_format.lua +++ b/nvim/.config/nvim/lua/plug/_format.lua @@ -52,11 +52,13 @@ local formatters = { require('formatter').setup({ logging = false, filetype = formatters }) -- Format on save: +-- DISABLED FOR NOW, due to messing with git contributions if they +-- do not use a formatter. Instead, formatting with key mapping used. -- gather filetypes to autocorrect for each activated formatter above -for k, _ in pairs(formatters) do - vim.api.nvim_create_autocmd({"Filetype " .. k}, { - command = "autocmd BufWritePost FormatWrite", - desc = "Automatically format on write", - group = vim.api.nvim_create_augroup('formatonsave', {clear = true}) - }) -end +-- for k, _ in pairs(formatters) do +-- vim.api.nvim_create_autocmd({"Filetype " .. k}, { +-- command = "autocmd BufWritePost FormatWrite", +-- desc = "Automatically format on write", +-- group = vim.api.nvim_create_augroup('formatonsave', {clear = true}) +-- }) +-- end From 1c983b2dce235f9459498cef69367da38ab96b9e Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 8 Dec 2022 13:30:20 +0100 Subject: [PATCH 10/14] nvim: Fix automatic packer installation Updated to new recommended bootstrapping for packer itself, straight from the project respository. --- nvim/.config/nvim/lua/plugins.lua | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua index c2990d4..bee0e73 100644 --- a/nvim/.config/nvim/lua/plugins.lua +++ b/nvim/.config/nvim/lua/plugins.lua @@ -1,10 +1,16 @@ -local install_path = vim.fn.stdpath("data") .. "/pack/packer/start/packer.nvim" - -if vim.fn.empty(vim.fn.glob(install_path)) > 0 then - vim.cmd("!git clone https://github.com/wbthomason/packer.nvim " .. - install_path) +local ensure_packer = function() + local fn = vim.fn + local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim' + if fn.empty(fn.glob(install_path)) > 0 then + fn.system({ 'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path }) + vim.cmd [[packadd packer.nvim]] + return true + end + return false end +local packer_bootstrap = ensure_packer() + -- Compile on plugin edits vim.api.nvim_create_autocmd({ "BufWritePost" }, { pattern = "plugins.lua", @@ -233,4 +239,9 @@ require("packer").startup(function() } require('plug._cmp') + -- Automatically set up your configuration after cloning packer.nvim + -- Put this at the end after all plugins + if packer_bootstrap then + require('packer').sync() + end end) From f325456e603bfca210ffbf68e65a96743df29732 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 8 Dec 2022 13:31:07 +0100 Subject: [PATCH 11/14] zsh: Check for additional plugins Checking for a couple additional plugins and automatically sourcing them - mostly alternate versions of previous plugins. --- zsh/.config/zsh/.zshrc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc index d475cca..8bcfa50 100644 --- a/zsh/.config/zsh/.zshrc +++ b/zsh/.config/zsh/.zshrc @@ -23,11 +23,15 @@ source /usr/share/oh-my-zsh/plugins/colored-man-pages/colored-man-pages.plugin.z source /usr/share/oh-my-zsh/plugins/command-not-found/command-not-found.plugin.zsh source /usr/share/fzf/key-bindings.zsh #source /usr/share/nvm/init-nvm.sh +## find the correct installed tab-completion version [ -e $PLUG_FOLDER/fzf-tab/fzf-tab.plugin.zsh ] && source $PLUG_FOLDER/fzf-tab/fzf-tab.plugin.zsh +[ -e $PLUG_FOLDER/fzf-tab-bin-git/fzf-tab.plugin.zsh ] && source $PLUG_FOLDER/fzf-tab-bin-git/fzf-tab.plugin.zsh # these need to be sourced after fzf-tab [ -e $PLUG_FOLDER/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh ] && source $PLUG_FOLDER/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh +[ -e $PLUG_FOLDER/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ] && source $PLUG_FOLDER/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh [ -e $PLUG_FOLDER/alias-tips/alias-tips.plugin.zsh ] && source $PLUG_FOLDER/alias-tips/alias-tips.plugin.zsh [ -e $PLUG_FOLDER/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh ] && source $PLUG_FOLDER/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh +[ -e $PLUG_FOLDER/zsh-vi-mode/zsh-vi-mode.plugin.zsh ] && source $PLUG_FOLDER/zsh-vi-mode/zsh-vi-mode.plugin.zsh unset PLUG_FOLDER # simple fzf-tab settings From 83f40d6f85268920e9a65bec2a82c017f584e739 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 8 Dec 2022 13:38:16 +0100 Subject: [PATCH 12/14] wayland: Set up basic multi-display support Added continuous wallpaper setting and different settings for laptop use (only one screen enabled) and docked use (two screens enabled and laptop screen disabled) using the wonderful `kanshi` program. --- wayland/.config/kanshi/config | 9 +++++++++ wayland/.config/river/init | 15 ++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 wayland/.config/kanshi/config diff --git a/wayland/.config/kanshi/config b/wayland/.config/kanshi/config new file mode 100644 index 0000000..dc7010e --- /dev/null +++ b/wayland/.config/kanshi/config @@ -0,0 +1,9 @@ +profile docked { + output eDP-1 disable + output "Goldstar Company Ltd W2442 0x000075FD" position 1920,0 + output "Goldstar Company Ltd W2442 0x000075E1" position 0,0 +} + +profile single { + output eDP-1 enable position 0,0 +} diff --git a/wayland/.config/river/init b/wayland/.config/river/init index 010d5e5..cdb08bb 100755 --- a/wayland/.config/river/init +++ b/wayland/.config/river/init @@ -224,12 +224,25 @@ for pad in $(riverctl list-inputs | grep -i touchscreen); do done setxkbmap -option "compose:menu" -exec swaybg -i ~/pictures/wall.jpg -o '*' -m fill & +# set a nice wallpaper +exec swww init & +if [ -e "$HOME/pictures/wall_l.jpg" ] && [ -e "$HOME/pictures/wall_r.jpg" ]; then + swww img -o DP-5 "$HOME/pictures/wall_l.jpg" & + swww img -o DP-3 "$HOME/pictures/wall_r.jpg" & +elif [ -e "$HOME/pictures/wall.jpg" ]; then + swww img "$HOME/pictures/wall.jpg" & +fi + # killall mako # mako & + +# start status bar killall waybar exec waybar & +# start dynamic display configuration +exec kanshi & + killall clipman exec wl-paste -t text --watch clipman store & # bash ~/.config/bin/gtktheme # setting our gtk variables From ec5dd2419877e19b4fd934669bd1ed5dcb7150c9 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 8 Dec 2022 13:39:40 +0100 Subject: [PATCH 13/14] nvim: Bootstrap spellfile if not existing Neovim sometimes errors out when enabling spelling without having all the necessary spellfiles available. This ensures on setting up the environment that a spellfile is downloaded. --- nvim/.config/sh/env.d/set-up-spellfile.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 nvim/.config/sh/env.d/set-up-spellfile.sh diff --git a/nvim/.config/sh/env.d/set-up-spellfile.sh b/nvim/.config/sh/env.d/set-up-spellfile.sh new file mode 100644 index 0000000..39eac18 --- /dev/null +++ b/nvim/.config/sh/env.d/set-up-spellfile.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env sh +# Set up a non-english spell dictionary if it doesn't exist yet. + +if [ ! -e "${XDG_DATA_HOME:-$HOME/.local/share}/nvim/site/spell/de.utf-8.spl" ]; then + echo "Neovim spell dictionary not yet installed, downloading..." + mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}/nvim/site/spell/" + wget -q 'https://ftp.nluug.nl/pub/vim/runtime/spell/de.utf-8.spl' -O "${XDG_DATA_HOME:-$HOME/.local/share}/nvim/site/spell/de.utf-8.spl" + echo "Done." +fi + + From 5a9a4e7162456207237ca7add16253cf06cc0ec6 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 8 Dec 2022 13:40:36 +0100 Subject: [PATCH 14/14] qutebrowser: Add pcgamingwiki search Now that I have time to enjoy a game every now and again once more, pcgamingwiki is a wonderful resource to start looking into all sorts of compatibility issues and troubleshooting, so it is added as a qutebrowser search engine as `pcw`. --- qutebrowser/.config/qutebrowser/url.py | 1 + 1 file changed, 1 insertion(+) diff --git a/qutebrowser/.config/qutebrowser/url.py b/qutebrowser/.config/qutebrowser/url.py index f09f43f..c2d63f0 100644 --- a/qutebrowser/.config/qutebrowser/url.py +++ b/qutebrowser/.config/qutebrowser/url.py @@ -20,6 +20,7 @@ c.url.searchengines = { "lib": "http://libgen.fun/search.php?req={}", "man": "https://manned.org/browse/search?q={}", "maps": "https://www.qwant.com/maps/?q={}", + "pcw": "https://www.pcgamingwiki.com/w/index.php?search={}", "r": "https://www.reddit.com/r/{}", "t": "https://www.thesaurus.com/browse/{}", "w": "https://en.wikipedia.org/w/index.php?search={}",