Home

dotnix @3b84780938f9249bcbfead57ccabae73685ce246 - refs - log -
-
https://git.jolheiser.com/dotnix.git
My nix dotfiles
dotnix / apps / nogui / nushell / jolheiser.nu
- raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
## 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 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}\)"
}

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
  echo 'nixpkgs.lib.fileContents ./go.mod.sri'
}

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)"
}

# 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
}

## Other ##
$env.EDITOR = 'hx'
$env.SSH_AUTH_SOCK = '/run/user/1000/ssh-agent'
source ~/.config/nushell/ohmyposh.nu
source ~/.config/nushell/ssh.nu
source ~/.config/nushell/miniserve.nu
source ~/.config/nushell/clone.nu