mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 06:37:46 +00:00
updated with categories
This commit is contained in:
parent
386d308f8a
commit
0d9a163e02
30 changed files with 81 additions and 17 deletions
0
256-color.sh → coloring/256-color.sh
Executable file → Normal file
0
256-color.sh → coloring/256-color.sh
Executable file → Normal file
5
coloring/README.md
Normal file
5
coloring/README.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# Coloring Scripts
|
||||||
|
|
||||||
|
### Definition
|
||||||
|
|
||||||
|
These scripts are used to demonstrate the `ansi` command using `ansi` coloring. This is mainly a demo area where we have taken typical `bash` scripts and ported them to nushell scripts. It would be nice if all scripts here showed the "other" version of script and the ported nushell version. We can show "other" flavors of scripts by including them as comments in the nushell scripts or by naming the nushell script and the other script the same basename.
|
0
color_and_formatting.sh → coloring/color_and_formatting.sh
Executable file → Normal file
0
color_and_formatting.sh → coloring/color_and_formatting.sh
Executable file → Normal file
0
table.sh → coloring/table.sh
Executable file → Normal file
0
table.sh → coloring/table.sh
Executable file → Normal file
5
nu_101/README.md
Normal file
5
nu_101/README.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# Nu_101 Scripts
|
||||||
|
|
||||||
|
### Definition
|
||||||
|
|
||||||
|
These scripts should be used to demonstrate to the beginner how nushell scripting works. Perhaps how it's different from Windows `batch` files and `bash` shell scripts. Also, to show off how nushell pipes commands in and out of one another.
|
5
parsing/README.md
Normal file
5
parsing/README.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# Parsing Scripts
|
||||||
|
|
||||||
|
### Definition
|
||||||
|
|
||||||
|
These scripts should be used to demonstrate how to parse any file format, including `json`, `csv`, etc. Also, perhaps parsing of `external` commands. For example, on Windows, perhaps we could wrap `ipconfig.exe` so that the output was more nushell friendly.
|
17
print.nu
17
print.nu
|
@ -1,17 +0,0 @@
|
||||||
# Not working yet
|
|
||||||
|
|
||||||
# A print command that concatenates arguments together with an optional separator
|
|
||||||
# By default there will be no newline
|
|
||||||
def print [
|
|
||||||
--separator(-s):any? # Optional separator
|
|
||||||
...rest # All of the parameters
|
|
||||||
] {
|
|
||||||
let is_empty = $(empty? $separator)
|
|
||||||
echo $rest | each {
|
|
||||||
if $is_empty {
|
|
||||||
build-string $it
|
|
||||||
} {
|
|
||||||
build-string $it $separator
|
|
||||||
}
|
|
||||||
} | str collect
|
|
||||||
}
|
|
22
progress_bar.nu
Normal file
22
progress_bar.nu
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
# progress bar attempt - not 100% yet
|
||||||
|
# https://askubuntu.com/questions/747143/create-a-progress-bar-in-bash
|
||||||
|
# https://www.shellscript.sh/tips/progressbar/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
let fill = "▒" # Fill up to $Len
|
||||||
|
let arr = [ "▉" "▎" "▌" "▊" ] # UTF-8 left blocks: 7/8, 1/4, 1/2, 3/4
|
||||||
|
let pb_len = 10
|
||||||
|
|
||||||
|
echo $(ansi cursor_off)
|
||||||
|
|
||||||
|
#Move cursor all the way to the left
|
||||||
|
echo $(ansi -e '1000D') | autoview
|
||||||
|
echo $fill | str lpad -c $fill -l $pb_len
|
||||||
|
echo 1..$pb_len | each {
|
||||||
|
sleep 50ms
|
||||||
|
echo $arr.0 | str lpad -c $arr.0 -l $it | autoview
|
||||||
|
echo $(ansi -e '1000D') | autoview
|
||||||
|
}
|
||||||
|
echo $(char newline)
|
||||||
|
echo $(ansi cursor_on)
|
5
prompt/README.md
Normal file
5
prompt/README.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# Prompt Scripts
|
||||||
|
|
||||||
|
### Definition
|
||||||
|
|
||||||
|
These scripts should be used to draw a custom command prompt in nushell. They can include anything that we think is appropriate for prompts such as `git` commands, `starship`, `oh-my-posh`, etc.
|
13
stdlib_candidate/README.md
Normal file
13
stdlib_candidate/README.md
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
# Nushell standard library candidate scripts
|
||||||
|
|
||||||
|
### Definition
|
||||||
|
|
||||||
|
Standard library candidates are scripts that should be installed with nushell and be sourced at startup time that add additional functionality to nushell. Some of these scripts could even take the place of some of the current rust code.
|
||||||
|
|
||||||
|
### Why Candidate?
|
||||||
|
|
||||||
|
Since this is really the only documentation of what should be in a standard library for nushell, we need to decide as a community what needs to be included in a standard library.
|
||||||
|
|
||||||
|
### Category
|
||||||
|
|
||||||
|
Standard Library candidates can be any category of script.
|
26
stdlib_candidate/print.nu
Normal file
26
stdlib_candidate/print.nu
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
# A print command that concatenates arguments together with an optional separator
|
||||||
|
# By default there will be no newline
|
||||||
|
def print [
|
||||||
|
--separator(-s):any # Optional separator (not yet flagged as optional?)
|
||||||
|
...rest # All of the parameters
|
||||||
|
] {
|
||||||
|
let is_empty = $(= $separator | empty?)
|
||||||
|
let num_of_rest = $(echo $rest | count)
|
||||||
|
echo $rest | each --numbered {
|
||||||
|
if $is_empty {
|
||||||
|
build-string $it.item
|
||||||
|
} {
|
||||||
|
if $num_of_rest > $(= $it.index + 1) {
|
||||||
|
build-string $it.item $separator
|
||||||
|
} {
|
||||||
|
build-string $it.item
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} | str collect
|
||||||
|
}
|
||||||
|
|
||||||
|
# > print 1 2 3 "four" -s '--'
|
||||||
|
# 1--2--3--four
|
||||||
|
|
||||||
|
# > print 1 2 3 "four"
|
||||||
|
# 123four
|
Loading…
Add table
Add a link
Reference in a new issue