From 2eccfe88ec97b933b560e287e07ead7ae48bf4fc Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 10 Feb 2025 14:45:04 +0100 Subject: [PATCH 01/12] jj: Improve default log invocation The default log invoked when hitting `j` is now composed of the working copy history as well as all ancestors, recent commits to visible heads and the trunk. `jl` shows the same view, only as oneline commits. --- vcs/jj/config/sh/alias.d/jj.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vcs/jj/config/sh/alias.d/jj.sh b/vcs/jj/config/sh/alias.d/jj.sh index a68adf2..db2422a 100644 --- a/vcs/jj/config/sh/alias.d/jj.sh +++ b/vcs/jj/config/sh/alias.d/jj.sh @@ -4,7 +4,7 @@ if ! exist jj; then return 1 fi -alias j='jj' # necessary for a thing as easy to type? +alias j="jj log -r '@ | ancestors(trunk()..(visible_heads() & mine()), 2) | trunk()'" if exist lazyjj; then alias lj="lazyjj" fi @@ -16,7 +16,7 @@ alias jds="jj describe" alias jc="jj commit" alias jln="jj log -T builtin_log_oneline" -alias jl="jj log -r '@ | ancestors(remote_bookmarks().., 2) | trunk()'" +alias jl="jj log -r '@ | ancestors(trunk()..(visible_heads() & mine()), 3) | trunk()' -T builtin_log_oneline" alias jL="jj log -r 'all()'" alias jlo="jj log --summary" alias jLO="jj log --summary -r 'all()'" From 7922e5285f145122c4e31466c160d2b536008503 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 7 Feb 2025 23:35:16 +0100 Subject: [PATCH 02/12] jj: Add alias for showing a commit with description --- vcs/jj/config/sh/alias.d/jj.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/vcs/jj/config/sh/alias.d/jj.sh b/vcs/jj/config/sh/alias.d/jj.sh index db2422a..7734a27 100644 --- a/vcs/jj/config/sh/alias.d/jj.sh +++ b/vcs/jj/config/sh/alias.d/jj.sh @@ -8,13 +8,21 @@ alias j="jj log -r '@ | ancestors(trunk()..(visible_heads() & mine()), 2) | trun if exist lazyjj; then alias lj="lazyjj" fi -alias js="jj status" -alias jd="jj diff" alias jn="jj new" alias jds="jj describe" alias jc="jj commit" +# finding out the current snapshot +js() { + if [ "$#" -eq 0 ]; then + jj status + else + jj show "$*" + fi +} +alias jw="jj show" +alias jd="jj diff" alias jln="jj log -T builtin_log_oneline" alias jl="jj log -r '@ | ancestors(trunk()..(visible_heads() & mine()), 3) | trunk()' -T builtin_log_oneline" alias jL="jj log -r 'all()'" From 0bd604298f574f9d3a9b2d36e3f6b87345975502 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 7 Feb 2025 23:15:09 +0100 Subject: [PATCH 03/12] jj: Add git commit signing and private commits Git commits, on push, will be signed by default (just like my git configuration itself) but *not* every change is signed since that is a hassle with the working copy technically also being an ever changing git commit. Additionally, added a private-commit option which will refuse to push commits beginning with 'wip: ' to any remote, which is not super useful for my current use cases but also a nice feature and fun to experiment with for the future. --- vcs/jj/config/jj/config.toml | 6 +++++- vcs/jj/config/sh/alias.d/jj.sh | 20 +++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/vcs/jj/config/jj/config.toml b/vcs/jj/config/jj/config.toml index 84b0f0f..1636b18 100644 --- a/vcs/jj/config/jj/config.toml +++ b/vcs/jj/config/jj/config.toml @@ -3,10 +3,14 @@ email = "marty.oehme@gmail.com" name = "Marty Oehme" [signing] -sign-all = false backend = "gpg" key = "73BA40D5AFAF49C9" +[git] +sign-on-push = true +subprocess = true +private-commits = "description(glob:'wip:*')" # refuse to push WIP commits + [ui] default-command = "log" diff-editor = ["nvim", "-c", "DiffEditor $left $right $output"] diff --git a/vcs/jj/config/sh/alias.d/jj.sh b/vcs/jj/config/sh/alias.d/jj.sh index 7734a27..4a59f92 100644 --- a/vcs/jj/config/sh/alias.d/jj.sh +++ b/vcs/jj/config/sh/alias.d/jj.sh @@ -23,6 +23,18 @@ js() { } alias jw="jj show" alias jd="jj diff" + +# for describe-and-edit workflows +# https://steveklabnik.github.io/jujutsu-tutorial/real-world-workflows/the-edit-workflow.html +alias je="jj edit" +alias jee="jj next --edit" + +# for squash-and-go workflows +# https://steveklabnik.github.io/jujutsu-tutorial/real-world-workflows/the-squash-workflow.html +alias jss="jj squash" +alias jsi="jj squash --interactive" + +# revset info alias jln="jj log -T builtin_log_oneline" alias jl="jj log -r '@ | ancestors(trunk()..(visible_heads() & mine()), 3) | trunk()' -T builtin_log_oneline" alias jL="jj log -r 'all()'" @@ -40,13 +52,7 @@ jloof() { jj log --patch -r "description($*)" } -alias jss="jj squash" -alias jsi="jj squash --interactive" - -alias je="jj edit" -alias jee="jj next --edit" - -# show branches w a couple commits +# show branches (i.e. head commits) w a couple previous commits alias jb="jj log -r 'ancestors(heads(all()), 3)'" alias jrb="jj rebase" From 9df2d06a06dc604facdbc885986b6c0f66235d67 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 10 Feb 2025 11:50:10 +0100 Subject: [PATCH 04/12] nvim: Add previews for images and gifs to fzf-lua --- nvim/.config/nvim/lua/plugins/pickers.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nvim/.config/nvim/lua/plugins/pickers.lua b/nvim/.config/nvim/lua/plugins/pickers.lua index fdd415c..8072d32 100644 --- a/nvim/.config/nvim/lua/plugins/pickers.lua +++ b/nvim/.config/nvim/lua/plugins/pickers.lua @@ -71,7 +71,9 @@ return { -- file/item pickers and managers previewers = { builtin = { extensions = { - ["png"] = { "viu" }, + ["png"] = { "chafa", "--format=symbols", "{file}" }, + ["jpg"] = { "chafa", "--format=symbols", "{file}" }, + ["gif"] = { "chafa", "--format=symbols", "{file}" }, ["svg"] = { "chafa", "--format=symbols", "{file}" }, }, }, From 43aefd2369b74f318679d237430d8c18ac4f3286 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 10 Feb 2025 12:03:48 +0100 Subject: [PATCH 05/12] jj: Automatically show git diff for commit descriptions --- vcs/jj/config/jj/config.toml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/vcs/jj/config/jj/config.toml b/vcs/jj/config/jj/config.toml index 1636b18..6f5f82d 100644 --- a/vcs/jj/config/jj/config.toml +++ b/vcs/jj/config/jj/config.toml @@ -18,3 +18,16 @@ pager = "delta" [ui.diff] format = "git" # for the time being to use delta well + +[templates] +draft_commit_description = ''' +concat( + description, + surround( + "\nJJ: This commit contains the following changes:\n", "", + indent("JJ: ", diff.stat(72)), + ), + "\nJJ: ignore-rest\n", + diff.git(), +) +''' From 98c54443e9aa8a4b99abc8205c1b2354ec88fc55 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 10 Feb 2025 12:08:29 +0100 Subject: [PATCH 06/12] git: Add pr alias which fetches a specific github pull request Used like `g pr 1234` to create local pr/1234 branch. --- vcs/git/config/git/config | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/vcs/git/config/git/config b/vcs/git/config/git/config index c73b86d..6164279 100644 --- a/vcs/git/config/git/config +++ b/vcs/git/config/git/config @@ -30,12 +30,14 @@ delta = "![ $TERM_DARK = false ] && delta --light || delta" # Take care that we always display right color scheme # check out a github PR directly on the commandline, creates pr/4 or pr/ branch locally - pr = "!f() { git fetch -fu ${2:-$(git remote |grep ^github || echo origin)} refs/pull/$1/head:pr/$1 }; f" + pr = "!f() { git fetch -fu ${2:-$(git remote |grep ^github || echo origin)} refs/pull/$1/head:pr/$1 }; f" # remove all pr/ local branches - pr-clean = "!git for-each-ref refs/heads/pr/* --format='%(refname)' | while read ref ; do branch=${ref#refs/heads/} ; git branch -D $branch ; done" + pr-clean = "!git for-each-ref refs/heads/pr/* --format = '%(refname)' | while read ref ; do branch = ${ref#refs/heads/} ; git branch -D $branch ; done" [commit] gpgsign = true # sign commits as me verbose = true # Always show diff when preparing commit message +[tag] + gpgsign = true [fetch] prune = true # remove references to non-existent remote branches [pull] @@ -45,7 +47,7 @@ [difftool] prompt = false [difftool "difftastic"] - cmd = difft "$LOCAL" "$REMOTE" + cmd = difft "$LOCAL" "$REMOTE" [color "diff"] meta = "9" frag = "magenta bold" From 14e33641556c7d4584413d9f8f692083a081f995 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 10 Feb 2025 11:46:29 +0100 Subject: [PATCH 07/12] starship: Remove general custom component display --- terminal/.config/starship.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/terminal/.config/starship.toml b/terminal/.config/starship.toml index 16a4bce..a7b888f 100644 --- a/terminal/.config/starship.toml +++ b/terminal/.config/starship.toml @@ -1,5 +1,4 @@ format = """ -$custom\ $sudo\ $username\ $directory\ @@ -77,3 +76,7 @@ disabled = false symbol = " 󱍔 " style = 'bold yellow' format = "[$symbol]($style)" + +# TODO: Would be lovely to have jujutsu support here +# An example implementation: https://github.com/jj-vcs/jj/wiki/Starship +# But currently very slow. Can be added with e.g. '${custom.jj}\' in format above From 25c678824737229b1ce562f98ec99d5ccd8d5edd Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 10 Feb 2025 17:29:05 +0100 Subject: [PATCH 08/12] jj: Make aliased log revset default in config Instead of aliasing the revset I am always using currently, we simply set it to be the default for any log command. If we want a different revset we can still supply it. Other aliases keep different revsets (e.g. `jL` variants for `all()` revsets). --- vcs/jj/config/jj/config.toml | 4 +++- vcs/jj/config/sh/alias.d/jj.sh | 5 ++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/vcs/jj/config/jj/config.toml b/vcs/jj/config/jj/config.toml index 6f5f82d..8476f5c 100644 --- a/vcs/jj/config/jj/config.toml +++ b/vcs/jj/config/jj/config.toml @@ -12,7 +12,6 @@ subprocess = true private-commits = "description(glob:'wip:*')" # refuse to push WIP commits [ui] -default-command = "log" diff-editor = ["nvim", "-c", "DiffEditor $left $right $output"] pager = "delta" @@ -31,3 +30,6 @@ concat( diff.git(), ) ''' + +[revsets] +log = "@ | ancestors(trunk()..(visible_heads() & mine()), 2) | trunk()" diff --git a/vcs/jj/config/sh/alias.d/jj.sh b/vcs/jj/config/sh/alias.d/jj.sh index 4a59f92..92f3092 100644 --- a/vcs/jj/config/sh/alias.d/jj.sh +++ b/vcs/jj/config/sh/alias.d/jj.sh @@ -4,7 +4,7 @@ if ! exist jj; then return 1 fi -alias j="jj log -r '@ | ancestors(trunk()..(visible_heads() & mine()), 2) | trunk()'" +alias j="jj" if exist lazyjj; then alias lj="lazyjj" fi @@ -35,8 +35,7 @@ alias jss="jj squash" alias jsi="jj squash --interactive" # revset info -alias jln="jj log -T builtin_log_oneline" -alias jl="jj log -r '@ | ancestors(trunk()..(visible_heads() & mine()), 3) | trunk()' -T builtin_log_oneline" +alias jl="jj log -T builtin_log_oneline" alias jL="jj log -r 'all()'" alias jlo="jj log --summary" alias jLO="jj log --summary -r 'all()'" From cfa59ae9df6542efa05e5c63b9c16f0301b74db8 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 10 Feb 2025 17:07:37 +0100 Subject: [PATCH 09/12] jj: Add revset aliases --- vcs/jj/config/jj/config.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vcs/jj/config/jj/config.toml b/vcs/jj/config/jj/config.toml index 8476f5c..e3d2f2b 100644 --- a/vcs/jj/config/jj/config.toml +++ b/vcs/jj/config/jj/config.toml @@ -33,3 +33,9 @@ concat( [revsets] log = "@ | ancestors(trunk()..(visible_heads() & mine()), 2) | trunk()" + +[revset-aliases] +"bases" = "dev" +"downstream(x,y)" = "(x::y) & y" +"branches" = "downstream(trunk(), bookmarks()) & mine()" +"curbranch" = "latest(branches::@- & branches)" From 98dad64976ad0512d424059ea206e17734aa8541 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 12 Feb 2025 18:29:16 +0100 Subject: [PATCH 10/12] jj: Add jj insert alias for forgotten commits Allows the user to just use the `ji` alias to quickly create a (previous) change, commit whatever they forgot and move back to the current commit. --- vcs/jj/config/sh/alias.d/jj.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/vcs/jj/config/sh/alias.d/jj.sh b/vcs/jj/config/sh/alias.d/jj.sh index 92f3092..2e51bfa 100644 --- a/vcs/jj/config/sh/alias.d/jj.sh +++ b/vcs/jj/config/sh/alias.d/jj.sh @@ -34,6 +34,12 @@ alias jee="jj next --edit" alias jss="jj squash" alias jsi="jj squash --interactive" +# oops buttons +alias ju="jj undo" +# for damn,-forgot-to-split-this-commit workflow +# Creates a new commit before with your selected changes, lets you describe it and carry on +alias ji="jj new -B@ --no-edit && jj squash --interactive && jj edit '@-' && jj describe && jj edit '@+'" + # revset info alias jl="jj log -T builtin_log_oneline" alias jL="jj log -r 'all()'" @@ -56,6 +62,5 @@ alias jb="jj log -r 'ancestors(heads(all()), 3)'" alias jrb="jj rebase" -alias ju="jj undo" alias jp="jj git push" From 1ab2b3a94fc182eb6be2f6ff39bc626025e6d476 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 14 Feb 2025 10:26:02 +0100 Subject: [PATCH 11/12] river: Change to swaybg for stable wallpaper setting Multi-output wallpaper setting was never particularly stable using swww. Using swaybg we can directly call on the 'description' of the outputs like we do in kanshi. This makes the interface way more stable than hoping that 'DP-3' and or 'DP-5' are discovered first. Thus, we default to use swaybg and my screens, but if the program is not found on the system we can still fall back to swww. --- desktop/.config/river/init | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/desktop/.config/river/init b/desktop/.config/river/init index d7b86d1..f60427b 100755 --- a/desktop/.config/river/init +++ b/desktop/.config/river/init @@ -270,12 +270,18 @@ setxkbmap -option "compose:menu" [ "$(pidof kanshi)" -eq 0 ] || riverctl spawn kanshi # set a nice wallpaper -if exist swww; then - riverctl spawn "swww init" +if exist swaybg; then + killall swaybg + riverctl spawn "swaybg \ + -o 'LG Electronics W2442 0x000574E1' -i pictures/wall_l.jpg \ + -o 'LG Electronics W2442 0x000574FD' -i pictures/wall_r.jpg \ + " +elif exist swww; then + riverctl spawn "swww-daemon" outputs=$(swww query | cut -d':' -f1) if [ "$(echo "$outputs" | grep -c -e '^DP')" -eq 2 ] && [ -e "$HOME/pictures/wall_r.jpg" ]; then - swww img -o "$(echo "$outputs" | head -n1)" "$HOME/pictures/wall_r.jpg" - swww img -o "$(echo "$outputs" | tail -n1)" "$HOME/pictures/wall_l.jpg" + swww img -o "$(echo "$outputs" | head -n1)" "$HOME/pictures/wall_l.jpg" + swww img -o "$(echo "$outputs" | tail -n1)" "$HOME/pictures/wall_r.jpg" elif [ -e "$HOME/pictures/wall.jpg" ]; then swww img "$HOME/pictures/wall.jpg" fi From c19dbefb2cfd55c7a905613211087635297a66a6 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 10 Feb 2025 19:21:01 +0100 Subject: [PATCH 12/12] river: Add init reload without program restarts By passing the 'no-restart' argument as the first parameter of the river init file, we can prevent program restarting which we do not want to have restarted every time (e.g. kanshi, wlsunset, waybar, swayidle, etc) By default these programs will still always be restarted. However, passing the parameter means that if the program is already running, we do not restart it. If the program is not yet running it will still be started like normally. The functionality makes use of the `pidof` program, so on Arch it requires the 'procps-ng' package. This is by default installed as a requirement for the 'base' package group. Reverted changes from earlier wallpaper switch. --- desktop/.config/river/init | 53 +++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/desktop/.config/river/init b/desktop/.config/river/init index f60427b..dcf40a2 100755 --- a/desktop/.config/river/init +++ b/desktop/.config/river/init @@ -8,6 +8,23 @@ time_to_lockscreen=300 time_to_screendim=600 time_to_suspend=900 +NO_RESTART="$1" +should_start() { # 1=program binary name + # not running, start + if ! pidof "$1"; then + return 0 + fi + + # only reload, no restarting + if [ "$NO_RESTART" = "no-restart" ]; then + return 1 + else + # kill then it can restart + killall "$1" + return 0 + fi +} + ## OPTIONS riverctl spawn "dbus-update-activation-environment SEATD_SOCK DISPLAY WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=river" riverctl focus-follows-cursor normal @@ -31,7 +48,8 @@ riverctl rule-add -app-id "org.pwmt.zathura" csd ## DEBUG # Reload river configuration -riverctl map normal $mod+Shift F12 spawn "$HOME/.config/river/init" +riverctl map normal $mod+Shift F12 spawn "$HOME/.config/river/init no-restart" +riverctl map normal $mod+Shift+Control F12 spawn "$HOME/.config/river/init" ## HOTKEYS # close focused view @@ -125,7 +143,7 @@ riverctl map normal $mod+Control L snap right # Mod+F to toggle fullscreen riverctl map normal $mod F toggle-fullscreen # if we are running filtile we also have access to monocle mode -if [ "$layout" = "filtile" ]; then +if [ "$layout" = "filtile" ]; then riverctl map normal $mod+Shift F spawn "riverctl send-layout-cmd $layout monocle" fi @@ -267,7 +285,7 @@ done setxkbmap -option "compose:menu" # start dynamic display configuration -[ "$(pidof kanshi)" -eq 0 ] || riverctl spawn kanshi +should_start kanshi && riverctl spawn kanshi # set a nice wallpaper if exist swaybg; then @@ -288,37 +306,36 @@ elif exist swww; then fi # start status bar -killall waybar -riverctl spawn waybar +should_start waybar && riverctl spawn waybar # start redshift-like sundown warming using current location or standard values -killall wlsunset -loc=$(curl ipinfo.io | grep -e '"loc": ' | sed -e 's/^.*"loc": "\(.*\)",$/\1/') -if [ -n "$loc" ]; then - riverctl spawn "wlsunset -l \"$(echo "$loc" | cut -d, -f1)\" -L \"$(echo "$loc" | cut -d, -f2)\"" -else - riverctl spawn "wlsunset -S \"09:00\" -s \"21:00\" -d \"3600\"" +if should_start wlsunset; then + loc=$(curl ipinfo.io | grep -e '"loc": ' | sed -e 's/^.*"loc": "\(.*\)",$/\1/') + if [ -n "$loc" ]; then + riverctl spawn "wlsunset -l \"$(echo "$loc" | cut -d, -f1)\" -L \"$(echo "$loc" | cut -d, -f2)\"" + else + riverctl spawn "wlsunset -S \"09:00\" -s \"21:00\" -d \"3600\"" + fi + unset loc fi -unset loc # start screen idle locking/dimming/sleep tool -killall swayidle -riverctl spawn "swayidle \ +should_start swayidle && riverctl spawn "swayidle \ timeout ${time_to_suspend} \"[ $(cat /sys/class/power_supply/AC/online) -eq 0 ] && systemctl suspend-then-hibernate\" timeout ${time_to_screendim} \"wlopm --off '*'\" \ resume \"wlopm --on '*'\" \ timeout ${time_to_lockscreen} \"pidof waylock || lockscreen\" \ after-resume \"wlopm --on '*'\" \ before-sleep \"pidof waylock || lockscreen\" &" -killall clipman -riverctl spawn "wl-paste -t text --watch clipman store" + +should_start wl-paste && riverctl spawn "wl-paste -t text --watch clipman store" + # bash ~/.config/bin/gtktheme # setting our gtk variables # killall polkit-gnome-authentication-agent-1 # /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 & # start layouting engine killall $layout -riverctl spawn "$layout\ - --tags all --output all main-ratio 0.65,\ +riverctl spawn "$layout --tags all --output all main-ratio 0.65,\ --tags all --output all view-padding 6,\ --tags all --output all outer-padding 0,\ --tags all --output all smart-padding on,\