NOflake/users/tao/nushell/stuff.nu

171 lines
3.6 KiB
Text
Raw Normal View History

2024-08-28 13:49:15 -07:00
task
2024-05-16 01:56:17 -07:00
2024-08-28 13:49:15 -07:00
alias xo = xdg-open
2024-09-05 15:18:19 -07:00
# alias h = hx (sk)
2024-05-16 01:56:17 -07:00
alias b = btm
alias cringe = sudo bootctl set-oneshot auto-windows
alias fetch = fastfetch
alias ff = firefox
alias pu = pueue
alias t = task
alias zl = zellij
2024-06-17 13:13:35 -07:00
alias snapper = snapper -c home
2024-09-21 00:01:32 -07:00
2024-09-05 15:18:19 -07:00
alias quiet = sudo ectool fanduty 30
2024-08-29 10:12:47 -07:00
alias loud = sudo ectool autofanctrl
2024-09-21 00:01:32 -07:00
alias cp = cp -prv
alias mv = mv -pv
2024-05-19 16:14:11 -07:00
alias jd = jj diff
2024-05-25 17:18:24 -07:00
alias jc = jj desc
2024-05-19 16:14:11 -07:00
alias js = jj status
alias jp = jj git push
alias jm = jj branch set main
2024-09-05 15:18:19 -07:00
def h [] {
sk | complete |
if $in.exit_code == 0 {
$in.stdout | str trim | hx $in
}
}
2024-09-01 22:11:49 -07:00
def --env c [path: path = "~"] {
cd $path
2024-05-16 01:56:17 -07:00
l
}
2024-04-28 10:56:51 -07:00
def l [
2024-05-25 17:18:24 -07:00
--all (-a)
2024-05-25 18:35:30 -07:00
--long (-l)
2024-05-16 01:56:17 -07:00
path: path = "."
2024-04-28 10:56:51 -07:00
] {
2024-05-25 18:35:30 -07:00
if $all and $long {
ls -la $path
} else if $all {
2024-05-25 17:18:24 -07:00
ls -a $path
2024-05-25 18:35:30 -07:00
} else if $long {
ls -l $path
2024-05-25 17:18:24 -07:00
} else {
ls $path
}
2024-05-16 03:51:55 -07:00
| sort-by type name -i -n
2024-04-28 10:56:51 -07:00
}
2024-09-05 15:18:19 -07:00
def srg [] {
2024-05-28 20:40:46 -07:00
sk --ansi -i -c 'rg --color=always --line-number "{}"'
2024-05-25 18:35:30 -07:00
}
2024-05-25 17:18:24 -07:00
alias nd = nix develop
2024-05-16 01:56:17 -07:00
def ns [package] {
nix shell $"nixpkgs#($package)"
}
2024-05-28 20:40:46 -07:00
def nr [package] {
nix search nixpkgs $package
}
2024-08-29 10:12:47 -07:00
def rebuild [--no-builders (-n), subcommand] {
if $no_builders {
sudo nice -n19 nixos-rebuild $subcommand --builders "" --flake /home/tao/projects/NOflake/ --impure --verbose
} else {
sudo nice -n19 nixos-rebuild $subcommand --flake /home/tao/projects/NOflake/ --impure --verbose
}
2024-05-09 23:37:38 -07:00
}
2024-06-10 17:41:44 -07:00
# def post-rebuild [] {
# # rm -r ~/.config/helix/runtime/grammars/
# # hx --grammar fetch; hx --grammar build
# # rustup update
# }
2024-05-07 13:10:41 -07:00
def bump [] {
cd /home/tao/projects/NOflake/
jj new -m "bump"
nix flake update
# rc2nix | save -f /home/tao/projects/NOflake/users/tao/plasma.nix;
2024-05-07 13:37:09 -07:00
# sudo nix store ping --store ssh://nocomputer
2024-05-09 23:37:38 -07:00
rebuild boot
2024-05-07 13:10:41 -07:00
jj new
}
2024-05-09 23:37:38 -07:00
alias rb = rebuild boot
alias rs = rebuild switch
2024-05-16 01:56:17 -07:00
alias gc = nh clean all
def check-mullvad [] {
2024-08-24 12:52:54 -07:00
loop {
2024-08-22 14:29:12 -07:00
print "checking connection status"
2024-08-24 12:52:54 -07:00
http get https://am.i.mullvad.net/json
2024-09-06 22:44:48 -07:00
| if $in.mullvad_exit_ip == true {break} else {print $in}
2024-08-28 13:49:15 -07:00
sleep 1sec
}
}
2024-05-16 01:56:17 -07:00
def tse [exit_node: string = ""] {
2024-05-28 20:40:46 -07:00
if ($exit_node | is-empty) and (ps | find deluge | is-not-empty) {
print "stop summoning first!"
return
} else {
tailscale set --exit-node $exit_node
}
2024-08-28 13:49:15 -07:00
if ($exit_node | is-not-empty) {
check-mullvad
}
2024-05-16 01:56:17 -07:00
}
2024-06-01 17:01:22 -07:00
def tsp [] {
tailscale exit-node list
| split row "\n"
| each {str trim}
| filter {is-not-empty}
| skip 1
| last 19
| first 17
| split column -r '\s{2,}'
| reject column5 column3
| rename ip addr city
| par-each {
insert ping {
|row| $row.addr
| str replace "mullvad.ts.net" "relays.mullvad.net"
| ping -c5 -q $in
| split row "\n"
| last
| split column "/"
| get column6?
| get 0
}
}
| sort-by ping -n -r
}
2024-05-16 01:56:17 -07:00
def tsr [] {
tailscale status --json
| from json
| get Peer
| transpose nodekey node
| get node
| filter {$in.Location?.Country == USA}
| get TailscaleIPs
| each {get 0}
| select (random int 0..($in | length))
| tse $in.0
2024-05-19 16:14:11 -07:00
# tailscale status
check-mullvad
2024-05-16 01:56:17 -07:00
}
2024-03-15 12:47:44 -07:00
alias ts = tailscale
alias tss = tailscale status
2024-05-16 03:51:55 -07:00
alias tsu = tailscale up
alias tsd = tailscale down
2024-03-15 12:47:44 -07:00
alias tsx = tailscale exit-node list
2024-06-01 17:01:22 -07:00
alias tsa = tailscale exit-node suggest
2024-05-28 20:40:46 -07:00
def "config stuff" [] {
hx ~/projects/NOflake/users/tao/nushell/stuff.nu
}
def deluge-gtk [] {
tsr
deluge-gtk
}
alias deluge = deluge-gtk
def fixme [] {
rg TODO --json
| lines
| each {from json}
| where type == "match"
| get data
| flatten
| each {$"($in.text):($in.line_number)"}
| hx ...$in
}
2024-05-16 01:56:17 -07:00
source ~/.cache/starship/init.nu
source ~/.zoxide.nu