66 lines
1.6 KiB
Plaintext
66 lines
1.6 KiB
Plaintext
= kakutils-rs
|
|
|
|
Sort by regular expression or lexicographically, find uniqes, shuffle, or evaluate rust selections without spawning a new command for each.
|
|
|
|
[![asciicast](https://asciinema.org/a/dIQh9NtLRkzVEENxmij5qBaai.svg)](https://asciinema.org/a/dIQh9NtLRkzVEENxmij5qBaai)
|
|
|
|
== Example
|
|
|
|
. Imagine you want to sort these stages
|
|
+
|
|
[source,groovy]
|
|
----
|
|
stage("Build") { # Step 1
|
|
8+3
|
|
}
|
|
|
|
stage("Compile") { # Step 5
|
|
math::log2(8)
|
|
}
|
|
|
|
stage("Assemble") { # Step 10
|
|
2^9+math::log2(10)
|
|
}
|
|
|
|
stage("Make") { # Step 100
|
|
not_a_formula
|
|
}
|
|
----
|
|
|
|
. Select the stage and stage body with: `%sstage<ret>MLM`
|
|
. Sort the selection by step number with: `:utils sort #\d+<ret>` (sort on whole capture) or `:utils sort "'.+?#(\d).+?'"` (sort on first capture group, which contains only the digits)
|
|
. Note if you just run `:utils sort<ret>`
|
|
|
|
== Configuration
|
|
|
|
[source,sh,title='sh']
|
|
----
|
|
cargo install --git https://github.com/austenadler/kakutils-rs
|
|
----
|
|
|
|
[source,title='kakrc']
|
|
----
|
|
define-command utils -params .. %{
|
|
eval -save-regs '"' %{
|
|
eval %sh{
|
|
# use kak_command_fifo kak_response_fifo;
|
|
kakutils-rs "$@"
|
|
}
|
|
}
|
|
}
|
|
----
|
|
|
|
== Usage
|
|
|
|
* Make multiple selections
|
|
* Run `utils sort` to sort the selections lexicographically
|
|
* Run `utils sort REGEX` to sort by regex match
|
|
** If the regex does not contain a capture group
|
|
** If the regex contains at least one capture group
|
|
|
|
== TODO
|
|
|
|
* I don't know what will happen with multiline strings and regex
|
|
* Figure out how to change the `no_skip_whitespace` option name in the source
|
|
* Get sort by selections working
|