nushell/zoxide.nu 1.9 K raw
1
# Code generated by zoxide. DO NOT EDIT.
2
3
# =============================================================================
4
#
5
# Hook configuration for zoxide.
6
#
7
8
# Initialize hook to add new entries to the database.
9
export-env {
10
  $env.config = (
11
    $env.config?
12
    | default {}
13
    | upsert hooks { default {} }
14
    | upsert hooks.env_change { default {} }
15
    | upsert hooks.env_change.PWD { default [] }
16
  )
17
  let __zoxide_hooked = (
18
    $env.config.hooks.env_change.PWD | any { try { get __zoxide_hook } catch { false } }
19
  )
20
  if not $__zoxide_hooked {
21
    $env.config.hooks.env_change.PWD = ($env.config.hooks.env_change.PWD | append {
22
      __zoxide_hook: true,
23
      code: {|_, dir| ^zoxide add -- $dir}
24
    })
25
  }
26
}
27
28
# =============================================================================
29
#
30
# When using zoxide with --no-cmd, alias these internal functions as desired.
31
#
32
33
# Jump to a directory using only keywords.
34
def --env --wrapped __zoxide_z [...rest: string] {
35
  let path = match $rest {
36
    [] => {'~'},
37
    [ '-' ] => {'-'},
38
    [ $arg ] if ($arg | path expand | path type) == 'dir' => {$arg}
39
    _ => {
40
      ^zoxide query --exclude $env.PWD -- ...$rest | str trim -r -c "\n"
41
    }
42
  }
43
  cd $path
44
}
45
46
# Jump to a directory using interactive search.
47
def --env --wrapped __zoxide_zi [...rest:string] {
48
  cd $'(^zoxide query --interactive -- ...$rest | str trim -r -c "\n")'
49
}
50
51
# =============================================================================
52
#
53
# Commands for zoxide. Disable these using --no-cmd.
54
#
55
56
alias z = __zoxide_z
57
alias zi = __zoxide_zi
58
59
# =============================================================================
60
#
61
# Add this to your env file (find it by running `$nu.env-path` in Nushell):
62
#
63
#   zoxide init nushell | save -f ~/.zoxide.nu
64
#
65
# Now, add this to the end of your config file (find it by running
66
# `$nu.config-path` in Nushell):
67
#
68
#   source ~/.zoxide.nu
69
#
70
# Note: zoxide only supports Nushell v0.89.0+.