rewrite nu shit
This commit is contained in:
parent
f64f61b9b6
commit
2ce0df9880
6 changed files with 101 additions and 96 deletions
67
modules/shell/nu/custom_commands.nu
Normal file
67
modules/shell/nu/custom_commands.nu
Normal file
|
@ -0,0 +1,67 @@
|
|||
# open nix shell with a bunch of programs
|
||||
def nsp [
|
||||
...programs: string
|
||||
] {
|
||||
nix shell ...($programs | each {|it| $"nixpkgs#($it)" })
|
||||
}
|
||||
|
||||
# do a nix run of a nix package
|
||||
def nr [
|
||||
program: string
|
||||
] {
|
||||
nix run $"nixpkgs#($program)"
|
||||
}
|
||||
|
||||
# do a recursive line count of a file extension
|
||||
def lcr [
|
||||
file_extension: string
|
||||
] {
|
||||
ls **/*
|
||||
| where name ends-with $".($file_extension)"
|
||||
| par-each {|file|
|
||||
open $file.name
|
||||
| lines --skip-empty
|
||||
| length }
|
||||
| math sum
|
||||
}
|
||||
|
||||
# get parsed git log
|
||||
def glog [
|
||||
amount: int
|
||||
] {
|
||||
git log --pretty=%h»¦«%s»¦«%aN»¦«%aE»¦«%aD -n $amount
|
||||
| lines
|
||||
| split column "»¦«" commit subject name email date
|
||||
}
|
||||
|
||||
# open typst IDE ish setup
|
||||
def typed [
|
||||
name: string
|
||||
] {
|
||||
touch $"($name).typ"
|
||||
typst compile $"($name).typ"
|
||||
mprocs --names Editor,Viewer,Notify $"hx '($name).typ'" $"while true; do mupdf-x11 '($name).pdf' && break; done" $"while inotifywait -e modify '($name).pdf' ; do pkill -HUP mupdf; done"
|
||||
}
|
||||
|
||||
# figure out when the next event is
|
||||
def nev [ unit = day ] {
|
||||
( ( open Docs/dates.csv
|
||||
| update datetime {|it| $it.datetime | into datetime }
|
||||
| first
|
||||
).datetime - (date now)
|
||||
)
|
||||
| into duration
|
||||
| format duration $unit
|
||||
}
|
||||
|
||||
# open chromium with bahn.expert opened and ready
|
||||
# TODO: intermediate stations
|
||||
def bx [from: string to: string] {
|
||||
let map = open ~/Docs/ril100map.json;
|
||||
let start = $map | get ($from | str upcase) | first;
|
||||
let dest = $map | get ($to | str upcase) | first;
|
||||
|
||||
let url = $"https://bahn.expert/routing/($start)/($dest)/0/";
|
||||
print $url;
|
||||
^bash -c $"nohup chromium '($url)' &";
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue