Giter VIP home page Giter VIP logo

zsh-zoxide's Introduction

Logo ❮ Plugin - Zsh zoxide ❯

ajeetdsouza/zoxide

The plugin calls zoxide init for Zsh.

zoxide is a smarter cd command, inspired by z and autojump.

Environment variables

Variable Description Default
_ZO_CMD_PREFIX Set variable to preferred prefix Zi: x, other: z
_ZO_DATA_DIR Directory in which the database is stored Zi: $ZPFX/share, other: none

All environment variables: ajeetdsouza/zoxide#environment-variables

Eval-cache options

Before setting the environment variables, you must declare the associative array:

typeset -A ZEC

Set the following environment variables to change the default behavior:

Variable Description Default
ZEC[DISABLED] Disable eval-caching 0
ZEC[DEBUG] Enable debug mode for eval-caching 0
ZEC[MAX] Maximum number to load from cache (until force refresh) 1000

Eval-cache files are stored in ${Plugins[ZSH_ZOXIDE]}/._zoxide/* directory.

Install zoxide

zi ice as'null' from"gh-r" sbin
zi light ajeetdsouza/zoxide

Wiki: install fzf command-line fuzzy finder as Zi package.

Install zsh-zoxide

Note:

  • the alternative for zsh-zoxide is 🌀 eval annex.
  • To forcefully set z function include atinit'z(){ __zoxide_z "$@"; }' when installing with Zi (#37).
zi ice has'zoxide'
zi light z-shell/zsh-zoxide
zi has'zoxide' light-mode for \
  z-shell/zsh-zoxide

Turbo mode + "For" syntax

zi has'zoxide' wait lucid for \
  z-shell/zsh-zoxide

Wiki: automatic, condition based (loading/unloading)

After loading the plugin – shows profiling results and then unloads zsh/zprof

zi ice has'zoxide' atinit'zmodload zsh/zprof' \
  atload'zprof | head -n 20; zmodload -u zsh/zprof'
zi light z-shell/zsh-zoxide

Environment variables and usage with Zi

The plugin will call zoxide init with prefixed commands x, xi:

x foo              # cd into highest ranked directory matching foo
x foo bar          # cd into highest ranked directory matching foo and bar
x foo /            # cd into a subdirectory starting with foo
x ~/foo            # x also works like a regular cd command
x foo/             # cd into relative path
x ..               # cd one level up
x -                # cd into the previous directory
xi foo             # cd with interactive selection (using fzf)
x foo<SPACE><TAB>  # show interactive completions

Environment variables and usage with other plugin managers

The plugin will call zoxide init with prefixed commands z, and zi.

zsh-zoxide's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

zsh-zoxide's Issues

[dev]: improve/review codebase

Your feedback for the existing codebase

Tasks:

  • line 74: scalar parameter __zoxide_result created globally in function @zsh-eval-cache

Self-service

  • I'd be willing to address this documentation request myself.

Have you read the Contributing Guidelines?

Are you familiar with the Contributor Covenant Code of Conduct?

Contact Details

No response

[bug]: `__zoxide_cd:cd:2: no such file or directory: foo`

Environment

Device: apple | darwin22.0 | arm64 | Shell: /bin/zsh | -zsh | zsh-5.8.1-0-g1a490c7 Zi: 75929e8f4425761a64591d0f6c23dbb0c64261fc | zoxide v0.9.0

Reproduction steps

  1. Load z-shell/zoxide:
    zi has'zoxide' wait lucid for atload="function z() { __zoxide_z \"\$@\" }" \
    z-shell/zsh-zoxide
  1. Attempt to use x or z (in this case). For every directory, __zoxide_cd:cd:2: no such file or directory: <directory> is returned.

Expected behavior

x or z<SPACE><DIRECTORY> correctly hooks into zoxide.

Current behavior

For every directory, __zoxide_cd:cd:2: no such file or directory: <directory> is returned.

Code snippet

zi has'zoxide' wait lucid for atload="function z() { __zoxide_z \"\$@\" }" \
  z-shell/zsh-zoxide

Additional information

Using zsh-zoxide in isolation (no other plugins) results in the same behaviour.

It seems like zi is resetting $chpwd_functions because if I echo that once the shell is loaded, only @zi-scheduler is listed there.

if [[ ${precmd_functions[(Ie)__zoxide_hook]:-} -eq 0 ]] && [[ ${chpwd_functions[(Ie)__zoxide_hook]:-} -eq 0 ]]; then
    chpwd_functions+=(__zoxide_hook)
fi

...yet:

❯ echo $chpwd_functions
@zi-scheduler

Self-service

  • I'd be willing to address this documentation request myself.

Have you read the Contributing Guidelines?

Are you familiar with the Contributor Covenant Code of Conduct?

Contact Details

No response

[bug]: __zoxide_result created globally in function @zsh-eval-cache prints every time zsh starts

Environment

Device:pc | linux-gnu | x86_64

Reproduction steps

1. install zsh-zoxide
2. open a new terminal
...

Expected behavior

1. it wont print /home/abs3nt/.local/share/zinit/plugins/z-shell---zsh-zoxide/._zoxide/0f30bf3113e711a95459631c2d1acbf4.zsh:74: scalar parameter __zoxide_result created globally in function @zsh-eval-cache
2.
3.
4.
5.
...

Current behavior

1. it does print /home/abs3nt/.local/share/zinit/plugins/z-shell---zsh-zoxide/._zoxide/0f30bf3113e711a95459631c2d1acbf4.zsh:74: scalar parameter __zoxide_result created globally in function @zsh-eval-cache
2.
3.
4.
5.
...

Code snippet

zi ice has'zoxide'
zi light z-shell/zsh-zoxide

Additional information

.

Self-service

  • I'd be willing to address this documentation request myself.

Have you read the Contributing Guidelines?

Are you familiar with the Contributor Covenant Code of Conduct?

Contact Details

No response

[bug]: @zsh-eval-cache:40: bad math expression: operator expected at `2'

Environment

Device: pc | linux-gnu | x86_64

Reproduction steps

Start a new shell using .zshrc

Expected behavior

No error

Current behavior

I get the following error

@zsh-eval-cache:40: bad math expression: operator expected at `2'

Code snippet

Here a snippet of my .zshrc

# install zoxide
zi ice as'null' from"gh-r" sbin
zi load ajeetdsouza/zoxide
zi ice has'zoxide'
zi load z-shell/zsh-zoxide

The error is gone as soon as I comment out the last two lines of the snippet.

Additional information

N/A

Self-service

  • I'd be willing to address this documentation request myself.

Have you read the Contributing Guidelines?

Are you familiar with the Contributor Covenant Code of Conduct?

Contact Details

[email protected]

[bug]: Incorrect regex matching for _ZO_CMD_PREFIX when empty

Environment

Package manager: antidote

Reproduction steps

1. Set _ZO_CMD_PREFIX to an empty string

Expected behavior

Zoxide initializes properly

Current behavior

error: The following required arguments were not provided:
  <SHELL>

Usage: zoxide init --cmd <CMD> <SHELL>

For more information try '--help'

Code snippet

 if [[ $_ZO_CMD_PREFIX =~ ^[a-zA-Z]*$ ]]; then
    # Set zoxide commands x, xi when using with Zi.
    @zsh-eval-cache zoxide init --cmd $_ZO_CMD_PREFIX zsh || {
      print "Failed to initialize zoxide, exit code: $?"
      return $?
    }

The above regex check is true when ZO_CMD_PREFIX = "" (using another package manager).

I've fixed it locally by changing the regex to detect 1 or more characters instead of 0 or more:

 if [[ $_ZO_CMD_PREFIX =~ ^[a-zA-Z]+$ ]]; then
    # Set zoxide commands x, xi when using with Zi.
    @zsh-eval-cache zoxide init --cmd $_ZO_CMD_PREFIX zsh || {
      print "Failed to initialize zoxide, exit code: $?"
      return $?
    }

Additional information

Thanks for the plugin 👍

Self-service

  • I'd be willing to address this documentation request myself.

Have you read the Contributing Guidelines?

Are you familiar with the Contributor Covenant Code of Conduct?

Contact Details

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.