-
-
Save yanick/fb6b62645759ef9b3db2102eb64356a2 to your computer and use it in GitHub Desktop.
cd to the repo root
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
# Defined in /home/yanick/.config/fish/functions/cdr.fish @ line 1 | |
function cdr --description 'cd to the repo root' | |
set -l repo_dir ( perl -MPath::Tiny \ | |
-E'$x = path(".")->absolute; while(1){ exit say $x if $x->child(".git")->is_dir; exit if $x eq "/"; $x = $x->parent }' ) | |
if [ $repo_dir != "" ] | |
cd $repo_dir | |
else | |
echo "not in a git repo" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment