Open nikitavoloboev opened 7 years ago
The simplest way I can think of to do something like that would be:
_cz() { cd "$@" > /dev/null 2>&1 || _z "$@" 2>&1; }
alias cz=_cz
Then you can do: cz path
if path
exists as a dir then it will go there, if not it will invoke z
-c
argument restricts matches to current dir, but IMHO the way to deal with getting unexpected result, or getting to something that isn't the top match, is to adjust the mnemonic so it matches something unique, maybe use a couple of args, eg z so files
or z pro files
For example I maybe in a folder ~/projects/something
And in there there maybe a folder files like ~/projects/something/files
If I do z files it actually goes to some other folder 'files'. I want to make it so that z will always work like 'cd' command if the path is given and the folder exists in the current place where I am.
Can I do this?