urxvt-selection-autotransform(1)

πŸ“¦ version 9.31, in opensuse-leap 16.0

πŸ’… urxvt-selection-autotransform(1) β€” the RXVT-UNICODE glow-up πŸ¦‹

okay bestie, so this is one of those urxvt helper pages and honestly? it's a little cutie. it's part of the RXVT-UNICODE family, and it's here to make your selections do tricks ✨


πŸŽ€ NAME πŸŽ€

selection-autotransform β€” it automatically transforms the text you select, no cap πŸ’«


🌸 DESCRIPTION 🌸

So here's the vibe: this selection lets you do automatic transforms on a selection every single time a selection is made. Like, the moment you highlight something, it gets rewrote. main character behaviour honestly πŸ‘‘

The way it works is you specify perl snippets (and lowkey the most useful one is a single s/// operator, periodt) that modify $_, and you give them to urxvt as resources:

URxvt.selection-autotransform.0: transform
URxvt.selection-autotransform.1: transform
...

Yup, that's it β€” numbered resources, .0, .1, and so on forever if you want 🌈


🧚 example time, bestie 🧚

Say you've got selections of the form filename:number β€” you know, the classic thing that shows up in compiler messages all the time 😭 well, this lil number right here will transform them into vi +$filename $word:

URxvt.selection-autotransform.0: s/^([^:[:space:]]+):(\\d+):?$/vi +$2 \\Q$1\\E\\x0d/

And this next example matches the same,but replaces it with vi-commands you can paste directly into your (vi :) editor β€” yes, that's the whole point, chef's kiss 🀌:

URxvt.selection-autotransform.0: s/^([^:[:space:]]+(\\d+):?$/:e \\Q$1\\E\\x0d:$2\\x0d/

Of course, this can be modified to suit your needs and your editor :) β€” go off, customize it, make it yours πŸ’–


πŸ¦‹ levelling up to perl error messages πŸ¦‹

To expand the example above to typical perl error messages (the "XXX at FILENAME line YYY." kind, you've definitely seen them and you've definitely cried a little πŸ™ˆ), you need a slightly more elaborate solution:

URxvt.selection.pattern-0: ( at .*? line \\d+[,.])
URxvt.selection-autotransform.0: s/^ at (.*?) line (\\d+)[,.]$/:e \\Q$1\\E\\x0d:$2\\x0d/

Let me break it down because it's giving two-step slay πŸ”₯:

  • The first line tells the selection code to treat the unchanging part of every error message as a selection pattern πŸ‘€
  • The second line transforms that message into vi commands to load the file 🎯
fr fr, that's the whole trick. pattern first, transform second, and your compiler errors become clickable-ish little portals into your editor. iconic.

🫢 and that's the page! cute lil sign-off for you: this was version 9.31, dated 2023-12-02, and it's the urxvt-selection-autotransform(1) page from the RXVT-UNICODE crew. go transform some selections bestie, you've got this β­πŸ’œ

πŸ“¦ where this page comes from