define-command \ -docstring %{ Replace the selections with the date, with the args passed as a string to date -d. } \ insert-date -params 0.. %{ evaluate-commands -draft -save-regs '|"' %{ set-register | "date -d '%arg{@}' '+%%Y-%%m-%%d' | tr -d '\n'" echo -debug "Inserting date: %reg{pipe}" # we delete the trailing newline execute-keys '|' } } alias global date insert-date define-command -params 2 \ -docstring %{ Swap all occurrence of the first parameter with the second in selection. } \ swap %{ evaluate-commands -save-regs | %{ set-register | %exp{ sed "s/%arg{1}/𝅙/; \ s/%arg{2}/%arg{1}/; s/𝅙/%arg{2}/" } execute-keys '|' } } define-command -params 2 \ -docstring %{ Swap all occurence of param A with param B in selections. } \ swap-buffer %{ evaluate-commands -save-regs "ab" -draft %{ set-register a %arg{1} set-register b %arg{2} execute-keys "s\Qa\E|\Qb\E" swap "%arg{1}" "%arg{2}" } } define-command regswap -params 2 %{ evaluate-commands -draft -save-regs "abcd" %{ set-register a %arg{1} set-register b %arg{2} execute-keys -draft '"xZZs\Qa\E"cZzs\Qb\E"dZ"cz"bR"dz"aRz' } } define-command -docstring %{ pastes []: paste the selection(s) to pastes.sh. Separate selections are appended into one. Resulting URL is printed to *debug* and copied to clipboard. Arguments: name optional filename for the paste } -params 0..1 pastes %{ evaluate-commands -draft -save-regs '"ab|' %{ set-register b %val{bufname} execute-keys '"ay' edit -scratch set-register | "ssh pastes.sh %arg{1} 2>/dev/null" execute-keys '"a%|%s\rd%_"ay' set-register | "wl-copy -n" execute-keys '' echo -debug %reg{a} hook -once global WinDisplay %exp{\Q%reg{b}\E} %{ info -title 'pastes.sh' "%reg{a}" } delete-buffer } }