From f63ba5be2e8e3726046d3d273d50b5e412058ae2 Mon Sep 17 00:00:00 2001 From: Ted Kulp Date: Mon, 15 Sep 2025 16:28:02 -0400 Subject: [PATCH] changes --- .config/ghostty/config | 2 +- .config/ghostty/shaders/cursor_blaze.glsl | 116 ++++++++++++++++++++++ .config/tmux/tmux.conf##template.j2 | 7 +- 3 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 .config/ghostty/shaders/cursor_blaze.glsl diff --git a/.config/ghostty/config b/.config/ghostty/config index ebe9f6c..5cc95b5 100644 --- a/.config/ghostty/config +++ b/.config/ghostty/config @@ -138,7 +138,7 @@ shell-integration = detect shell-integration-features = cursor,no-sudo,title osc-color-report-format = 16-bit vt-kam-allowed = false -custom-shader = +custom-shader = ./shaders/cursor_blaze.glsl custom-shader-animation = true macos-non-native-fullscreen = false macos-titlebar-style = hidden diff --git a/.config/ghostty/shaders/cursor_blaze.glsl b/.config/ghostty/shaders/cursor_blaze.glsl new file mode 100644 index 0000000..6da0090 --- /dev/null +++ b/.config/ghostty/shaders/cursor_blaze.glsl @@ -0,0 +1,116 @@ +float getSdfRectangle(in vec2 p, in vec2 xy, in vec2 b) +{ + vec2 d = abs(p - xy) - b; + return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0); +} + +// Based on Inigo Quilez's 2D distance functions article: https://iquilezles.org/articles/distfunctions2d/ +// Potencially optimized by eliminating conditionals and loops to enhance performance and reduce branching + +float seg(in vec2 p, in vec2 a, in vec2 b, inout float s, float d) { + vec2 e = b - a; + vec2 w = p - a; + vec2 proj = a + e * clamp(dot(w, e) / dot(e, e), 0.0, 1.0); + float segd = dot(p - proj, p - proj); + d = min(d, segd); + + float c0 = step(0.0, p.y - a.y); + float c1 = 1.0 - step(0.0, p.y - b.y); + float c2 = 1.0 - step(0.0, e.x * w.y - e.y * w.x); + float allCond = c0 * c1 * c2; + float noneCond = (1.0 - c0) * (1.0 - c1) * (1.0 - c2); + float flip = mix(1.0, -1.0, step(0.5, allCond + noneCond)); + s *= flip; + return d; +} + +float getSdfParallelogram(in vec2 p, in vec2 v0, in vec2 v1, in vec2 v2, in vec2 v3) { + float s = 1.0; + float d = dot(p - v0, p - v0); + + d = seg(p, v0, v3, s, d); + d = seg(p, v1, v0, s, d); + d = seg(p, v2, v1, s, d); + d = seg(p, v3, v2, s, d); + + return s * sqrt(d); +} + +vec2 normalize(vec2 value, float isPosition) { + return (value * 2.0 - (iResolution.xy * isPosition)) / iResolution.y; +} + +float antialising(float distance) { + return 1. - smoothstep(0., normalize(vec2(2., 2.), 0.).x, distance); +} + +float determineStartVertexFactor(vec2 c, vec2 p) { + // Conditions using step + float condition1 = step(p.x, c.x) * step(c.y, p.y); // c.x < p.x && c.y > p.y + float condition2 = step(c.x, p.x) * step(p.y, c.y); // c.x > p.x && c.y < p.y + + // If neither condition is met, return 1 (else case) + return 1.0 - max(condition1, condition2); +} + +vec2 getRectangleCenter(vec4 rectangle) { + return vec2(rectangle.x + (rectangle.z / 2.), rectangle.y - (rectangle.w / 2.)); +} +float ease(float x) { + return pow(1.0 - x, 3.0); +} + +vec4 saturate(vec4 color, float factor) { + float gray = dot(color, vec4(0.299, 0.587, 0.114, 0.)); // luminance + return mix(vec4(gray), color, factor); +} +const vec4 TRAIL_COLOR = vec4(1.0, 0.725, 0.161, 1.0); +const vec4 TRAIL_COLOR_ACCENT = vec4(1.0, 0., 0., 1.0); +const float DURATION = 0.3; //IN SECONDS + +void mainImage(out vec4 fragColor, in vec2 fragCoord) +{ + #if !defined(WEB) + fragColor = texture(iChannel0, fragCoord.xy / iResolution.xy); + #endif + // Normalization for fragCoord to a space of -1 to 1; + vec2 vu = normalize(fragCoord, 1.); + vec2 offsetFactor = vec2(-.5, 0.5); + + // Normalization for cursor position and size; + // cursor xy has the postion in a space of -1 to 1; + // zw has the width and height + vec4 currentCursor = vec4(normalize(iCurrentCursor.xy, 1.), normalize(iCurrentCursor.zw, 0.)); + vec4 previousCursor = vec4(normalize(iPreviousCursor.xy, 1.), normalize(iPreviousCursor.zw, 0.)); + + vec2 centerCC = getRectangleCenter(currentCursor); + vec2 centerCP = getRectangleCenter(previousCursor); + // When drawing a parellelogram between cursors for the trail i need to determine where to start at the top-left or top-right vertex of the cursor + float vertexFactor = determineStartVertexFactor(currentCursor.xy, previousCursor.xy); + float invertedVertexFactor = 1.0 - vertexFactor; + + // Set every vertex of my parellogram + vec2 v0 = vec2(currentCursor.x + currentCursor.z * vertexFactor, currentCursor.y - currentCursor.w); + vec2 v1 = vec2(currentCursor.x + currentCursor.z * invertedVertexFactor, currentCursor.y); + vec2 v2 = vec2(previousCursor.x + currentCursor.z * invertedVertexFactor, previousCursor.y); + vec2 v3 = vec2(previousCursor.x + currentCursor.z * vertexFactor, previousCursor.y - previousCursor.w); + + float sdfCurrentCursor = getSdfRectangle(vu, currentCursor.xy - (currentCursor.zw * offsetFactor), currentCursor.zw * 0.5); + float sdfTrail = getSdfParallelogram(vu, v0, v1, v2, v3); + + float progress = clamp((iTime - iTimeCursorChange) / DURATION, 0.0, 1.0); + float easedProgress = ease(progress); + // Distance between cursors determine the total length of the parallelogram; + float lineLength = distance(centerCC, centerCP); + + float mod = .007; + //trailblaze + // HACK: Using the saturate function because I currently don't know how to blend colors without losing saturation. + vec4 trail = mix(saturate(TRAIL_COLOR_ACCENT, 1.5), fragColor, 1. - smoothstep(0., sdfTrail + mod, 0.007)); + trail = mix(saturate(TRAIL_COLOR, 1.5), trail, 1. - smoothstep(0., sdfTrail + mod, 0.006)); + trail = mix(trail, saturate(TRAIL_COLOR, 1.5), step(sdfTrail + mod, 0.)); + //cursorblaze + trail = mix(saturate(TRAIL_COLOR_ACCENT, 1.5), trail, 1. - smoothstep(0., sdfCurrentCursor + .002, 0.004)); + trail = mix(saturate(TRAIL_COLOR, 1.5), trail, 1. - smoothstep(0., sdfCurrentCursor + .002, 0.004)); + fragColor = mix(trail, fragColor, 1. - smoothstep(0., sdfCurrentCursor, easedProgress * lineLength)); +} diff --git a/.config/tmux/tmux.conf##template.j2 b/.config/tmux/tmux.conf##template.j2 index 90e02c4..0df44f9 100644 --- a/.config/tmux/tmux.conf##template.j2 +++ b/.config/tmux/tmux.conf##template.j2 @@ -39,6 +39,8 @@ set -g @catppuccin_flavour 'mocha' set -g @catppuccin_status_modules_right "battery application session date_time" set -g @catppuccin_status_left_separator "█" set -g @catppuccin_status_right_separator "█" +set -g @catppuccin_window_text " #(basename #{pane_current_path})" +set -g @catppuccin_window_current_text " #(basename #{pane_current_path})" set -g @plugin 'tmux-plugins/tpm' set -g @plugin 'tmux-plugins/tmux-sensible' @@ -60,6 +62,10 @@ run '/opt/homebrew/opt/tpm/share/tpm/tpm' run '~/.tmux/plugins/tpm/tpm' {% endif %} +set -g status-right-length 100 +set -g status-left-length 100 +set -g status-left "" + # set vi-mode set-window-option -g status-keys vi set-window-option -g mode-keys vi @@ -69,4 +75,3 @@ bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel # Use F12 for pane sync bind-key e set-window-option synchronize-panes\; display-message "synchronize-panes is now #{?pane_synchronized,on,off}" -