Skip to content

Commit

Permalink
Port before_v0.60/cool_oneliners folder (#831)
Browse files Browse the repository at this point in the history
This PR is part of porting all old scripts #221 and ports
`cool_oneliners` folder

## Summary

### dict.nu
This script has already been ported to `sourced/cool_oneliners/dict.nu`
in
28c7e09

```yaml
from: before_v0.60/cool_oneliners/dict.nu
to: sourced/cool-oneliners/dict.nu
functions:
  dict: sourced/cool-oneliners/dict.nu:2:dict
```

### file_cat.nu
has already been ported to `sourced/cool_oneliners/file_cat.nu` in
c47ccd4
```yaml
  from: before_v0.60/cool_oneliners/file_cat.nu
  to: sourced/cool-oneliners/file_cat.nu
```

### filesize.nu

```yaml
from: before_v0.60/cool_oneliners/filesize.nu
to: sourced/cool-oneliners/filesize.nu
```

### js_map_to_markdown.nu
```yaml
from: before_v0.60/cool_oneliners/js_map_to_markdown.nu
to:  sourced/cool-oneliners/js_map_to_markdown.nu
```
I created `sourced/cool-oneliners/assets/js_map.json` with the data for
this script as it was before

### cdpath-implementation.nu
```yaml
from: before_v0.60/cool_oneliners/cdpath-implementation.nu
to: sourced/cool-oneliners/cdpath-implementation.nu
functions:
  c: sourced/cool-oneliners/cdpath-implementation.nu:18:c
```

### parse_aws_s3_ls.nu
I don't have aws so I just ported the syntax
```yaml
from: before_v0.60/cool_oneliners/parse_aws_s3_ls.nu
to:  null
```
Edit: I considered not porting this script yet because I can't test it
for now

### npm_update_versions.nu
```yaml
from: before_v0.60/cool_oneliners/npm_update_versions.nu
to: sourced/cool-oneliners/npm_update_versions.nu
```

### xml_search_schema.nu
```yaml
from: before_v0.60/cool_oneliners/xml_search_schema.nu
to: sourced/cool-oneliners/xml_search_schema.nu
```
  • Loading branch information
39555 committed May 13, 2024
1 parent f1b0432 commit b40ead9
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 66 deletions.
19 changes: 0 additions & 19 deletions before_v0.60/cool_oneliners/README.md

This file was deleted.

23 changes: 0 additions & 23 deletions before_v0.60/cool_oneliners/cdpath-implementation.nu

This file was deleted.

14 changes: 0 additions & 14 deletions before_v0.60/cool_oneliners/dict.nu

This file was deleted.

3 changes: 0 additions & 3 deletions before_v0.60/cool_oneliners/file_cat.nu

This file was deleted.

2 changes: 0 additions & 2 deletions before_v0.60/cool_oneliners/filesize.nu

This file was deleted.

2 changes: 0 additions & 2 deletions before_v0.60/cool_oneliners/js_map_to_markdown.nu

This file was deleted.

2 changes: 0 additions & 2 deletions before_v0.60/cool_oneliners/npm_update_versions.nu

This file was deleted.

6 changes: 6 additions & 0 deletions sourced/cool-oneliners/assets/js_map.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
["cero", "zero"],
["uno", "one"],
["dos", "two"],
["tres", "three"]
]
48 changes: 48 additions & 0 deletions sourced/cool-oneliners/cdpath-implementation.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/nu

# I actually use it as a part of my startup, so I am not really sure how to pack it, yet I wouldd like to contribute
#-------------------------------------------------------------------------------------------------------------------------------
#
# How to use?
#-------------------------------------------------
#1) Add desired paths to the cdpath variable
#2) Use in your shell: $c [directory]
#2.5) You *have to* use an argument. If you wish to simply $cd, use $cd command.
#3) If the path exists, you will cd into the first match found (the command is iterating over the list in the correct order,
# i.e. first element is being iterated overin the first place)
#3.5) But if path does not exist, you will receive a proper echo.
#-----------------------------------------------------------------------------------------------------------------------------------
#
#Written by skelly37
#------------------------

# startup = [
# "let cdpath = [. /place/your ~/cdpath/here ]",
# "def c [dir] { let wd = (pwd); for element in $cdpath {if (pwd) == $wd {cd $element; for directory in (ls -a | select name type | each { if $it.type == Dir {echo $it.name} {} } ) {if $dir == $directory {cd $dir} {}}; if (pwd) == $element {cd $wd} {}} {}}; if (pwd) == $wd {cd $wd; echo \"No such path!\"} {}}",
# ]
#

export def --env c [dir] {
let CD_PATH = [. ($env.NU_PLUGIN_DIRS | get 0) $nu.default-config-dir ]
let wd = (pwd);
for element in $CD_PATH {
let element = ($element | path expand)
if (pwd) == $wd {
cd $element;
for directory in (ls -a | where type == dir | get name) {
if $dir == $directory {
cd $dir
break
}
};
if (pwd) == $element {
cd $wd
}
}
};
if (pwd) == $wd {
cd $wd
print "No such path!"
}
}

2 changes: 2 additions & 0 deletions sourced/cool-oneliners/filesize.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## show directory sizes in current directory starting from the largest
ls -d|where type == dir|sort-by size|reverse|format filesize GB size
2 changes: 2 additions & 0 deletions sourced/cool-oneliners/js_map_to_markdown.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ingest JavaScript Map JSON into nu then to markdown
open assets/js_map.json | each { echo [[Español English]; [ $in.0 $in.1]] } | flatten | to md
2 changes: 2 additions & 0 deletions sourced/cool-oneliners/npm_update_versions.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Increment the minor version for any package.json in the current directory with `nu_plugin_inc` (eigenrick — 08/16/2020)
ls -f */package.json | each {|it| open $it.name | inc version --minor | to json --indent 2 | save --raw --force $it.name }
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# To get that file, first download the following zip:
# https://www.ecma-international.org/wp-content/uploads/ECMA-376-Fifth-Edition-Part-1-Fundamentals-And-Markup-Language-Reference.zip
# Then, unzip the contents of OfficeOpenXML-XMLSchema-Strict.zip.
open wml.xsd | from xml | get schema.children.simpleType | flatten | where name =~ 'BrType' | get children.restriction.children.enumeration.attributes
open wml.xsd | from xml | get content | where tag == simpleType | flatten | where name =~ BrType | get content.content.0.attributes

0 comments on commit b40ead9

Please sign in to comment.