1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-01 06:37:46 +00:00

Fix typos (#982)

This commit is contained in:
Ian Manske 2024-11-21 20:51:05 -08:00 committed by GitHub
parent fc1d1989b6
commit dee0e7efcd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 838 additions and 833 deletions

View file

@ -38,7 +38,7 @@ def print_colour [ colour:int ] {
$bg_color + $fg_color + $text + " "
}
let printable_colours = 256
const printable_colours = 256
def print_run [start:int, amount:int] {
$start..<($start + $amount) | each { |i|
@ -62,12 +62,13 @@ def print_blocks [start:int, end:int, block_cols:int, block_rows:int, blocks_per
} | str join
}
print (print_run 0 16) # The first 16 colours are spread over the whole spectrum
print "" # Single line
print (print_blocks 16 123 6 6 3) # 6x6x6 colour cube between 16 and 123 inclusive
print (print_blocks 124 231 6 6 3) # 6x6x6 colour cube between 124 and 231 inclusive
print (print_blocks 232 255 12 2 1) # Not 50, but 24 Shades of Grey
export def main [] {
print (print_run 0 16) # The first 16 colours are spread over the whole spectrum
print "" # Single line
print (print_blocks 16 123 6 6 3) # 6x6x6 colour cube between 16 and 123 inclusive
print (print_blocks 124 231 6 6 3) # 6x6x6 colour cube between 124 and 231 inclusive
print (print_blocks 232 255 12 2 1) # Not 50, but 24 Shades of Grey
}
# bash:
@ -113,7 +114,7 @@ print (print_blocks 232 255 12 2 1) # Not 50, but 24 Shades of Grey
#
# # Uncomment the below for more precise luminance calculations
#
# # # Calculate percieved brightness
# # # Calculate perceived brightness
# # # See https://www.w3.org/TR/AERT#color-contrast
# # # and http://www.itu.int/rec/R-REC-BT.601
# # # Luminance is in range 0..5000 as each value is 0..5

View file

@ -1,5 +1,5 @@
# this script uses foreground ansi index colors to print
# a table of 16 rows by 16 colums where each item is a
# a table of 16 rows by 16 columns where each item is a
# different color
def show_index_colors [] {
let prefix = "38;5;"
@ -24,4 +24,6 @@ def one_liner [] {
}
show_index_colors
export def main [] {
show_index_colors
}

View file

@ -1,7 +1,7 @@
# A Terminal Wordle game.
# A Terminal Wordle game.
# The code is based on https://gist.github.com/huytd/6a1a6a7b34a0d0abcac00b47e3d01513 ,but slightly personalized.
# a simple termninal Wordle game!
# a simple terminal Wordle game!
export def main [
--unlimited(-u) # Play the game in unlimited mode.
--max_count(-M) : int = 6 # Give yourself more chances than default
@ -23,7 +23,7 @@ export def main [
if (((($words | where column1 =~ $guess) | length) >= 1) and ($guess | str length) == 5) {
mut out = ""
mut checked = $word
for i in ($guess | split chars) -n {
for i in ($guess | split chars | enumerate) {
if ($i.item == ($word | str substring ($i.index)..($i.index + 1)) ) {
$out += $"(ansi green_reverse)($i.item)(ansi reset)"
$avail = ($avail | str replace $i.item $"(ansi green_reverse)($i.item)(ansi white_reverse)")
@ -46,10 +46,10 @@ export def main [
} else {
echo "please enter a valid [5 letter] word!"
$guess_count -= 1
}
}
} else {
echo $"(ansi yellow )You loose, the word was: (ansi red)($word)(ansi reset)"
$end = true
}
}
}
}

View file

@ -211,7 +211,7 @@ export def "cartesian product" [
def cartesian_product [] {
use std assert
# emptyness
# emptiness
assert equal (cartesian product [] []) []
assert equal (cartesian product []) []
assert equal (cartesian product) []

View file

@ -1,15 +1,15 @@
# Build a full-line prompt with widgets for:
# Build a full-line prompt with widgets for:
# activated python virtual environment (from `overlay use <ve>/bin/activate.nu`)
# current working directory
# git status (branch, branch ahead/behind remote, files changed)
# git status (branch, branch ahead/behind remote, files changed)
# current position in remembered working directories (`std dirs`, a.k.a. `shells`)
# also, as a nu dev special, widget for active nu executable (flags `cargo run` vs "installed" and which branch built from).
#
#
# to use:
# 1. copy this file to `($nu.default-config-dir | path add 'scripts')` (Or someplace on your $env.NU_LIB_DIRS path, defined in env.nu)
# 2. cut `$env.PROMPT_COMMAND` and `PROMPT_OMMAND_RIGHT' from your env.nu.
# 2. cut `$env.PROMPT_COMMAND` and `PROMPT_OMMAND_RIGHT' from your env.nu.
# These will depend on `use full-line`, which can not be done in env.nu.
# You can leave the `PROMPT-*INDICATOR*` statements in env.nu or
# You can leave the `PROMPT-*INDICATOR*` statements in env.nu or
# consolidate all prompt stuff in config.nu.
# 3. Add new prompt setup stuff somewhere in config.nu:
# ```
@ -18,7 +18,7 @@
# $env.PROMPT_COMMAND_RIGHT = ""
# ```
#
# credit panache-git for the git status widget.
# credit panache-git for the git status widget.
use std dirs
use std assert
@ -40,14 +40,14 @@ export def main [
let mid_content = ($" (dir_string) ")
let mid_content_len = ($mid_content | ansi strip | str length -g)
let dirs_segment = $" |(dirs show | each {|it| if $it.active {'V'} else {'.'}} | str join '')|"
let dirs_segment = $" |(dirs | each {|it| if $it.active {'V'} else {'.'}} | str join '')|"
let right_content = ($"(repo-styled)($pad_char + $pad_char + $pad_char)($dirs_segment)")
let right_content_len = ($right_content | ansi strip | str length -g)
let term_width = ((term size) | get columns)
let mid_padding = ($term_width - $left_content_len - $right_content_len)
[(ansi reset),
$left_content,
($mid_content | fill --character $pad_char --width $mid_padding --alignment center),
@ -58,7 +58,7 @@ export def main [
# build current exe widget
def current_exe [] {
let content = ([
let content = ([
($nu.current-exe | path dirname | path basename | str replace "bin" ""),
(version | get branch | str replace "main" ""),
] | str join " " | str trim)
@ -70,7 +70,7 @@ def current_exe [] {
}
# build current working directory segment
## don't get sucked into the path syntax wars: simply color portions of path to flag priviliged vs normal user mode.
## don't get sucked into the path syntax wars: simply color portions of path to flag privileged vs normal user mode.
def dir_string [] {
let path_color = (if (is-admin) { ansi red_bold } else { ansi green_bold })
@ -78,7 +78,7 @@ def dir_string [] {
$"($path_color)($env.PWD)(ansi reset)" | str replace --all (char path_sep) $"($separator_color)(char path_sep)($path_color)"
}
# Following code cheerfully ~~stolen~~ adapted from:
# Following code cheerfully ~~stolen~~ adapted from:
# https://github.com/nushell/nu_scripts/blob/ab0d3aaad015ca8ac2c2004d728cc8bac32cda1b/modules/prompt/panache-git.nu
# Get repository status as structured data

View file

@ -20,7 +20,7 @@ export def construct_prompt [] {
# get the terminal width
let term_width = (term size).columns
# get the curren time
# get the current time
let current_time = (date now | format date '%I:%M:%S%.3f %p')
# let's construct the left and right prompt
@ -33,7 +33,7 @@ export def construct_prompt [] {
# the right side of the prompt with ansi colors
let right_colored = $"(ansi blue)($env.CMD_DURATION_MS)|(ansi dark_gray)($current_time)(ansi reset)"
# let's calcuate the length of the right prompt so we know how much to pad the left prompt
# let's calculate the length of the right prompt so we know how much to pad the left prompt
let calculated_right_len = ($term_width - $left_len)
# finally, let's make the prompt
let the_prompt = $"($left_colored)($right_colored | fill -a r -c ' ' -w $calculated_right_len)(char newline)($decorator) "

View file

@ -2,168 +2,168 @@
# modes
# * 8bit
# * 24bit
let color_mode = "8bit"
const color_mode = "8bit"
# setup separate characters
let left_prompt_separator_diff_color = (char -u 'e0b0')
let left_prompt_separator_same_color = (char -u 'e0b1')
let right_prompt_separator_diff_color = (char -u 'e0b2')
let right_prompt_separator_same_color = (char -u 'e0b3')
const left_prompt_separator_diff_color = (char -u 'e0b0')
const left_prompt_separator_same_color = (char -u 'e0b1')
const right_prompt_separator_diff_color = (char -u 'e0b2')
const right_prompt_separator_same_color = (char -u 'e0b3')
# setup color variables for 24bit and 8bit
# prompt
let prompt_color_frame_and_connection_24 = (ansi -e { fg: "#6C6C6C" })
let prompt_color_separator_same_color_24 = (ansi -e { fg: "#949494" })
let prompt_color_frame_and_connection_8 = $"(ansi idx_fg)242m"
let prompt_color_separator_same_color_8 = $"(ansi idx_fg)246m"
let prompt_add_new_line_before = false
let prompt_color_frame_and_connection = ""
let prompt_color_separator_same_color = ""
const prompt_color_frame_and_connection_24 = (ansi -e { fg: "#6C6C6C" })
const prompt_color_separator_same_color_24 = (ansi -e { fg: "#949494" })
const prompt_color_frame_and_connection_8 = $"(ansi idx_fg)242m"
const prompt_color_separator_same_color_8 = $"(ansi idx_fg)246m"
const prompt_add_new_line_before = false
const prompt_color_frame_and_connection = ""
const prompt_color_separator_same_color = ""
let left_separator_diff_color = ""
let left_separator_same_color = ""
let left_items = []
let left_prefix = ""
let left_suffix = ""
const left_separator_diff_color = ""
const left_separator_same_color = ""
const left_items = []
const left_prefix = ""
const left_suffix = ""
let right_separator_diff_color = ""
let right_separator_same_color = ""
let right_items = []
let right_prefix = ""
let right_suffix = ""
const right_separator_diff_color = ""
const right_separator_same_color = ""
const right_items = []
const right_prefix = ""
const right_suffix = ""
# cmd
let cmd_duration_bg_color_24 = (ansi -e { bg: "#C4A000" })
let cmd_duration_color_24 = (ansi -e { fg: "#000000" })
let cmd_duration_bg_color_8 = $"(ansi idx_bg)178m"
let cmd_duration_color_8 = $"(ansi idx_fg)16m"
let cmd_bg_color = ""
let cmd_color = ""
let cmd_decimals = 2
let cmd_icon = ""
const cmd_duration_bg_color_24 = (ansi -e { bg: "#C4A000" })
const cmd_duration_color_24 = (ansi -e { fg: "#000000" })
const cmd_duration_bg_color_8 = $"(ansi idx_bg)178m"
const cmd_duration_color_8 = $"(ansi idx_fg)16m"
const cmd_bg_color = ""
const cmd_color = ""
const cmd_decimals = 2
const cmd_icon = ""
# git
let git_bg_color_24 = (ansi -e { bg: "#4E9A06" })
let git_bg_color_unstable_24 = (ansi -e { bg: "#C4A000" })
let git_bg_color_urgent_24 = (ansi -e { bg: "#CC0000" })
let git_color_branch_24 = (ansi -e { fg: "#000000" })
let git_color_conflicted_24 = (ansi -e { fg: "#000000" })
let git_color_dirty_24 = (ansi -e { fg: "#000000" })
let git_color_operation_24 = (ansi -e { fg: "#000000" })
let git_color_staged_24 = (ansi -e { fg: "#000000" })
let git_color_stash_24 = (ansi -e { fg: "#000000" })
let git_color_untracked_24 = (ansi -e { fg: "#000000" })
let git_color_upstream_24 = (ansi -e { fg: "#000000" })
const git_bg_color_24 = (ansi -e { bg: "#4E9A06" })
const git_bg_color_unstable_24 = (ansi -e { bg: "#C4A000" })
const git_bg_color_urgent_24 = (ansi -e { bg: "#CC0000" })
const git_color_branch_24 = (ansi -e { fg: "#000000" })
const git_color_conflicted_24 = (ansi -e { fg: "#000000" })
const git_color_dirty_24 = (ansi -e { fg: "#000000" })
const git_color_operation_24 = (ansi -e { fg: "#000000" })
const git_color_staged_24 = (ansi -e { fg: "#000000" })
const git_color_stash_24 = (ansi -e { fg: "#000000" })
const git_color_untracked_24 = (ansi -e { fg: "#000000" })
const git_color_upstream_24 = (ansi -e { fg: "#000000" })
let git_bg_color_8 = $"(ansi idx_bg)70m"
let git_bg_color_unstable_8 = $"(ansi idx_bg)178m"
let git_bg_color_urgent_8 = $"(ansi idx_bg)160m"
let git_color_branch_8 = $"(ansi idx_fg)16m"
let git_color_conflicted_8 = $"(ansi idx_fg)16m"
let git_color_dirty_8 = $"(ansi idx_fg)16m"
let git_color_operation_8 = $"(ansi idx_fg)16m"
let git_color_staged_8 = $"(ansi idx_fg)16m"
let git_color_stash_8 = $"(ansi idx_fg)16m"
let git_color_untracked_8 = $"(ansi idx_fg)16m"
let git_color_upstream_8 = $"(ansi idx_fg)16m"
const git_bg_color_8 = $"(ansi idx_bg)70m"
const git_bg_color_unstable_8 = $"(ansi idx_bg)178m"
const git_bg_color_urgent_8 = $"(ansi idx_bg)160m"
const git_color_branch_8 = $"(ansi idx_fg)16m"
const git_color_conflicted_8 = $"(ansi idx_fg)16m"
const git_color_dirty_8 = $"(ansi idx_fg)16m"
const git_color_operation_8 = $"(ansi idx_fg)16m"
const git_color_staged_8 = $"(ansi idx_fg)16m"
const git_color_stash_8 = $"(ansi idx_fg)16m"
const git_color_untracked_8 = $"(ansi idx_fg)16m"
const git_color_upstream_8 = $"(ansi idx_fg)16m"
let git_bg_color = ""
let git_bg_color_unstable = ""
let git_bg_color_urgent = ""
let git_color_branch = ""
let git_color_conflicted = ""
let git_color_dirty = ""
let git_color_operation = ""
let git_color_staged = ""
let git_color_stash = ""
let git_color_untracked = ""
let git_color_upstream = ""
const git_bg_color = ""
const git_bg_color_unstable = ""
const git_bg_color_urgent = ""
const git_color_branch = ""
const git_color_conflicted = ""
const git_color_dirty = ""
const git_color_operation = ""
const git_color_staged = ""
const git_color_stash = ""
const git_color_untracked = ""
const git_color_upstream = ""
# os
let os_bg_color_24 = (ansi -e { bg: "#CED7CF" })
let os_color_24 = (ansi -e { fg: "#080808" })
let os_bg_color_8 = $"(ansi idx_bg)188m"
let os_color_8 = $"(ansi idx_fg)232m"
let os_bg_color = ""
let os_color = ""
const os_bg_color_24 = (ansi -e { bg: "#CED7CF" })
const os_color_24 = (ansi -e { fg: "#080808" })
const os_bg_color_8 = $"(ansi idx_bg)188m"
const os_color_8 = $"(ansi idx_fg)232m"
const os_bg_color = ""
const os_color = ""
# pwd
let pwd_bg_color_24 = (ansi -e { bg: "#3465A4" })
let pwd_color_anchors_24 = (ansi -e { fg: "#E4E4E4" })
let pwd_color_dirs_24 = (ansi -e { fg: "#E4E4E4" })
let pwd_color_truncated_dirs_24 = (ansi -e { fg: "#BCBCBC" })
const pwd_bg_color_24 = (ansi -e { bg: "#3465A4" })
const pwd_color_anchors_24 = (ansi -e { fg: "#E4E4E4" })
const pwd_color_dirs_24 = (ansi -e { fg: "#E4E4E4" })
const pwd_color_truncated_dirs_24 = (ansi -e { fg: "#BCBCBC" })
let pwd_bg_color_8 = $"(ansi idx_bg)61m"
let pwd_color_anchors_8 = $"(ansi idx_fg)254m"
let pwd_color_dirs_8 = $"(ansi idx_fg)254m"
let pwd_color_truncated_dirs_8 = $"(ansi idx_fg)250m"
const pwd_bg_color_8 = $"(ansi idx_bg)61m"
const pwd_color_anchors_8 = $"(ansi idx_fg)254m"
const pwd_color_dirs_8 = $"(ansi idx_fg)254m"
const pwd_color_truncated_dirs_8 = $"(ansi idx_fg)250m"
let pwd_bg_color = ""
let pwd_color_anchors = ""
let pwd_color_dirs = ""
let pwd_color_truncated_dirs = ""
let pwd_icon = ""
let pwd_icon_home = ""
let pwd_icon_unwritable = ""
let pwd_markers = []
const pwd_bg_color = ""
const pwd_color_anchors = ""
const pwd_color_dirs = ""
const pwd_color_truncated_dirs = ""
const pwd_icon = ""
const pwd_icon_home = ""
const pwd_icon_unwritable = ""
const pwd_markers = []
# rustc
let rustc_bg_color_24 = (ansi -e { bg: "#F74C00" })
let rustc_color_24 = (ansi -e { fg: "#000000" })
let rustc_bg_color_8 = $"(ansi idx_bg)202m"
let rustc_color_8 = $"(ansi idx_fg)16m"
const rustc_bg_color_24 = (ansi -e { bg: "#F74C00" })
const rustc_color_24 = (ansi -e { fg: "#000000" })
const rustc_bg_color_8 = $"(ansi idx_bg)202m"
const rustc_color_8 = $"(ansi idx_fg)16m"
let rustc_bg_color = ""
let rustc_color = ""
let rustc_icon = ""
const rustc_bg_color = ""
const rustc_color = ""
const rustc_icon = ""
# status
let status_bg_color_24 = (ansi -e { bg: "#2E3436" })
let status_bg_color_failure_24 = (ansi -e { bg: "#CC0000" })
let status_color_24 = (ansi -e { fg: "#4E9A06" })
let status_color_failure_24 = (ansi -e { fg: "#FFFF00" })
const status_bg_color_24 = (ansi -e { bg: "#2E3436" })
const status_bg_color_failure_24 = (ansi -e { bg: "#CC0000" })
const status_color_24 = (ansi -e { fg: "#4E9A06" })
const status_color_failure_24 = (ansi -e { fg: "#FFFF00" })
let status_bg_color_8 = $"(ansi idx_bg)236m"
let status_bg_color_failure_8 = $"(ansi idx_bg)160m"
let status_color_8 = $"(ansi idx_fg)70m"
let status_color_failure_8 = $"(ansi idx_fg)226m"
const status_bg_color_8 = $"(ansi idx_bg)236m"
const status_bg_color_failure_8 = $"(ansi idx_bg)160m"
const status_color_8 = $"(ansi idx_fg)70m"
const status_color_failure_8 = $"(ansi idx_fg)226m"
let status_bg_color = ""
let status_bg_color_faiure = ""
let status_color = ""
let status_color_failure = ""
let status_icon = ""
let status_icon_failure = ""
const status_bg_color = ""
const status_bg_color_failure = ""
const status_color = ""
const status_color_failure = ""
const status_icon = ""
const status_icon_failure = ""
# time
let time_bg_color_24 = (ansi -e { bg: "#D3D7CF" })
let time_color_24 = (ansi -e { fg: "#000000" })
let time_bg_color_8 = $"(ansi idx_bg)188m"
let time_color_8 = $"(ansi idx_fg)16m"
const time_bg_color_24 = (ansi -e { bg: "#D3D7CF" })
const time_color_24 = (ansi -e { fg: "#000000" })
const time_bg_color_8 = $"(ansi idx_bg)188m"
const time_color_8 = $"(ansi idx_fg)16m"
let time_bg_color = ""
let time_color = ""
let time_format = ""
const time_bg_color = ""
const time_color = ""
const time_format = ""
# indicator
let indicator_color_24 = (ansi -e { fg: "#3465a4" })
let indicator_bg_color_24 = (ansi -e { bg: "#000000" })
let indicator_color_8 = $"(ansi idx_fg)61m"
let indicator_bg_color_8 = $"(ansi idx_bg)16m"
const indicator_color_24 = (ansi -e { fg: "#3465a4" })
const indicator_bg_color_24 = (ansi -e { bg: "#000000" })
const indicator_color_8 = $"(ansi idx_fg)61m"
const indicator_bg_color_8 = $"(ansi idx_bg)16m"
# terminal background color
let terminal_color_24 = (ansi -e { fg: "#c7c7c7" })
let terminal_color_8 = (ansi white)
let terminal_bg_color_24 = (ansi -e { bg: "#000000" })
let terminal_bg_color_8 = (ansi black)
const terminal_color_24 = (ansi -e { fg: "#c7c7c7" })
const terminal_color_8 = (ansi white)
const terminal_bg_color_24 = (ansi -e { bg: "#000000" })
const terminal_bg_color_8 = (ansi black)
# cmd_duration_ms
let cmd_duration_ms_color_24 = (ansi -e { fg: "#606060" })
let cmd_duration_ms_color_8 = $"(ansi idx_fg)244m"
let cmd_duration_ms_bg_color_24 = (ansi -e { fg: "#000000" })
let cmd_duration_ms_bg_color_8 = (ansi black)
const cmd_duration_ms_color_24 = (ansi -e { fg: "#606060" })
const cmd_duration_ms_color_8 = $"(ansi idx_fg)244m"
const cmd_duration_ms_bg_color_24 = (ansi -e { fg: "#000000" })
const cmd_duration_ms_bg_color_8 = (ansi black)
let runtime_colors = [
const runtime_colors = [
{ name: prompt_color_frame_and_connection, '8bit': $prompt_color_frame_and_connection_8, '24bit': $prompt_color_frame_and_connection_24 },
{ name: prompt_color_separator_same_color, '8bit': $prompt_color_separator_same_color_8, '24bit': $prompt_color_separator_same_color_24 },
{ name: left_separator_diff_color, '8bit': $left_prompt_separator_diff_color, '24bit': $left_prompt_separator_diff_color },

File diff suppressed because it is too large Load diff