Changed . token to _dot

This change allows the dotfiles to work with chezmoi (e.g: on windows)
and improves grepability with neovim/telescope
This commit is contained in:
2024-11-07 13:52:17 +00:00
parent 83b02bd753
commit 896af887ca
2351 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
# construct bars based of a given percentage from a given width (5 is default)
# > bar 0.2
# █
# > bar 0.71
# ███▌
def 'bar' [
percentage: float
--background (-b): string = 'default'
--foreground (-f): string = 'default'
--progress (-p) # output the result using 'print -n'
--width (-w): int = 5
] {
let blocks = [null "▏" "▎" "▍" "▌" "▋" "▊" "▉" "█"]
let $whole_part = (($blocks | last) * ($percentage * $width // 1))
let $fraction = (
$blocks
| get (
($percentage * $width) mod 1
| $in * ($blocks | length | $in - 1)
| math round
)
)
let result = (
$"($whole_part)($fraction)"
| fill -c $' ' -w $width
| if ($foreground == 'default') and ($background == 'default') {} else {
$"(ansi -e {fg: ($foreground), bg: ($background)})($in)(ansi reset)"
}
)
if $progress {
print -n $"($result)\r"
} else {
$result
}
}
use std assert equal
#[test]
def bar_tests [] {
equal "█▌ " (bar 0.3)
equal "███ " (bar 0.3 --width 10)
equal "▊" (bar 0.71 --width 1)
equal "███████▏ " (bar 0.71 --width 10)
}

View File

@@ -0,0 +1,23 @@
def loading [] {
print -n $"Loading (char newline)"
0..100 | each { |tick|
sleep 50ms
# I believe '1000D' means move the cursor to the left 1000 columns
print -n $"(ansi -e '1000D')($tick)%"
}
#show_cursor
}
def show_cursor [] {
print $"(ansi -e '?25h')"
}
def hide_cursor [] {
print $"(ansi -e '?25l')"
}
def demo_percent_meter [] {
hide_cursor
loading
show_cursor
}

View File

@@ -0,0 +1,52 @@
# progress bar attempt
# https://askubuntu.com/questions/747143/create-a-progress-bar-in-bash
# https://www.shellscript.sh/tips/progressbar/
# There is a strange artifact drawing the first two full blocks
# You can see this artifact better in progress_bar_no_back.nu
# I'm not sure what's going on nor how to fix it.
let pb_len = 25
let bg_fill = "▒" # Fill up to $pb_len
let blocks = ["▏" "▎" "▍" "▌" "▋" "▊" "▉" "█"]
# "█" #8/8
# "▉" #7/8
# "▊" #3/4
# "▋" #5/8
# "▌" #1/2
# "▍" #3/8
# "▎" #1/4
# "▏" #1/8
# Turn off the cursor
ansi cursor_off
# Move cursor all the way to the left
print -n $"(ansi -e '1000D')"
# Draw the background for the progress bar
print -n ($bg_fill | fill -c $bg_fill -w $pb_len -a r)
1..<$pb_len | each { |cur_progress|
# This is kind of a hack because it's not incrementally drawing a new box
# It's drawing the entire row every time with a different padding amount
# echo $blocks.7 | fill --character $blocks.7 --width $it --align right
0..7 | each { |tick|
let cur_idx = ($tick mod 8)
let cur_block = (echo $blocks | get $cur_idx)
print -n $"(ansi -e '1000D')($cur_block | fill -c $blocks.7 -w $cur_progress -a r)"
sleep 20ms
}
print -n $"(ansi -e '1000D')"
}
# Fill in the last background block
print $"($blocks.7 | fill -c $blocks.7 -w $pb_len -a r)"
"Done"
ansi cursor_on
# Try to do this in the next version
# Make it a custom command so you can do
# set-progress 33 100
# and the display look like
# 33% (33/100) [███████████ ]

View File

@@ -0,0 +1,16 @@
let blocks = ["▏" "▎" "▍" "▌" "▋" "▊" "▉" "█"]
let pb_size = 25
ansi cursor_off
1..<$pb_size | each { |cur_size|
0..7 | each { |tick|
let idx = ($tick mod 8)
let cur_block = ($blocks | get $idx)
print -n $"(ansi -e '1000D')($cur_block | fill -c $blocks.7 -w $cur_size -a r)"
sleep 20ms
}
print -n $"(ansi -e '1000D')"
}
print $"($blocks.7 | fill -c $blocks.7 -w $pb_size -a r)"
'Done'
ansi cursor_on