A similar tool that saves me immeasurable amounts of time is fasd[0]. I started using it as a part of prezto[1], which is similar to oh-my-zsh, and have never gotten around to trying any other solutions such as z.
For navigating between parallel directory structures (src/ and test/), I made an awful hack called c-, that sed subs src/ for test/ and vice versa on pwd. A fluke grade.
When actually inside vim Tim Pope's excellent vim-projectionist has a wonderfully useful feature for flipping between various related files(:h projectionist-alternate). The whole plugin is really cool, it makes it so simple to configure project specific working environments with it.
Is there some functionality that `z` offers that fzf doesn't? I have a keybinding that essentially does `open $(fd | fzf)`, and that is how I go _anywhere_ in my file system. Completely changed how I use the shell.
I personally find that fzf is better because I can see where I'm going to end up before I accept the operation.
Besides z being much faster (looking through a sorted list of directories visited instead of recursively walking from the current directory) your snippet looks from the cwd
Yep, that's fair. I use fzf along with z. I use z usually to switch projects (and I work in Go, so many are in GOPATH and annoying to CD to manually) but I use fzf both inside and outside of vim to open individual files.
Not for you, but perhaps for others who also like that behaviour.
With zsh you can enable the auto_pushd option, which makes cd manipulate the directory stack itself. You could probably simply alias cd as pushd too under zsh too, but in bash that would break cd's argument handling.
I'm mildly skeptical of any shortcuts that are based on "learning habits". I've already gotten enough of user interfaces that move items based on use all the time (The spotify playlist list is the worst offender - playlists move up and down in rank after every use, so there is never any spatial memory, startled every time).
It's very well hidden, but (at least on Android) there is an option to sort alphabetically. I was quite annoyed until I googled it and found out how to do it. I can't find it in the UI now despite having done it before... Anyway, I fully agree.
I found the per-directory "suggest-while-typing" history in Fish (and Zsh with the right extension) very intuitive. It speeds up getting around the filesystem, and to common locations tremendously, and of course also remembers regular commands. And it "just works", there is nothing to setup and no commands to remember.
tried fish for some time for the implicit completion but the otherwise excotic nature of the shell has caused me enough headaces to revert to bash and live with C-R
Tools like this always make me faintly uncomfortable. The idea is nice, but as a systems guy I would liken it to a mechanic’s toolbox that tries to predict what tool you want and puts it in your hand. Seems like it would be nice except you would need to carefully check what tool you were given to make sure the algo didn’t make a wrong decision and you’re using a wrong-sized wrench or something.
I’m not sure I want the fundamental building blocks of my field to be “helpful” like this. I’m much more a fan of naming it easier and faster for computers to do what I want, than I am of computers trying to divine what I want without my explicitly asking for it at this level.
It sounds terrific. Also make sure to check out the fish shell if you haven't before. It's tab completions/up-arrow completions including for cd are really useful in a similar way.
I’ve used fish for quite a while but after Many a scripting incompatibility I went back to ohmyzsh. Fish is great if you can port your whole ecosystem into it.
I find the persistent directory stack of ohmyzsh (easy enough to enable yourself in zsh) easier to use than things like autojump or z, and pretty much makes them unnecessary. I miss this basic functionality in fish (hoping someone will point out that I have overlooked it)
"CDPATH=<str>" without the export will work as you'd want, and won't pollute the environment for subshells and scripts. It is unlikely you really want to export anything listed in the shell variables section of the man page, but yeah everybody does :/
I develop apps on Windows, but I use Linux to do lots of my work and automate cumbersome boring tasks where I can (there are still many more to be automated....).
I'm constantly amazed at what Windows dev people can get done without a programmable command line. I've seen several thousand line long cmd/bat files to do relatively simple things. They work, which is good. They are a lot of work to maintain though.
I find z absolutely wonderful to take away that first hurdle of remembering folders. I can't imagine how Windows devs who don't know Unix can get around easily. They seem to though. Much must be memorised and some tools help. Powershell is getting better, but I think lacks (at least for the moment) the amount of existing code/books/links that shell solutions have.
I sometimes hum my version of that old Sting favourite,
Oh, I'm an alien, I'm a legal alien
I'm a Linux dev in Windows 10....
I'd be interested to hear if there are better/equivalent searching tools easily available on Windows, but z works wonderfully for me.
> I can't imagine how Windows devs who don't know Unix can get around easily. They seem to though.
It's simple, for filesystem operations most Windows people don't use CLI.
I use Total Commander for example, which has tabs and bookmarks to quickly navigate around the filesystem.
For shell scripts that are longer then a handful lines, python is the better alternative IMHO, especially if the scripts need to work across Windows, Linux and macOS.
Windows has some nice tricks to connect the UI to the cmdline. For instance you can type "cmd" or "powershell" in the breadcrumbs-bar of an Explorer window, and it opens a terminal at that filesystem location (and the other way around, "start ." on the command line opens an Explorer window in the current directory.
Historically, pure command line workflows are somewhat rare on Windows though.
Oh-my-zsh with the fzf plugin has a lot of navigation-friction removal.
cd ~/r/pr/e/de<tab>
Becomes
cd ~/repos/projectlongname/environments/development
It also has built in push/pop, with minus always returning to the previous path, various numbers of dots, up to six I believe, navigating up the tree, and cd - <tab x2> showing interactive breadcrumbs of recent paths for easy as click-and-click navigation.
Built-in zsh behaviour in fact, oh-my-zsh just enables some extremely useful non-default options.
With a compinit call the directory substring expansion will work. And, with auto_pushd enabled cd fiddles with the directory stack.
The ....... behaviour is interesting because it uses a global alias(alias -g) which is an awesome feature for text expansion anywhere in a line, unlike standard aliases which only expand where commands should be given. It means, for example, you can do `readlink -f ......` and it would perform `readlink ../../../../../..`. Aliases on zsh are very powerful indeed.
I'm writing this text in the hope it drives at least one person to burn an afternoon on the amazing(but huge) zsh documentation, because the entire thing is full of gems.
I'll add that to my Read-Only Friday. I got tossed directly into the zsh/omz/fzf pool head-first from bash, so the borders of what's what are murky. Definitely some powerful stuff, so far.
Seriously though, I think you were probably lucky to have experienced zsh that way. The out of the box experience is incredibly bare. Said as a fellow oh-my-zsh user going back the full twelve years, according to the history of oh-my-zsh's jnrowe theme ;)
I do believe there is a lot of useful knowledge to be gained from working back towards zsh first principles though, especially if -- like me -- you spend hours a day alongside the prompt.
Nice. I made a similar tool that saves and searches the history by a query string. In order to keep the history separate for each session I save it to a different file. Nothing I type is ever lost, I can always search for it.
I have been using `z` for some time, and now I can't imagine working without it.
I used to have a big list of aliases like:
alias pro='cd ~/Projects'
Seems trivial, but it was a huge time saver over time. After installing `z` and using it for a few days, I can now keep only the top 3/4 aliases and `z` does the rest.
I've been tempted to try more fancy tools like zoxide, but I love the fact that `z` is just a shell script I can easily move around.
OP here, thanks for the amazing comments. Some nice projects to look into!
As much as I love z, I'm also a fan of fzf, both are really complementary. I'm using this little piece of code (not from me, but cannot find the original source) to fallback to fuzzy search when z fails to find a result or when no args are given:
reply