Created
March 30, 2016 23:08
-
-
Save ddribin/a67938040f04f70460eb220fcdea5af5 to your computer and use it in GitHub Desktop.
The 'cd' function in my .zshrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd () | |
{ | |
if (( ${#argv} == 0 )); then | |
builtin cd | |
return | |
fi | |
local dir=$1 | |
if [[ -f $dir ]]; then | |
file=$dir:t | |
echo "Ignoring: $file" | |
dir=$dir:h | |
fi | |
builtin cd "$dir" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This allows running
cd
on a file and it will ignore the file component: