๐Ÿ”’ Backup for my config files
dotfiles
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

add cursor_tail shader

kacaii 54f100d1 cc274d27

+246 -8
+4 -1
.config/ghostty/config
··· 1 1 theme = catppuccin-mocha.conf 2 2 font-family = "Maple Mono NF" 3 3 font-size = 10 4 + font-thicken = true 4 5 background-opacity = 0.9 5 6 background-blur = true 6 7 ··· 11 12 12 13 shell-integration-features = no-cursor 13 14 cursor-style = block 15 + cursor-style-blink = false 14 16 mouse-hide-while-typing = true 15 - gtk-single-instance = true 16 17 quick-terminal-position = bottom 17 18 quick-terminal-size = 25% 19 + 20 + custom-shader = shaders/cursor_tail.glsl 18 21 19 22 # ๓ฐŒŒ Keybinds 20 23
+234
.config/ghostty/shaders/cursor_tail.glsl
··· 1 + // -- CONFIGURATION -- 2 + vec4 TRAIL_COLOR = iCurrentCursorColor; // can change to eg: vec4(0.2, 0.6, 1.0, 0.5); 3 + const float DURATION = 0.09; // in seconds 4 + const float MAX_TRAIL_LENGTH = 0.2; 5 + const float THRESHOLD_MIN_DISTANCE = 1.5; // min distance to show trail (units of cursor width) 6 + const float BLUR = 1.0; // blur size in pixels (for antialiasing) 7 + 8 + // --- CONSTANTS for easing functions --- 9 + const float PI = 3.14159265359; 10 + const float C1_BACK = 1.70158; 11 + const float C2_BACK = C1_BACK * 1.525; 12 + const float C3_BACK = C1_BACK + 1.0; 13 + const float C4_ELASTIC = (2.0 * PI) / 3.0; 14 + const float C5_ELASTIC = (2.0 * PI) / 4.5; 15 + const float SPRING_STIFFNESS = 9.0; 16 + const float SPRING_DAMPING = 0.9; 17 + 18 + // --- EASING FUNCTIONS --- 19 + 20 + // // Linear 21 + // float ease(float x) { 22 + // return x; 23 + // } 24 + 25 + // // EaseOutQuad 26 + // float ease(float x) { 27 + // return 1.0 - (1.0 - x) * (1.0 - x); 28 + // } 29 + 30 + // // EaseOutCubic 31 + // float ease(float x) { 32 + // return 1.0 - pow(1.0 - x, 3.0); 33 + // } 34 + 35 + 36 + // // EaseOutQuart 37 + // float ease(float x) { 38 + // return 1.0 - pow(1.0 - x, 4.0); 39 + // } 40 + 41 + // // EaseOutQuint 42 + // float ease(float x) { 43 + // return 1.0 - pow(1.0 - x, 5.0); 44 + // } 45 + 46 + // // EaseOutSine 47 + // float ease(float x) { 48 + // return sin((x * PI) / 2.0); 49 + // } 50 + 51 + // // EaseOutExpo 52 + // float ease(float x) { 53 + // return x == 1.0 ? 1.0 : 1.0 - pow(2.0, -10.0 * x); 54 + // } 55 + 56 + // EaseOutCirc 57 + float ease(float x) { 58 + return sqrt(1.0 - pow(x - 1.0, 2.0)); 59 + } 60 + 61 + // // EaseOutBack 62 + // float ease(float x) { 63 + // return 1.0 + C3_BACK * pow(x - 1.0, 3.0) + C1_BACK * pow(x - 1.0, 2.0); 64 + // } 65 + 66 + // // EaseOutElastic 67 + // float ease(float x) { 68 + // return x == 0.0 ? 0.0 69 + // : x == 1.0 ? 1.0 70 + // : pow(2.0, -10.0 * x) * sin((x * 10.0 - 0.75) * C4_ELASTIC) + 1.0; 71 + // } 72 + 73 + // Parametric Spring 74 + // float ease(float x) { 75 + // x = clamp(x, 0.0, 1.0); 76 + // float decay = exp(-SPRING_DAMPING * SPRING_STIFFNESS * x); 77 + // float freq = sqrt(SPRING_STIFFNESS * (1.0 - SPRING_DAMPING * SPRING_DAMPING)); 78 + // float osc = cos(freq * 6.283185 * x) + (SPRING_DAMPING * sqrt(SPRING_STIFFNESS) / freq) * sin(freq * 6.283185 * x); 79 + // return 1.0 - decay * osc; 80 + // } 81 + 82 + float getSdfRectangle(in vec2 p, in vec2 xy, in vec2 b) 83 + { 84 + vec2 d = abs(p - xy) - b; 85 + return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0); 86 + } 87 + 88 + // Based on Inigo Quilez's 2D distance functions article: https://iquilezles.org/articles/distfunctions2d/ 89 + // Potencially optimized by eliminating conditionals and loops to enhance performance and reduce branching 90 + 91 + float seg(in vec2 p, in vec2 a, in vec2 b, inout float s, float d) { 92 + vec2 e = b - a; 93 + vec2 w = p - a; 94 + vec2 proj = a + e * clamp(dot(w, e) / dot(e, e), 0.0, 1.0); 95 + float segd = dot(p - proj, p - proj); 96 + d = min(d, segd); 97 + 98 + float c0 = step(0.0, p.y - a.y); 99 + float c1 = 1.0 - step(0.0, p.y - b.y); 100 + float c2 = 1.0 - step(0.0, e.x * w.y - e.y * w.x); 101 + float allCond = c0 * c1 * c2; 102 + float noneCond = (1.0 - c0) * (1.0 - c1) * (1.0 - c2); 103 + float flip = mix(1.0, -1.0, step(0.5, allCond + noneCond)); 104 + s *= flip; 105 + return d; 106 + } 107 + 108 + float getSdfParallelogram(in vec2 p, in vec2 v0, in vec2 v1, in vec2 v2, in vec2 v3) { 109 + float s = 1.0; 110 + float d = dot(p - v0, p - v0); 111 + 112 + d = seg(p, v0, v3, s, d); 113 + d = seg(p, v1, v0, s, d); 114 + d = seg(p, v2, v1, s, d); 115 + d = seg(p, v3, v2, s, d); 116 + 117 + return s * sqrt(d); 118 + } 119 + 120 + vec2 normalize(vec2 value, float isPosition) { 121 + return (value * 2.0 - (iResolution.xy * isPosition)) / iResolution.y; 122 + } 123 + 124 + float antialising(float distance) { 125 + return 1. - smoothstep(0., normalize(vec2(BLUR, BLUR), 0.).x, distance); 126 + } 127 + 128 + float determineIfTopRightIsLeading(vec2 a, vec2 b) { 129 + float condition1 = step(b.x, a.x) * step(a.y, b.y); // a.x < b.x && a.y > b.y 130 + float condition2 = step(a.x, b.x) * step(b.y, a.y); // a.x > b.x && a.y < b.y 131 + 132 + // if neither condition is met, return 1 (else case) 133 + return 1.0 - max(condition1, condition2); 134 + } 135 + 136 + vec2 getRectangleCenter(vec4 rectangle) { 137 + return vec2(rectangle.x + (rectangle.z / 2.), rectangle.y - (rectangle.w / 2.)); 138 + } 139 + 140 + 141 + void mainImage(out vec4 fragColor, in vec2 fragCoord){ 142 + #if !defined(WEB) 143 + fragColor = texture(iChannel0, fragCoord.xy / iResolution.xy); 144 + #endif 145 + 146 + // normalization & setup(-1, 1 coords) 147 + vec2 vu = normalize(fragCoord, 1.); 148 + vec2 offsetFactor = vec2(-.5, 0.5); 149 + 150 + vec4 currentCursor = vec4(normalize(iCurrentCursor.xy, 1.), normalize(iCurrentCursor.zw, 0.)); 151 + vec4 previousCursor = vec4(normalize(iPreviousCursor.xy, 1.), normalize(iPreviousCursor.zw, 0.)); 152 + 153 + vec2 centerCC = currentCursor.xy - (currentCursor.zw * offsetFactor); 154 + vec2 centerCP = previousCursor.xy - (previousCursor.zw * offsetFactor); 155 + 156 + vec2 delta = centerCP - centerCC; 157 + float lineLength = length(delta); 158 + 159 + float sdfCurrentCursor = getSdfRectangle(vu, centerCC, currentCursor.zw * 0.5); 160 + 161 + vec4 newColor = vec4(fragColor); 162 + 163 + float minDist = currentCursor.w * THRESHOLD_MIN_DISTANCE; 164 + float progress = clamp((iTime - iTimeCursorChange) / DURATION, 0.0, 1.0); 165 + if (lineLength > minDist) { 166 + // ANIMATION logic 167 + 168 + float head_eased = 0.0; 169 + float tail_eased = 0.0; 170 + 171 + float tail_delay_factor = MAX_TRAIL_LENGTH / lineLength; 172 + 173 + float isLongMove = step(MAX_TRAIL_LENGTH, lineLength); 174 + 175 + float head_eased_short = ease(progress); 176 + float tail_eased_short = ease(smoothstep(tail_delay_factor, 1.0, progress)); 177 + float head_eased_long = 1.0; 178 + float tail_eased_long = ease(progress); 179 + 180 + head_eased = mix(head_eased_long, head_eased_short, isLongMove); 181 + tail_eased = mix(tail_eased_long, tail_eased_short, isLongMove); 182 + 183 + // detect straight moves 184 + vec2 delta_abs = abs(centerCC - centerCP); 185 + float threshold = 0.001; 186 + float isHorizontal = step(delta_abs.y, threshold); 187 + float isVertical = step(delta_abs.x, threshold); 188 + float isStraightMove = max(isHorizontal, isVertical); 189 + 190 + // -- Making the parallelogram sdf (diagonal move) -- 191 + 192 + // animate the TOP-LEFT corners 193 + vec2 head_pos_tl = mix(previousCursor.xy, currentCursor.xy, head_eased); 194 + vec2 tail_pos_tl = mix(previousCursor.xy, currentCursor.xy, tail_eased); 195 + 196 + float isTopRightLeading = determineIfTopRightIsLeading(currentCursor.xy, previousCursor.xy); 197 + float isBottomLeftLeading = 1.0 - isTopRightLeading; 198 + 199 + // v0, v1 : "front" of the trail (head) 200 + vec2 v0 = vec2(head_pos_tl.x + currentCursor.z * isTopRightLeading, head_pos_tl.y - currentCursor.w); 201 + vec2 v1 = vec2(head_pos_tl.x + currentCursor.z * isBottomLeftLeading, head_pos_tl.y); 202 + 203 + // v2, v3: "back" of the trail (tail) 204 + vec2 v2 = vec2(tail_pos_tl.x + currentCursor.z * isBottomLeftLeading, tail_pos_tl.y); 205 + vec2 v3 = vec2(tail_pos_tl.x + currentCursor.z * isTopRightLeading, tail_pos_tl.y - previousCursor.w); 206 + 207 + float sdfTrail_diag = getSdfParallelogram(vu, v0, v1, v2, v3); 208 + 209 + // -- Making the rectangle sdf (straight move) -- 210 + 211 + vec2 head_center = mix(centerCP, centerCC, head_eased); 212 + vec2 tail_center = mix(centerCP, centerCC, tail_eased); 213 + 214 + vec2 min_center = min(head_center, tail_center); 215 + vec2 max_center = max(head_center, tail_center); 216 + 217 + vec2 box_size = (max_center - min_center) + currentCursor.zw; 218 + vec2 box_center = (min_center + max_center) * 0.5; 219 + 220 + float sdfTrail_rect = getSdfRectangle(vu, box_center, box_size * 0.5); 221 + 222 + // -- FINAL SELECTING AND DRAWING -- 223 + float sdfTrail = mix(sdfTrail_diag, sdfTrail_rect, isStraightMove); 224 + 225 + vec4 trail = TRAIL_COLOR; 226 + float trailAlpha = antialising(sdfTrail); 227 + newColor = mix(newColor, trail, trailAlpha); 228 + 229 + // punch hole 230 + newColor = mix(newColor, fragColor, step(sdfCurrentCursor, 0.)); 231 + } 232 + 233 + fragColor = newColor; 234 + }
+7 -7
.config/ghostty/themes/catppuccin-mocha.conf
··· 14 14 palette = 13=#f5c2e7 15 15 palette = 14=#94e2d5 16 16 palette = 15=#bac2de 17 - background = 1e1e2e 18 - foreground = cdd6f4 19 - cursor-color = f5e0dc 20 - cursor-text = 11111b 21 - selection-background = 353749 22 - selection-foreground = cdd6f4 23 - split-divider-color = 313244 17 + background = #1e1e2e 18 + foreground = #cdd6f4 19 + cursor-color = #f5e0dc 20 + cursor-text = #11111b 21 + selection-background = #353749 22 + selection-foreground = #cdd6f4 23 + split-divider-color = #313244
+1
.config/nvim/lua/plugins/colorscheme.lua
··· 90 90 CursorLine = { bg = custom_bg }, 91 91 Label = { fg = colors.blue }, 92 92 LineNr = { fg = colors.overlay1 }, 93 + Visual = { bg = "#353749" }, 93 94 94 95 LspReferenceWrite = { bg = colors.none, bold = true }, 95 96 LspReferenceRead = { bg = colors.none, bold = true },