mirror of
https://github.com/nushell/nu_scripts.git
synced 2024-10-26 22:08:03 +03:00
c47ccd42b8
* refactor: ✨ move in one commit
Eveything in modules should probably be changed to `exported` defs.
The idea is to move everything first to keep proper history.
* refactor: 📝 add modules readme (wip)
* refactor: ✨ small move
* refactor: 📝 changed nestring, updated modules readme
* refactor: 📝 to document or not to document
* fix: 🐛 themes
replaced the template to use `main` and regenerated them
from lemnos themes.
* Revert "fix: 🐛 themes"
This reverts commit 4918d3633c
.
* refactor: ✨ introduce sourced
- Created a source `root` in which sourcable demos are stored.
Some might get converted to modules later on.
- Moved some files to bin too.
* fix: 🐛 fehbg.nu
* fix: 🐛 modules/after.nu
* moved some other stuff around
---------
Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
79 lines
2.2 KiB
Plaintext
79 lines
2.2 KiB
Plaintext
# (See TODO.md for more details)
|
|
|
|
# This first command looks for the file with the todo list and
|
|
# prints it to the screen.
|
|
def-env printer [] {
|
|
let contents = (
|
|
# if you haven't setup this environment var,
|
|
# replace `$env.TODO` with the path to your
|
|
# `todo.txt`
|
|
open $env.TODO
|
|
| split row "\n"
|
|
| take (($in | length) - 1)
|
|
| each {|$it, n| $"($n + 1) (ansi red)->(ansi reset) ($it)"}
|
|
| str join "\n"
|
|
)
|
|
|
|
# change the message to print what you want
|
|
if $contents == "" {
|
|
echo $"\n(ansi lgb)Everything's been done!!! Yay!!!(ansi reset)\n"
|
|
} else {
|
|
echo $"\n(ansi lgb)You promised to do these(ansi reset)\n($contents)"
|
|
}
|
|
}
|
|
|
|
printer # don't forget to call it here, so that it gets run automatically
|
|
|
|
# This command is used to update you todo-list, and should ideally be
|
|
# sourced in your `config.nu`
|
|
def todo [
|
|
--edit(-e) # edit todo manually
|
|
--add(-a): string # add item
|
|
--remove(-r): int # remove an item using its number
|
|
--clear(-c) # clear the list
|
|
] {
|
|
def get_todo [] {
|
|
# if you haven't setup this environment var,
|
|
# replace `$env.TODO` with the path to your
|
|
# `todo.txt`
|
|
open $env.TODO
|
|
| split row "\n"
|
|
| take (($in | length) - 1)
|
|
}
|
|
|
|
def todo_add [todo: string] {
|
|
get_todo
|
|
| reverse
|
|
| $in ++ [$todo]
|
|
| reverse
|
|
| save $env.TODO -f
|
|
}
|
|
|
|
def todo_rm [num: int] {
|
|
get_todo
|
|
| reverse
|
|
# change ($num - 1) to $num to have zero-based indexing
|
|
| filter {|it, n| $n != ($num - 1) }
|
|
| reverse
|
|
| save $env.TODO -f
|
|
}
|
|
|
|
if $edit {
|
|
clear
|
|
vim $env.TODO # replace `vim` with your favorite editor
|
|
} else if ($add != null) {
|
|
clear
|
|
todo_add $add | todo
|
|
} else if ($remove != null) {
|
|
clear
|
|
todo_rm $remove | todo
|
|
} else if $clear {
|
|
clear
|
|
# change the message to print what you want
|
|
"" | save $env.TODO -f | echo $"(ansi lgb)todo cleared!!!"
|
|
} else {
|
|
clear
|
|
printer
|
|
}
|
|
}
|