ajeetdsouza / zoxide

A smarter cd command. Supports all major shells.
MIT License
20.33k stars 519 forks source link

need `z -b` #753

Closed owenstake closed 3 months ago

owenstake commented 3 months ago

z -b in z.lua is useful to go back to the root of git repo.

bew commented 3 months ago

Note that you can implement it easily by aliasing to:

cd "$(git rev-parse --show-toplevel)"
owenstake commented 3 months ago

Note that you can implement it easily by aliasing to:

cd "$(git rev-parse --show-toplevel)"

Fantasy. Sometime I need to go back to the root with custom mark file .root

owenstake commented 3 months ago

I achieve it without zoxide in powershell. zb will change directory to the parent directory with .root/.git.

    Function zb {
        $markFiles = (".root", ".git", ".svn", "package.json")
        $curDir = $(Get-Item ".")
        while ($curDir) {
            $dirName = $curDir.FullName
            ForEach($m in $markFiles) {
                If (Test-Path "$dirName/$m") {
                    cd $dirName 
                    return
                }
            }
            $curDir = $curDir.Parent
        }
        echo "No found upper .root"
    }