2023-06-28 20:48:01 +00:00
|
|
|
## Aliases ##
|
|
|
|
alias cat = bat
|
|
|
|
alias find = fd
|
|
|
|
alias df = duf
|
|
|
|
alias du = dust -b -d 1
|
|
|
|
alias just = just --shell "nu" --shell-arg "-c"
|
|
|
|
alias ll = ls -al
|
|
|
|
|
|
|
|
## Functions ##
|
|
|
|
def sshdev [port: int = 8080] {
|
|
|
|
$"Listening on localhost:($port)"
|
|
|
|
^ssh -i ~/.ssh/dev -N -T -R $"1337:localhost:($port)" dev@jolheiser.com
|
|
|
|
}
|
|
|
|
|
2023-07-22 21:00:53 +00:00
|
|
|
def nixdev [
|
2023-07-22 21:56:55 +00:00
|
|
|
name: string # Name of the dev shell to use
|
2024-02-04 01:47:22 +00:00
|
|
|
--bash # Use bash instead of nushell
|
|
|
|
--refresh # Refresh the flake
|
2023-07-22 21:00:53 +00:00
|
|
|
] {
|
|
|
|
let url = $"git+https://git.jojodev.com/jolheiser/dev-shells\#($name)"
|
2023-07-22 21:56:55 +00:00
|
|
|
let c = if ($bash) {""} else {"-c nu"}
|
|
|
|
let refresh = if ($refresh) {"--refresh"} else {""}
|
|
|
|
let cmd = $"nix develop ($refresh) ($url) ($c)"
|
|
|
|
^nu -c $cmd
|
2023-07-22 16:47:20 +00:00
|
|
|
}
|
|
|
|
|
2023-11-24 23:25:51 +00:00
|
|
|
def "forge types" [] {
|
|
|
|
["github", "gitea", "jojodev", "codeberg"]
|
|
|
|
}
|
|
|
|
|
|
|
|
def clone [
|
|
|
|
repo: string # Repo name
|
|
|
|
--forge (-f) = "github": string@"forge types" # Forge type (github, gitea, jojodev, codeberg)
|
|
|
|
--owner (-o): string # Owner (default: current dir name)
|
|
|
|
] {
|
|
|
|
mut id = 'gh'
|
|
|
|
if $forge == 'gitea' {
|
|
|
|
$id = 'gt'
|
|
|
|
} else if $forge == 'jojodev' {
|
|
|
|
$id = 'jj'
|
|
|
|
} else if $forge == 'codeberg' {
|
|
|
|
$id = 'cb'
|
|
|
|
}
|
2023-12-29 16:55:09 +00:00
|
|
|
mut namespace = ($env.PWD | path basename)
|
|
|
|
if $owner != '' {
|
|
|
|
$namespace = $owner
|
|
|
|
}
|
2023-11-24 23:25:51 +00:00
|
|
|
let origin = $'ssh:($id):jolheiser/($repo).git'
|
2023-12-29 16:55:09 +00:00
|
|
|
let upstream = $'($id):($namespace)/($repo).git'
|
2023-11-24 23:25:51 +00:00
|
|
|
^git clone $origin
|
|
|
|
cd $repo
|
2023-12-29 16:55:09 +00:00
|
|
|
if $namespace != 'jolheiser' {
|
|
|
|
^git remote add upstream $upstream
|
|
|
|
^git fetch upstream
|
|
|
|
}
|
2023-11-24 23:25:51 +00:00
|
|
|
}
|
|
|
|
|
2023-11-30 17:26:03 +00:00
|
|
|
def fg [args ...string] {
|
|
|
|
^rg --ignore-case --color=always --line-number --no-heading $args
|
|
|
|
| ^fzf --ansi --color 'hl:-1:underline,hl+:-1:underline:reverse' --delimiter ':' --preview "bat --color=always {1} --theme='ctp-mocha' --highlight-line {2}" --preview-window 'up,60%,border-bottom,+{2}+3/3,~3' --bind $"enter:become\(($env.EDITOR) +{2} {1}\)"
|
|
|
|
}
|
|
|
|
|
2024-03-08 05:07:41 +00:00
|
|
|
def gomodsri [] {
|
|
|
|
let tmp = (mktemp -d)
|
|
|
|
go mod vendor -o $tmp
|
|
|
|
let sri = (go run tailscale.com/cmd/nardump@latest --sri $tmp)
|
|
|
|
$sri | save -f go.mod.sri
|
|
|
|
rm -rf $tmp
|
2024-03-10 02:31:53 +00:00
|
|
|
echo 'nixpkgs.lib.fileContents ./go.mod.sri'
|
2024-03-08 05:07:41 +00:00
|
|
|
}
|
|
|
|
|
2024-08-08 00:19:51 +00:00
|
|
|
def q [
|
|
|
|
--debug # Debug mode, only echo query
|
|
|
|
...args: string
|
|
|
|
] {
|
|
|
|
let input = $in
|
|
|
|
mut query = $args | str join ' '
|
|
|
|
if ($input | is-not-empty) {
|
|
|
|
$query = $"($query)\n\n($input)"
|
|
|
|
}
|
|
|
|
if ($debug) {
|
|
|
|
print $query
|
|
|
|
return
|
|
|
|
}
|
|
|
|
^llm -s "Answer in as few words as possible. Use a brief style with short replies." -m claude-3.5-sonnet $"($query)"
|
|
|
|
}
|
|
|
|
|
2024-03-20 17:57:56 +00:00
|
|
|
# Run a command if known, otherwise run it with nix
|
|
|
|
def , [
|
|
|
|
cmd: string # The command to run
|
|
|
|
...args: string # Command arguments; all flags MUST be quoted
|
|
|
|
] {
|
|
|
|
if (not (which $cmd | is-empty)) {
|
|
|
|
^$cmd ...$args
|
|
|
|
return
|
|
|
|
}
|
|
|
|
^nix run $"nixpkgs#($cmd)" -- ...$args
|
|
|
|
}
|
|
|
|
|
2023-06-28 20:48:01 +00:00
|
|
|
## Other ##
|
2024-10-18 00:57:02 +00:00
|
|
|
$env.EDITOR = 'hx'
|
2024-08-29 03:05:21 +00:00
|
|
|
$env.SSH_AUTH_SOCK = '/run/user/1000/ssh-agent'
|
2024-08-29 03:23:15 +00:00
|
|
|
source ~/.config/nushell/ohmyposh.nu
|
|
|
|
source ~/.config/nushell/ssh.nu
|
2024-12-12 19:38:55 +00:00
|
|
|
source ~/.config/nushell/miniserve.nu
|