repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

initial svn externs and completions for `svn`

2864ecbf0c3861873331da31bb83a8d941d8b2c2

Oliver Jan Krylow <olver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (7)

COMMANDS.md

Modified
1 1 ## Commands to remember
3 +- cbs: copy and paste
3 4 - ouch: compress and decompress archives
4 5 - sd: search and replace
5 6 - fd: find files recursively
30 31 - comrak: render markdown to html
31 32 - hx: terminal code editor
32 33 - xplr: terminal file explorer
34 +- coreutils: rust unix tools
35 +- t-rec: terminal gifs
36 +- podcast: podcast manager
37 +- sic: image manipulation
38 +- vivid: generate LS_COLORS
39 +- chars: unicode character info
40 +- hwatch: watch output of commands over time
41 +- franklin-cli: evolutionary image filter
42 +- uggo: LoL builds

nushell/completions/svn.complete.nu

Added
new file mode 100644
1 +def "complete svn subcommands" [] {
2 + ^svn help
3 + | lines
4 + | skip until { | line | $line | str starts-with "Available subcommands:" }
5 + | skip 1
6 + | each { |line| $line | str trim }
7 + | take until { |line| $line | empty? }
8 + | split column " "
9 + | get column1
12 +def "complete svn add paths" [] {
13 + ^svn status --depth files
14 + | lines
15 + | parse "{mode} {file}"
16 + | str trim
17 + | where mode == ?
18 + | get file
21 +def "complete svn revert paths" [] {
22 + ^svn status --depth files
23 + | lines
24 + | parse "{mode} {file}"
25 + | where mode == M
26 + | str trim
27 + | get file
30 +def "complete svn depth" [] { ['empty', 'files', 'immediates', 'infinity'] }
32 +def "complete svn changelists" [] {
33 + ^svn status --depth files
34 + | lines
35 + | parse "--- Changelist '{changelist}':"
36 + | get --ignore-errors changelist
39 +# Subversion is a tool for version control.
40 +# For additional information, see http://subversion.apache.org/
41 +export extern svn [
42 + subcommand?: string@"complete svn subcommands" # for help on a specific subcommand.
43 + --version # to see the program version and RA modules
44 + --quiet # to see just the version number
45 + --verbose # to see dependency versions as well
48 +# help (?, h): Describe the usage of this program or its subcommands.
49 +# usage: help [SUBCOMMAND...]
50 +export extern "svn help" [
51 + subcommand?: string@"complete svn subcommands" # for help on a specific subcommand.
52 + --verbose(-v) # also show experimental subcommands and options
55 +# FIXME: https://github.com/nushell/nushell/issues/5012
56 +# rest parameters do not play well with completions yet
57 +# the `paths` parameter should be `...paths`
59 +# Put new files and directories under version control.
60 +export extern "svn add" [
61 + paths: path@"complete svn add paths" # unversioned PATHs for addition
62 + --targets: path # pass contents of file ARG as additional args
63 + --non-recursive(-N) # obsolete; same as --depth=empty
64 + --depth: string@"complete svn depth" # limit operation by depth ARG ('empty', 'files', 'immediates', or 'infinity')
65 + --quiet(-q) # print nothing, or only summary information
66 + --force # ignore already versioned paths
67 + --no-ignore # disregard default and svn:ignore and svn:global-ignores property ignores
68 + --auto-props # enable automatic properties
69 + --no-auto-props # disable automatic properties
70 + --parents # add intermediate parents
73 +export extern "svn revert" [
74 + paths: path@"complete svn revert paths"
75 + --targets: path # pass contents of file as additional args
76 + --recursive(-R) # descend recursively, same as --depth=infinity
77 + --depth: string@"complete svn depth" # limit operation by depth ARG ('empty', 'files', 'immediates', or 'infinity')
78 + --quiet(-q) # print nothing, or only summary information
79 + --changelist: string@"complete svn changelists" # operate only on members of changelist ARG
80 + --remove-added # reverting an added item will remove it from disk

nushell/config.nu

Modified
7 7 use todo.nu *
8 8 use git.nu *
10 +# CUSTOM COMPLETIONS
11 +use svn.complete.nu *
10 13 # for more information on themes see
11 14 # https://github.com/nushell/nushell/blob/main/docs/How_To_Coloring_and_Theming.md
12 15 let default_theme = {
268 -# CUSTOM COMPLETIONS
270 -module svn {
271 - def "complete svn subcommands" [] {
272 - ^svn help
273 - | lines
274 - | skip until { | line | $line | str starts-with "Available subcommands:" }
275 - | skip 1
276 - | each { |line| $line | str trim }
277 - | take until { |line| $line | empty? }
278 - | split column " "
279 - | get column1
280 - }
282 - def "complete svn add paths" [] {
283 - ^svn status --depth files
284 - | lines
285 - | parse "{mode} {file}"
286 - | str trim
287 - | where mode == ?
288 - | get file
289 - }
291 - def "complete svn revert paths" [] {
292 - ^svn status --depth files
293 - | lines
294 - | parse "{mode} {file}"
295 - | where mode == M
296 - | str trim
297 - | get file
298 - }
300 - def "complete svn depth" [] { ['empty', 'files', 'immediates', 'infinity'] }
302 - def "complete svn changelists" [] {
303 - ^svn status --depth files
304 - | lines
305 - | parse "--- Changelist '{changelist}':"
306 - | get --ignore-errors changelist
307 - }
309 - # Subversion is a tool for version control.
310 - # For additional information, see http://subversion.apache.org/
311 - export extern svn [
312 - subcommand?: string@"complete svn subcommands" # for help on a specific subcommand.
313 - --version # to see the program version and RA modules
314 - --quiet # to see just the version number
315 - --verbose # to see dependency versions as well
316 - ]
318 - # help (?, h): Describe the usage of this program or its subcommands.
319 - # usage: help [SUBCOMMAND...]
320 - export extern "svn help" [
321 - subcommand?: string@"complete svn subcommands" # for help on a specific subcommand.
322 - --verbose(-v) # also show experimental subcommands and options
323 - ]
325 - # FIXME: https://github.com/nushell/nushell/issues/5012
326 - # rest parameters do not play well with completions yet
327 - # the `paths` parameter should be `...paths`
329 - # Put new files and directories under version control.
330 - export extern "svn add" [
331 - paths: path@"complete svn add paths" # unversioned PATHs for addition
332 - --targets: path # pass contents of file ARG as additional args
333 - --non-recursive(-N) # obsolete; same as --depth=empty
334 - --depth: string@"complete svn depth" # limit operation by depth ARG ('empty', 'files', 'immediates', or 'infinity')
335 - --quiet(-q) # print nothing, or only summary information
336 - --force # ignore already versioned paths
337 - --no-ignore # disregard default and svn:ignore and svn:global-ignores property ignores
338 - --auto-props # enable automatic properties
339 - --no-auto-props # disable automatic properties
340 - --parents # add intermediate parents
341 - ]
343 - export extern "svn revert" [
344 - paths: path@"complete svn revert paths"
345 - --targets: path # pass contents of file as additional args
346 - --recursive(-R) # descend recursively, same as --depth=infinity
347 - --depth: string@"complete svn depth" # limit operation by depth ARG ('empty', 'files', 'immediates', or 'infinity')
348 - --quiet(-q) # print nothing, or only summary information
349 - --changelist: string@"complete svn changelists" # operate only on members of changelist ARG
350 - --remove-added # reverting an added item will remove it from disk
351 - ]
354 -use svn *

nushell/modules/environment.nu

Modified
1 -# To add entries to PATH (on Windows you might use Path), you can use the following pattern:
2 -# export env PATH { ($env.PATH | prepend '/some/path') }
1 +export env GO111MODULE { "on" }
2 +export env GOPATH { ($nu.home-path | path join '.go') }
4 +export env PATH {
5 + ( $env.PATH |
6 + prepend ($env.GOPATH | path join 'bin')
7 + )
8 + }
3 9 #TODO CARGO_HOME
5 11 # GLOBAL VARIABLES

nushell/modules/svn.nu

Added
new file mode 100644
1 +def get-item-status-count [
2 + svn_status: table # svn status table from xml
3 + item_status_filter: string # the path item status to count
4 +] {
5 + let target_status_count = ( $svn_status | get status.children.target.children.entry.children.wc-status.attributes | compact | flatten | flatten | where item == $item_status_filter | length )
6 + # there will always be a "target" node, but "changelist" is optional
7 + let changelist_status_count = ( $svn_status | get --ignore-errors status.children.changelist.children.entry.children.wc-status.attributes | compact | flatten | flatten | where item == $item_status_filter | length )
8 + $target_status_count + $changelist_status_count
9 +}
11 +# Aggregates the output of `svn status` and `svn info` into a table.
12 +# This command operates in the current directory.
13 +# Analog to gstat for svn.
14 +export def-env svnstat [
15 + ...path: string # optional paths to get svn status from. If empty, the current directory is assumed.
16 +] {
17 + # the svn info and status commands can handle multiple input paths.
18 + # TODO empty values, when not in svn directory
19 + let svn_status = (^svn status --xml $path | from xml)
20 + let svn_info = (^svn info --xml $path | from xml)
21 + {
22 + "path": ( $svn_info | get info.children.entry.attributes.path | path expand )
23 + "working_copy_root_path": ( $svn_info | get info.children.entry.children.wc-info.children.wcroot-abspath.children | flatten | flatten | flatten | compact )
24 + "url": ( $svn_info | get info.children.entry.children.url.children | flatten | flatten | compact )
25 + "relative_url": ( $svn_info | get info.children.entry.children.relative-url.children | flatten | flatten | compact )
26 + "repository_root": ( $svn_info | get info.children.entry.children.repository.children.root.children | flatten | flatten | flatten | compact )
27 + "repository_uuid": ( $svn_info | get info.children.entry.children.repository.children.uuid.children | flatten | flatten | flatten | compact )
28 + "revision": ( $svn_info | get info.children.entry.attributes.revision )
29 + "node_kind": ( $svn_info | get info.children.entry.attributes.kind )
30 + "schedule": ( $svn_info | get info.children.entry.children.wc-info.children.schedule.children | flatten | flatten | flatten | compact )
31 + "last_changed_author": ( $svn_info | get info.children.entry.children.commit.children.author.children | flatten | flatten | flatten | compact )
32 + "last_changed_rev": ( $svn_info | get info.children.entry.children.commit.attributes.revision | flatten | compact )
33 + "last_changed_date": ( $svn_info | get info.children.entry.children.commit.children.date.children | flatten | flatten | flatten | compact| into datetime )
34 + "added": ( get-item-status-count $svn_status "added" )
35 + "conflicted": "TODO"
36 + "deleted": ( get-item-status-count $svn_status "deleted" )
37 + "ignored": ( get-item-status-count $svn_status "ignored" )
38 + "modified": ( get-item-status-count $svn_status "modified" )
39 + "replaced": "TODO"
40 + "unversioned_external": "TODO"
41 + "unversioned": ( get-item-status-count $svn_status "unversioned" )
42 + "missing": ( get-item-status-count $svn_status "missing" )
43 + "obstructed": "TODO"
44 + "tree_conflicts": ( $svn_status | get --ignore-errors status.children.target.children.entry.children.wc-status.attributes.tree-conflicted | flatten | flatten | compact | length)
45 + "changelists": ( $svn_status | get --ignore-errors status.children.changelist | compact | flatten | get name )
46 + }

nushell/modules/table.nu

Modified
2 2 # Check whether table in pipeline has a column with given name
3 3 export def "has-column?" [
4 4 name: string # Name of the column to check for
6 - pivot | any? Column0 == $name
6 + transpose | any? Column0 == $name
9 9 # Flattens a table into a string separated by a single space character.

nushell/modules/todo.nu

Modified
4 4 # Render my To-Do file in the terminal
5 5 export def todo [] { mdcat ($env.DOTFILES | path join "TODO.md") }
6 6 # Open my To-Do file for editing
7 7 export def "todo edit" [] { hx ($env.DOTFILES | path join "TODO.md")}
8 8 # Open a list of commands, that I would like to remember to use
9 9 export def "todo commands" [] { mdcat ($env.DOTFILES | path join "COMMANDS.md") }
10 +# Open the list of commands to remember for editing.
11 +export def "todo commands edit" [] { hx ($env.DOTFILES | path join "COMMANDS.md") }