Comments (6)
Here's a workaround for anyone else who is trying to get this to behave - we will override the internal zoxide function and catch the leading --
before it is passed along with another --
making an invalid set of arguments:
function __zoxide_z() {
# shellcheck disable=SC2199
if [[ $# -eq 0 ]]; then
__zoxide_cd ~
elif [[ $# -eq 1 && $1 == '-' ]]; then
__zoxide_cd "${OLDPWD}"
elif [[ $# -eq 1 && -d $1 ]]; then
__zoxide_cd "$1"
elif [[ ${@: -1} == "${__zoxide_z_prefix}"?* ]]; then
# shellcheck disable=SC2124
\builtin local result="${@: -1}"
__zoxide_cd "${result:${#__zoxide_z_prefix}}"
else
\builtin local result
# Allow for leading '--' in args from autocd etc. See issue #776
while [[ $1 == '--' ]]; do \builtin shift; done
# shellcheck disable=SC2312
result="$(\command zoxide query --exclude "$(__zoxide_pwd)" -- "$@")" &&
__zoxide_cd "${result}"
fiinit
}
This is just the normal __zoxide_z
function as generated by zoxide init
, with one line of code (and one comment) to strip the leading --
from the arguments, since one is hardcoded and more is broken. This one is for bash, so you might need to adjust it to work with your shell of choice. I'll be happy to help if you're stuck :)
I would submit this as a PR, but I'm brand new around here and have no idea if this is the 'right way' to do it for this project.... But this works just fine, for now :)
from zoxide.
they do it in a way that's not covered by zoxide.
If it isn't the prepended --
that is reported by OP and I, you might want to log a separate case, but, specify it, and I'll see what I can do :)
from zoxide.
+1. Just came here to report that zoxide isn't working with autocd.
from zoxide.
Not just the autocd but sometimes other tools change directory for you and they do it in a way that's not covered by zoxide.
A good solution is to watch when current directory PWD changes which is a hook that's provided by most shells, if not, there must be a hook that runs whenever the prompt is changed and then you can run $(pwd) to get the current dir and compare it.
from zoxide.
Same here with my md
function :(
❯ which md
md () {
[[ $# == 1 ]] && mkdir -p -- "$1" && cd -- "$1"
}
❯ md Test
zoxide: no match found
I updated it in my dotfiles to force it to use my builtin shell command instead.
❯ md () {
[[ $# == 1 ]] && mkdir -p -- "$1" && builtin cd -- "$1"
}
❯ md Test
❯ pwd
/home/waser/Test
from zoxide.
#695 almost resolves this, so maybe this issue can be closed now...
Although... Not that I care a lot, but there is a bug in that fix - it will work with the autocd
command, but if someone attempts to use cd
with the --
option, along with another argument, then it will not trigger that new rule, because there will be more than two arguments.
/home/pallaswept> cd -P -- /tmp
zoxide: no match found
/home/pallaswept> builtin cd -P -- /tmp
/tmp>
My workaround above has a similar bug.
Perhaps a more robust way to do this, is to check that the second-to-last argument is the --
string, since the last arg is the target directory, and any other options supplied would always be prior to the --
.
from zoxide.
Related Issues (20)
- .zoxide.nu method breaks with the latest 0.94.0 release HOT 3
- Nushell failure on `z` for keyword not under $env.PWD HOT 1
- Interactive completions when using powershell
- error: unrecognized subcommand 'Documents' HOT 2
- Trying to implement a go back and go forward HOT 3
- Multidot navigation
- zoxide resets every time I shut off my mac HOT 1
- Cannot run shell installer on WSL2 Ubuntu 22.04 HOT 3
- Errors when accessing network drive on windows via git bash
- [Bug Report]: No directory history in the database, check out the `zoxide` docs to set it HOT 1
- `zi` doesn't work HOT 2
- `zoxide` does not work HOT 3
- no match found HOT 3
- Easier flow for bumping path to be top result for query
- Add support for bash autocd option HOT 1
- Support regexp
- Ability to disable cd-like behavior HOT 3
- Folder Alias not properly supported on macOS
- Using --cmd cd in Fish Shell does not work HOT 4
- `zoxide edit` broken with `fzf` >=0.54 and `-1, --select-1`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zoxide.