Skip to content

Instantly share code, notes, and snippets.

@mbaldessari
Created May 10, 2014 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbaldessari/54a4924daae59063968b to your computer and use it in GitHub Desktop.
Save mbaldessari/54a4924daae59063968b to your computer and use it in GitHub Desktop.
Bash implementation of "cd ...."
function cd () {
local -ri n=${#*};
if [ $n -eq 0 -o -d "${!n}" -o "${!n}" == "-" ]; then
builtin cd "$@";
else
local e="s:\.\.\.:../..:g";
builtin cd "${@:1:$n-1}" $(sed -e$e -e$e -e$e <<< "${!n}");
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment