Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: z path/to/file cds into path/to #922

Closed
jficz opened this issue Oct 15, 2024 · 1 comment
Closed

Feat: z path/to/file cds into path/to #922

jficz opened this issue Oct 15, 2024 · 1 comment

Comments

@jficz
Copy link

jficz commented Oct 15, 2024

I enjoyed this behavior with zsh, not exactly sure what the exact config or plugins were but when one did

cd path/to/file

the directory was changed to path/to

Useful with other autocomplete/search features where you look for a file and need to cd to the directory that contains the file fast.

@ajeetdsouza
Copy link
Owner

If you need custom functionality, you can wrap the __zoxide_z function to do what you want.

For example:

eval "$(zoxide init zsh --no-cmd)" # initialize without `z` command

function z() {
  if test -f "$1"; then
    cd "$(dirname "$1")"
  else
    __zoxide_z "$@"
  fi
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants