Home

dotnix @c47f62bb1e0221d5a88bcc6e27fccc4ae2790380 - 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
59
60
61
62
63
64
## 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
def day [] { date now | date format "%a %b %d" }

## Functions ##
def sshdev [port: int = 8080] {
	$"Listening on localhost:($port)"
	^ssh -i ~/.ssh/dev -N -T -R $"1337:localhost:($port)" dev@jolheiser.com
}

def nixdev [
		name: string    # Name of the dev shell to use
		--bash: bool    # Use bash instead of nushell
		--refresh: bool # Refresh the flake
	] {
	let url = $"git+https://git.jojodev.com/jolheiser/dev-shells\#($name)"
	let c = if ($bash) {""} else {"-c nu"}
	let refresh = if ($refresh) {"--refresh"} else {""}
	let cmd = $"nix develop ($refresh) ($url) ($c)"
	^nu -c $cmd
}

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)
] {
  let owner = ($env.PWD | path basename)
  mut id = 'gh'
  if $forge == 'gitea' {
    $id = 'gt'
  } else if $forge == 'jojodev' {
    $id = 'jj'
  } else if $forge == 'codeberg' {
    $id = 'cb'
  }
  let origin = $'ssh:($id):jolheiser/($repo).git'
  let upstream = $'($id):($owner)/($repo).git'
  ^git clone $origin
  cd $repo
  ^git remote add upstream $upstream
  ^git fetch upstream
}

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

## Other ##
$env.EDITOR = hx
$env.config = ($env.config | upsert "shell_integration" ("WEZTERM_PANE" not-in $env and "SSH_CLIENT" not-in $env))
source ~/.config/nushell/zoxide.nu
source ~/.config/nushell/ohmyposh.nu