2 ms·
Best I can come up with is adding the following to .bashrc: function jump() { local current_dir=$(pwd) local search_pattern="*" for arg i
by reaperman 3y ago
Best I can come up with is adding the following to .bashrc:
function jump() {
local current_dir=$(pwd)
local search_pattern="*"
for arg in "$@"; do
search_pattern+="$arg*"
done
local path_found=$(find "$current_dir" -type d -path "$search_pattern" -print -quit)
if [[ -n $path_found ]]; then
cd "$path_found" || return
else
echo "Directory not found from here."
fi
}
Then
jump foo bar {baz ...}
does what you'd like here.
e.g.
me@myhost ~ % jump CMake doc guide
will go to
/Users/me/Qt/Tools/CMake/CMake.app/Contents/doc/cmake/html/guide/