12 ms·
Zoxide: A Better CD Command
- Zizizizz 1y agoOne of those fundamental work-changing tools. I use it dozens of times a day. It's fantastic
- peauc 1y agoI couldn’t live without it now. Very simple yet effective tool
- tcoff91 1y agoIt’s just so good. fzf and zoxide are probably my two most game changing cli tools. They make the terminal feel so good.
- tcoff91 1y agoI actually made a git worktree aware function called w that wraps zoxide and will basically switch to the main worktree, execute z, and then switch back to the worktree you came from. That way you don’t run into zoxide switching from one worktree to another annoyingly, and new worktrees immediately inherit your zoxide scores. You purge all other worktrees from the zoxide database and use w instead of z inside git repos. I haven’t used it in a while though because I switched from git to jj.
- 0x008 1y agocare to share?
- tcoff91 1y ago#!ruby if ARGV.size < 1 puts "Usage: wz path" exit end # Get current working directory current_dir = "#{Dir.pwd}/" # puts "Current directory: #{current_dir}" # Run git worktree list and capture the output worktree_output = `git worktree list` # Split output into lines and process worktrees = worktree_output.split("\n") # Extract all worktree paths worktree_paths = worktrees.map { |wt| "#{wt.split.first}/" } # puts "Worktree paths: #{worktree_paths}" # First path is always the root worktree root_wt_path = worktree_paths[0] # Find current worktree by comparing with pwd current_wt_path = worktree_paths.find do |path| # puts "Path: #{path}" current_dir.start_with?(path) end if current_wt_path == root_wt_path zoxide_destination = `zoxide query --exclude "#{Dir.pwd}" "#{ARGV[0]}"`.strip puts zoxide_destination exit 0 end current_dir_in_root_wt = current_dir.sub(current_wt_path, root_wt_path) Dir.chdir(current_dir_in_root_wt) current_dir = "#{Dir.pwd}/" # puts "Current directory: #{current_dir}" # puts "Querying zoxide for #{ARGV[0]}" zoxide_destination = `zoxide query --exclude "#{Dir.pwd}" "#{ARGV[0]}"`.strip # puts "zoxide destination: #{zoxide_destination}" Dir.chdir(zoxide_destination) current_dir = "#{Dir.pwd}/" if current_dir.start_with?(root_wt_path) target_dir = current_dir.sub(root_wt_path, current_wt_path) puts target_dir exit 0 end puts Dir.pwd exit 0 Then put this function in your .zshrc: # Worktree aware form of zoxide's z command. function w() { cd $(wz $@) }
- mythz 1y agozoxide alongside fzf, eza, bat and starship were my killer CLI productivity tools I discovered after ditching Windows for Fedora. I have it aliased to `cd` so I don't really notice when I'm using it until moving to a Terminal that doesn't have it.
- mubu 1y agoHow is this any different from z?
- dag11 1y agoThis is z, no?
- sevg 1y agoThere is a different project called z: https://github.com/rupa/z https://github.com/rupa/z I’d never heard of it but it was the first search result for “z github”.
- eddyg 1y agoOr the pure zsh version, which is superior, since it eliminates a ton of forking by eliminating calls to external tools (the original z script relies heavily on awk, sort, date, sed, mv, rm, and chown). There are also significant stability improvements to the database thanks to proper locking. https://github.com/agkozak/zsh-z https://github.com/agkozak/zsh-z
- derintegrative 1y agoFailed twenty ways to Sunday if I set `ZSHZ_DATA="$HOME/.local/share/zsh-z"` . Could not get it to recover from it.
- stranges 1y agoThe main difference is speed (Rust vs shell script)
- UK-AL 1y agoZoxide normally aliases to z. Is this not z?
- OJFord 1y agoNot having heard of either of these before, but now seeing z linked by sibling comment too, I would guess 'z oxide' is a Rust re-implementation of z.
- Latty 1y agoI tried zoxide for a while but I really disliked how it made things fuzzy, and most of the use cases for it I found were 90% solved by using ZSH's history search which I use routinely anyway. It gives you this potentially constantly shifting set of shortcuts, essentially, and the problem is that means I have to constantly check I did get the result I wanted, and that I haven't accidentally gone to the wrong place. I found that more annoying to me than just using tab completions or history, which are much more predictable. I can see how someone who has different workflows or environments might find it great though.
- mrcarrot 1y agoYeah, I've been trying it recently and I'm not entirely convinced I want to keep using it. My biggest annoyance at the moment (and this may be me missing something), is that I have two directories: "thing" and "thing-api". I'm doing work in "thing" much more often than in the "thing-api", but whenever I run "z thing", it takes me to "thing-api" first, and I have to "z thing" again to get to where I wanted to go. It ends up being more effort than if I'd just tab-completed or history searched a plain cd command.
- paholg 1y agozoxide stores a rank for each directory based on how often you visit it, but you can manually adjust the scores. Run `zoxide query -ls thing` to see the scores, and `zoxide add thing -s AMOUNT` to increase the score.
- yonatan8070 1y agoThat's good to know, when I needed to raise the score for a directory I just did a bunch of `cd .`
- _kb 1y agoIf xkcd took comment form, this would be it.
- 1y ago
- bjackman 1y agoDoes anyone know if zoxide has any fancy logic to ignore strings that appear in common prefixes? For example I have a big ~/src dir where I keep all my code checkouts. If I type 'z src' intending to go to ~/src/foo/bar/src, will it be clever enough to realise that I am referring to the second instance of the string 'src'? I currently use a Fish port of the original 'z'. It does ignore the common prefix of _all_ matches (so if I only ever used it within my ~/src tree, the problem would disappear) but after that binary exclusion it works exclusively on frecency.
- ShinTakuya 1y agoAs far as I'm aware it keeps a history of the frequency you visit each directory so yes it will select the one you've visited more often (assuming you don't always start at the base one and work your way down).
- bjackman 1y agoNo the issue is that the one I want _isnt_ the most recent. Because 90% of the directories I visit contain the string 'src'
- neobrain 1y agoAdding to the other answer: You can also pass multiple keywords to zoxide and they are expected to match in order. So in your example, `z foo src` would reliably cd into `~src/foo/bar/src` even if `src/foo` has a higher visit frequency.
- bjackman 1y agoOk what about when I have this ~/src/linux/linux ~/src/linux/stable And I want to go to the first one? It doesn't have a unique sequence of keywords in it :/ Unless it recognises that if I type "z lin lin" I want the one where it appears twice? I'm beginning to think my directory structure might just be toxic haha
- 1y ago
- yerlantemir 1y agosuper happy to be a super of such an amazing tool, thank you!
- CopyOnWrite 1y agoDoes anyone know, how this compares to [autojump](https://github.com/wting/autojump https://github.com/wting/autojump)? Could not imagine using regular cd for navigating file systems anymore.
- jmholla 1y agoThe creator is actually in this thread now [0] and said that they passed ownership and it now unmaintained and recommends using zoxide instead. [0]: https://news.ycombinator.com/item?id=45346715 https://news.ycombinator.com/item?id=45346715
- kritr 1y agoOne useful thing I discovered recently about zoxide is that it has a basedir flag, so in theory you scan scope your query to the directory you’re in or based off some git root. something like alias zg=‘zoxide —basedir $(git rev-parse --show-toplevel)’ https://github.com/ajeetdsouza/zoxide/pull/1027 https://github.com/ajeetdsouza/zoxide/pull/1027
- hannesfur 1y agoWow! That's really useful!
- itsmevictor 1y agoYes, thanks!
- stared 1y agoFor me, this simple tools is the single best command line changer! Instead of a lot of commands to traverse the folder tree, I jump where and when I want. Other nice tools I use: Fish for shell (https://fishshell.com/ https://fishshell.com/), Starship for prompt (https://starship.rs/ https://starship.rs/), bat "a cat with wings" for file preview (https://github.com/sharkdp/bat https://github.com/sharkdp/bat).
- hannesfur 1y agoI also like eza (https://github.com/eza-community/eza https://github.com/eza-community/eza) which is a modern ls. Fish is the biggest game changer though.
- nkydr0i0 1y agoTrue! lots of people sleeping on Fish. Probably because it's not POSIX compliant -- which is something I was hesitant about at first, too. My favorite features are: built-in vim mode, alt+s instead of sudo !!, backwards search with arrow-up, overall good default settings
- cedilla 1y agoFish was weird at first, with it's insistence on `or` instead of `||`, and `and` instead of `&&`. Since they relented on this, there's not much non-POSIX weirdness for me. From time to time I'll try to `export` something, but fish just reminds you what to do instead. 3rd party integration is excellent now, too. When I write scripts I'll just target /bin/sh, or /bin/bash if necessary. Never saw a reason to write zsh or fish scripts.
- smartmic 1y agoIs it just me, or is it actually a new trend that the first thing on the README page is an advertisement? Could this perhaps even be related to the AI glut? In any case, aberrations such as the excessive use of emojis and exaggeration are becoming increasingly common, which is yet another reason for me to distance myself from GitHub. For me, a README that more closely follows the conventions and minimalism of a classic man page is a sign of quality, and it could perhaps even be rendered in plain text to achieve a high signal-to-noise ratio.
- hannesfur 1y agoIt definitely got more widespread, but I am not sure that it's related to AI. If it's a way for open source maintainers of awesome tools I use to fund their development, I am totally fine with that.
- benrutter 1y agoWarp seems to have sponsored more or less every CLI tool these days- I don't think I've ever seen other companies advertised though somehow?
- whirlwin 1y agoDo you have any real experience with Warp? Just curious to learn
- benrutter 1y agoI've always stayed clear of it because I don't like the idea of merging shell langauges with terminal interfaces, and also I'm not really a big fan of tools that inject AI into my workflow when I don't want them too. So I don't really have a take on it at all. My whole experience of it is just seeing it's advertisements on every CLI tool page. Someone else here probably has something more meaningful to say about it though.
- OJFord 1y agoIt's older than AI, I think people do it because it seems to work - where 'work' means builds hype and 'community' and GitHub stars fast.
- mkw2000 1y agoI wouldnt say I cant live without it , but it saves me a few seconds here and there and its a great tool!
- brontosaurusrex 1y agoI've been using autojump, called with 'j'. Any pros of zoxide over that? https://packages.debian.org/sid/autojump https://packages.debian.org/sid/autojump
- neobrain 1y agoI don't use autojump, but glancing over its readme it's missing nushell integration that zoxide provides. It being a native binary instead of Python-based might also help it execute more instantaneously. Most Python-based CLI helpers that I tried add a slight but noticeable delay to simple commands, whereas zoxide is so quick it's easy to forget you even invoked a helper in the first place.
- jgb1984 1y agoI was using autojump for years (on debian) until I lost my jump history several times in the past few months. Turns out it's a known race condition bug fixed in a newer version: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1110899 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1110899 Migrated to zoxide instead, seems to work fine! Only need to get used to using z instead of j, muscle memory hard to adjust, might set an alias :)
- joelthelion 1y agoInitial creator of autojump here: just use zoxide. I passed autojump mainternship to someone else a few years ago but it has now been abandoned. Rust is superior to python for this application anyway.
- otikik 1y agoHey, thanks for creating it! I still use it and as a light user it fits my purpose just fine
- nusaru 1y agoSwitched. For anyone else thinking of doing the same, zoxide can import your data from autojump: https://github.com/ajeetdsouza/zoxide#installation https://github.com/ajeetdsouza/zoxide#installation Here's the command I ran on macOS: zoxide import --from=autojump ~/Library/autojump/autojump.txt
- desireco42 1y agoI think this is awesome tool, but somehow using fish shell does most of what I need and rarely I reach for it. This is not a critique of Zoxide, but just the fact that this is not as big of a problem once it was.
- carlosneves 1y agoI was going to say that. Gratitude to the creators of fish shell. The history-based rank is immediate as you type. Lately I've simply done: abbr --add c cd And then the "most used paths" are just present in the history filtered by the prefix I already typed.
- maherbeg 1y agohuh, I don't seem to have this enabled at all. My cd in fish only shows the current directory choices
- rukenshia 1y agoI tried zoxide, but at the end settled for using fzf to quickly find and enter directories: qcd () { local d dirs=$(fd -t d -t l --ignore-file ~/.gitignore . $@) d="$(echo ${dirs} | fzf +m --height=50%)" && cd "${d}" } alias hd="qcd ${HOME}"
- Zizizizz 1y agoThere's a built-in shortcut with fzf to change directories I think it's alt+d
- a3w 1y agoI barely use pushd/popd, for me this would be overkill, and I dislike the side effects. I mostly use my history, so same command needs to reliably do same thing. Workaround for cd-ing: cd ~/foo; $COMMAND ; #optional cd ~ here My history is full of this
- Starlevel004 1y agoI tried using z for a while but I got mad every time I typoed, failed a tab-complete, and ended up in some random directory halfway across my disk instead of doing nothing.
- ivanstame 1y agoRust people trying to replace stuff that already works...
- k__ 1y agoSeems like a bit fancier "cd -" to me.
- donatj 1y agoThis has me lamenting just how fiddly it really is to implement a standalone "cd" that isn't a builtin. I am certainly there are a whole host of security reasons not to, but it sure would be handy if a parent process could easily just read the final state of all environmental variables of a child process and possibly integrate them back into its own. Shells could just have a syntax for accepting sub process environmental variables. I'd propose something easy like starting a line with = absorbing all set environmental variables. We could build a custom cd tool, "custom-cd-bin" in this example and all that would need to do is change the PWD variable. $ =custom-cd-bin ./foo Maybe this will be something for my dream shell I'm never going to actually get around to building. It would take something gross like wrapping setenv though
- deleted 1y ago[deleted]
- ffsm8 1y agoMmh, that's kinda... Exactly what `source` is. It's just rarely used beyond dotfiles because... Well.. it inherits all variables etc https://docs.vultr.com/how-to-use-the-source-command-in-bash https://docs.vultr.com/how-to-use-the-source-command-in-bash If you want to make the transition explicit at the end of the script, you can do what the sister comment did, essentially "source <(bash the-script|grep -Pom "xx inherited variables\n(.*?)\n yy inherited variables")"
- donatj 1y agoNot at all. The source command is basically just an include, executing shell commands in the current scope. I'm talking about inheriting the environmental state of any subprocess. You can't source a binary.
- ffsm8 1y agoCan you tell me an example where this has a difference in behaviour? Basically somewhere that source would not behave as you wanted? I'm also uncertain what you mean wrt a binary. A binary will only have the environment variables available to the shell it's executed in - or do you mean that you'd also want it to inherit variables the binary itself might read from disk via .env files or similar?
- ulfbert_inc 1y agoPlease replace CD with cd in the title, it's misleading.
- ryzvonusef 1y agothere are CLI tools that are combining most of these package in one go, like Yazi, that are gaining popularity in the TUI community.
- serial_dev 1y agoInteresting to read the different threads, it sounds like most of the shortcomings of this tool can be somehow "configured away", but at that point, just configure your terminal by adding suggestions, plugins, etc, then you'll have all what you need for every command, not just CD.
- dayvster 1y agoZoxide is a bit more than just that, it creates and index as you are using it, the more you CD into dirs the higher priority they will be.
- dayvster 1y agoZoxide is amazing and I can't live without it since I switched to it.
- kh_hk 1y agoCtrl+r in zsh already gives you fuzzy search. In the rare case I have to go to a long path that I can't remember I use that, but for most cases, cd <tab> [...] <tab> <enter> suffices if I am feeling really lazy
- RianAtheer 1y ago[dead]
- lproven 1y agoIs it just me or does this description sound like an improved hammer? I mean, it's a hammer. It's fine. You can hit things. And pull out nails. This thing runs on batteries and needs syncing and it's a hammer. It didn't need improving. It's an improvement on a rock, and it's all improved out.
- akdor1154 1y agoWhat i really want is a `mkdir --cd` - annoying to code without shadowing real mkdir though.
- ramon156 1y agoit's weird how most IDE's already figured out people want this. I can type in "New File" > "/foo/bar/baz" and it will work just fine. Is there any limitation as to why mkdir can't support recursive generation?
- dannyfritz07 1y agomkdir -p https://www.man7.org/linux/man-pages/man1/mkdir.1.html https://www.man7.org/linux/man-pages/man1/mkdir.1.html
- johnisgood 1y agoI'm surprised people do not know about this. Maybe that is why they love these CLI tools written by Rust. ;) Learn your basic UNIX/POSIX utilities first, please, before you start preaching because of Rust. :D
- metaltyphoon 1y ago> Learn your basic UNIX/POSIX utilities first, please, before you start preaching because of Rust. :D Maybe, jus maybe the defaults for UNIX/POSIX was just not good and thats why they Rust based one?
- johnisgood 1y agoMaybe, just maybe I could fork "mkdir" just for you and make "-p" the default, in C? Or maybe, just maybe you could make an alias for it, i.e. "alias mkdir="mkdir -p" so then it becomes the default? sighs.
- 1y ago
- tpoacher 1y agoThis is nice, but ... I wish the doc didn't introduce it as "a better cd command", that's very misleading. With the exception of the fuzzy part, which can be added separately, Bash already has facilities for all of those functionalities. The "remembering" part can be done via dirs/pushd/popd. The "using the basename only" part can be done via CDPATH. The "automated" remembering could be done via a super simple function wrapper over 'cd', adding things onto the the dirstack or the CDPATH respectively (and with a selection menu, possibly fuzzy, when clashes occur) Putting it all together to achieve the same effect feels like a very simple 10-liner bash function at best. Not dissing the author's work or idea, nor is there anything wrong with reinventing the wheel in another language for fun; but if you're going to claim that "z is a better cd" because it bundles all that other functionality for things that are unrelated to cd, and for which there are already pretty decent unix-philosophy-adhereing commands that you could be using effectively already, then if you fail to mention these things in your documentation, it feels a bit ignorant / disingenuous. I would have preferred examples with "without z you'd have to use CDPATH for this, and dirstack for that, and maybe this 5-line wrapper for the menu thing, etc". Otherwise it feels a bit like saying "grep is a better ed" or something.
- robenkleene 1y agoI think you're misunderstanding the authors intention. Fuzzy finding is the banner feature of zoxide, i.e., it's only a better cd because it includes that feature. Everything else is just the necessary table stakes features in order to make zoxide a viable cd alternative. E.g., it's not notable that zoxide copies the rest of the useful features from cd in Bash, because that's exactly what it would need to do in order to be a cd replacement. What you could argue with is whether there's a point to replacing the cd built-in in order to include fizzy finding (personally I don't see the point of this either). But the reason all the other cd features are included is in order to make that viable.
- ktosobcy 1y agoI tried some alternatives and while some works (bat, rg, fd) others don't (fzf and said `zoxide`)... most of the time they usually get in the way more…
- thibran 1y agozoxoide, rg, fd, jj and Nushell are my command line favorites.
- esafak 1y agonushell supports going up arbitrary number of levels like so: cd ..../foo, and that's the only feature I've ever missed in cd, so I'm all set.
- transitivebs 1y agolove zoxide; been using it for a long while as a replacement for built-in `cd`
- elcapitan 1y agocd alternatives always give me PTSD from one of my earliest computer memories, aged 13 or so. That was on DOS 3.3 on my parents 286, and I had recently installed some Norton utilities, among them ncd (Norton Change Directory), which kept its own database of directories and allowed for fuzzy cd with regex. It was quite cool to see the power of such a tool, until the day I wanted to ncd into a directory with some code experiments I had built and just delete them all. Unfortunately the completion sent me into another directory, which I noticed after deleting all my parents tax documents. DOS 3.3 didn't have an undelete command like later versions of DOS, so a colleague of my dad had to spend an evening trying to restore some of that data with some external tools. On the positive side, he also installed DOS 6.22 (we were really behind).
- achristmascarl 1y agoI used zoxide for a while before realizing that the `zi` command allows you to search for your desired destination before changing directories. I use it instead of the default `z` command the vast majority of the time now.
- xwowsersx 1y agoI had no idea about this. Super helpful. Thank you!
- GNOMES 1y agoI have been testing this as a daily driver since the last big mention on HN to simplify my .bashrc file. I use it with `eval "$(zoxide init bash --cmd cd)"` so I can continue to use CD due to muscle memory. - I like that if there are multiple /foo directories known by Zoxide, say /foo/ and /abc/foo/, that you can do `cd abc foo` to go the path containing both. - I am not a fan of having to do `cd foo**` for tab completion to folders outside CWD. I feel it slows me down as a tab complete fanatic. - Also don't enjoy if I `cd foo/bar/batz` directly, then try `cd bar`, Zoxide has no reference. You would need to CD into each directory individually to build the database. I have seen scripts kicking around online to put a complete directory structure into Zoxide database by CD'ing to each subdirectory for you. Not sure if I am officially sold, or I'll go back to aliases and simple tab completes forwards, and backwards (logic I use for tab complete backwards to exact directory name backwards from CWD instead of `cd ../../../etc` https://gist.github.com/GNOMES/6bf65926648e260d8023aebb9ede9573?permalink_comment_id=5372297#gistcomment-5372297 https://gist.github.com/GNOMES/6bf65926648e260d8023aebb9ede9...)
- tqwhite 1y agoI installed it as cd. I do not think I ever, even a single time, used it differently from normal cd. It turns out that my system is organized so that I know where everything is. On the rare occasion something is lost, it's a file, not a directory. Then I Spotlight (Mac super find) because it also searches content
- stavros 1y agoEh, all my stuff is, say, in Code/Projects/Django/deadmansswitch, but it's great to be able to do `z dead` instead of typing the whole thing out.
- amelius 1y agoI have a lot of paths that end with ".../src" Looks like the tool doesn't handle that case very well.
- jbrnh 1y agoI would say it might, with the 'zi' variant (cd with interactive selection (using fzf)).
- amelius 1y agoIf I have 100 paths that end in ".../src", then interactive selection will, I suppose, make me go through that long list.
- fwip 1y agoYou can type any part of the path, not just the final part - so, from `/path/to/projects/go/github.com/me/my-cool-app/src`, you could type `cool-app/src` or `proj me cool src` or `cool s`. Interactive selection is useful partly because you can search iteratively, for less-frequently accessed locations. E.g: I might type `go fwip` because I'm looking for my go projects, and then once I see it in the list and actually remember it's called "my-radical-app", I add `rad` (or use the arrow keys to select) and hit enter.
- amelius 1y agoOk. That's good to know. I currently use an alias per folder. So I would type "cool-app", and it would go to the desired folder. But, and here comes the point, the alias also runs "source sourceme" to put all the environment variables in place, start virtual environments, etc.
- fwip 1y agoThat sounds like you've already got it pretty well figured out, then. :) If you did want to get fuzzy-matching in your workflow, I might recommend using building a small alias/function with fzf[1], rather than using zoxide. Something like `dst=$(cat ~/myprojectlist.txt | fzf) && cd $dst && source sourceme`. You wouldn't get the list sorted by most-frequent/recent like you do with zoxide, but it sounds like that's not what you're looking for anyways. [1] https://github.com/junegunn/fzf https://github.com/junegunn/fzf
- jmarchello 1y agoI love shell tools, and by no means disparage the use of zoxide, z, etc. But I find I get 90% of the usefulness of these tools using the native cd command and adding my most used directories to CDPATH. This additionally is consistent and works without needing to “train” it first.
- stavros 1y agoI agree, but I get 100% of the usefulness of these tools by installing them with one command and using them. Why settle for 90% when 100% takes a second?
- jmarchello 1y agoFair point. I don't disagree. I personally just like to stay as close to default GNU/Linux tooling as is practical. It's a matter of personal taste. For me, this makes it so my expectations and muscle memory transfer cleanly between my workstation and other servers, devices, etc. I find the default tools are much more powerful than is often understood, and you can replicate most third party functionality fairly easily. That's not always the case mind you, and I happily use those tools.
- stavros 1y agoI used to agree, but nowadays my thinking is "I use my own machines 99.99% of the time, why optimize for the 0.01%?".
- rollcat 1y agoIf you want a simpler and less invasive "improved cd", you can do this in ZSH: chpwd() { ls } It does what it says: after changing the cwd, list its contents. You can try other things, e.g. "[ -d .git ] && git status".
- larusso 1y agoI can’t see myself using this. I have a mental map of my folder structure and am actually proud that I can navigate and type the structure fast enough to move around. I feel that remembering which directory was last and adding some matching overhead is too much for my use case. I also use the zfs history heavily with fzf. And similar to another comment I usually work from same paths, be it a project root or my home directory. In any case I think it’s still valuable to break with the norm and explore other ways of using the shell. This time around it ain’t for me though.
- tehryanx 1y agothis feels like a hundred accidents waiting to happen.
- BeetleB 1y agoI see several comments saying they use fzf instead of zoxide. You should use both in tandem! Several years ago, I set up a keybinding that presents me all the directories stored in the zoxide[1] DB in fzf - in rank order. With just a few keystrokes, I get where I need to be, and I'm not presented with all possible directories - just ones I've visited in the past. This solves the problem of "I want to go to a directory that's not the most ranked one for the string I typed, and zoxide keeps putting me in the other one". Once you have this flow, there's no going back! [1] Actually, I use autojump, but it should work with zoxide as well.
- konfekt 1y agoThe classic z [0] is a shell script and thus doesn't require any installation other than loading this script in your shell's rc file. I found Navita [1] an improvement over it that works more reliably on different shells such as Bash and ZSH, though. 0: https://github.com/rupa/z https://github.com/rupa/z 1: https://github.com/CodesOfRishi/navita/ https://github.com/CodesOfRishi/navita/
- Svoka 1y agoHonestly, love seeing some cool Rust written memory safe CLIs at HN at the same time as blog post of zig fanboys who couldn't. Way to go.
- jlnthws 1y agoThose kind of tools should have the same name as the command they replace, I don’t want to change my workflow with this or that. I think a simple wrapper over cd with fzf is good enough and much simpler. Claude can probably write it in a few minutes.
- squigz 1y agoOr you could use shell aliases.
- tristan957 1y agoThat's what an alias is for. I don't want that behavior, but you are free to do it for yourself.
- jlnthws 1y agoOf course you can alias, but I was not very clear indeed. My point is that these tools ship multiple commands (z, zi, etc. autojump does too). I treat core shell commands as interfaces: keep the name, swap the implementation. If there's just one command, you can of course alias it (but why should I do this final step); if there are many, it turns into clutter. These tools should enhance existing commands instead of reinventing them: the goal is the same result, just faster and better. The philosophy is non-intrusive augmentation, like bash_completion or fzf.
- pmkary 1y agoTo know haw bad CD, is to realize it's the second time in half of a year that Zoxide is featured in the main page.
- samtrack2019 1y agoI would use https://github.com/agkozak/zsh-z https://github.com/agkozak/zsh-z if you are on zsh if i was you, much faster than alternatives
- cb321 1y agoOnce you have a little frecency command-line utility like https://github.com/c-blake/adix/blob/master/util/lfreq.nim https://github.com/c-blake/adix/blob/master/util/lfreq.nim (inspired by this very HN thread!) and then either fzf, vip (https://github.com/c-blake/bu/blob/main/doc/vip.md https://github.com/c-blake/bu/blob/main/doc/vip.md), or whatever, the essence of the idea is really just two lines of Zsh code (https://github.com/c-blake/bu/blob/main/doc/vip.md#combining-with-adixutillfreq-for-frecent-dir-navigation https://github.com/c-blake/bu/blob/main/doc/vip.md#combining...). It's only a couple dozen more to have a more robust/complete system, though with shared-across-shells PWD histories and long-term saving somewhere with lock files. As another example of why a simple CL utility for frecency alone is nice, you can basically replicate https://github.com/kantord/frecenfile https://github.com/kantord/frecenfile with a shell 1-liner: git log --pretty=format: --name-only | tac | sed '/^$/d' | lfreq -n9 -o.999 In a little timing test I did this morning, that was about 270X faster than the git log itself on the Linux kernel (61 seconds to git log, but only 227 ms to `lfreq` it). Besides all that, there's also the distributed-with-Zsh `cdr` (`man zshcontrib` or similar to read all about that).