# export def --env init [] { # let zoxide_nushell_path = ($env.NU_POLYJUICE_AUTOLOAD_DIRS | path join "zoxide.nu") # if ($zoxide_nushell_path | path exists) { # rm $zoxide_nushell_path # } # zoxide init nushell --cmd z | save -f $zoxide_nushell_path # } # Code generated by zoxide. DO NOT EDIT. # ============================================================================= # # Hook configuration for zoxide. # # Initialize hook to add new entries to the database. export-env { $env.config = ( $env.config? | default {} | upsert hooks { default {} } | upsert hooks.env_change { default {} } | upsert hooks.env_change.PWD { default [] } ) let __zoxide_hooked = ( $env.config.hooks.env_change.PWD | any { try { get __zoxide_hook } catch { false } } ) if not $__zoxide_hooked { $env.config.hooks.env_change.PWD = ($env.config.hooks.env_change.PWD | append { __zoxide_hook: true, code: {|_, dir| zoxide add -- $dir} }) } } # ============================================================================= # # When using zoxide with --no-cmd, alias these internal functions as desired. # def _pj_normalize_windows_drive [path: string] { if (($nu.os-info.name | str downcase) != "windows") { return $path } let parsed = ($path | parse --regex '^(?[a-zA-Z]):(?.*)$') if ($parsed | is-empty) { return $path } let item = ($parsed | first) $"(($item.drive | str upcase)):($item.rest)" } # Jump to a directory using only keywords. def --env --wrapped __zoxide_z [...rest: string] { let path = match $rest { [] => {'~'}, [ '-' ] => {'-'}, [ $arg ] if ($arg | path expand | path type) == 'dir' => {$arg} _ => { zoxide query --exclude $env.PWD -- ...$rest | str trim -r -c "\n" } } cd (_pj_normalize_windows_drive $path) } # Jump to a directory using interactive search. def --env --wrapped __zoxide_zi [...rest:string] { let path = (zoxide query --interactive -- ...$rest | str trim -r -c "\n") cd (_pj_normalize_windows_drive $path) } # Jump to git repository root when currently inside a repository. def --env __zoxide_zg [] { if (which ^git | is-empty) { return } let top = (^git rev-parse --show-toplevel | complete) if ($top.exit_code != 0) { return } let root = ($top.stdout | str trim -r -c "\n") if ($root != "") { cd (_pj_normalize_windows_drive $root) } } # ============================================================================= # # Commands for zoxide. Disable these using --no-cmd. # export alias z = __zoxide_z export alias zi = __zoxide_zi export alias zg = __zoxide_zg # ============================================================================= # # Add this to your env file (find it by running `$nu.env-path` in Nushell): # # zoxide init nushell | save -f ~/.zoxide.nu # # Now, add this to the end of your config file (find it by running # `$nu.config-path` in Nushell): # # source ~/.zoxide.nu # # Note: zoxide only supports Nushell v0.89.0+.