by alufers · 6y ago · 0 comments
It automatically makes a list of directories you frequently use in your shell and if you type `z a-small-substring-of-the-directory-path` it does a cd to that directory. (e.g. I type `z and` and it changes my current directory to $HOME/Work/Projects/android`). Saved me tons of typing.
export CDPATH="/path/to/my/projects:$HOME/Work/Projects"
# From anywhere.
cd andr<tab><enter>And zsh users get another advantage here. You can use assign to the cdpath array or the CDPATH colon-delimited string, they are both treated the same internally. The advantage is being able to `cdpath+=...`, much like adding to $PATH with `path+=` or removing from PATH with `path^=`. Check zshbuiltins(1) for how to make your variables work like this, or how to use typeset -U to remove duplicates automatically, or $thousand_other_cool_things.
A huge block of "unalias" calls at the beginning of shell scripts used to be a common practice, but they don't seem to be found in more widely-used tools these days.
It's a bug in the script, just like reacting badly to $IFS or $LANG.
EDIT:
$ cat /usr/bin/cd
#!/usr/bin/sh
builtin cd "$@" yum install -y bash-completion
bash # a fresh runAlthough I might adopt it for different weird system configuration directories which I often forget the path to.
[edit] Or z's based ageing ranking system will just aged those legacy directories, even better (in terms of more hands off)!
For example, I integrated it into ranger (see my history, I don't want to spam HN with this project).
No argument: start fzf (this really should read "to $(fzf)"), jump to that dir.
One arg: if the path is a real file/dir, jump to it, else use zoxide (z in rust) to soft-match it from history.
https://github.com/xkortex/bashbox/blob/master/aliases/core....