Skip to content

Instantly share code, notes, and snippets.

@emanuelduss
Created May 18, 2020 20:56
Show Gist options
  • Save emanuelduss/b731828a0b4370f1d48265324a9570f9 to your computer and use it in GitHub Desktop.
Save emanuelduss/b731828a0b4370f1d48265324a9570f9 to your computer and use it in GitHub Desktop.
Shell function that can be used to jump up in the directory structure to the last directory containing the provided string
cdf(){
local path="$(pwd | rev | cut -d/ -f2- | rev | grep -o -E ".*$1[^/]*")"
echo cd -- "$path"
cd -- "$path"
}
@hoorace
Copy link

hoorace commented May 19, 2020

local variable 'path' can named 'last_path'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment