feat(Nushell): trancate diractory path to git root
This commit is contained in:
@@ -59,6 +59,23 @@ def --env --wrapped __zoxide_zi [...rest:string] {
|
||||
cd $'(zoxide query --interactive -- ...$rest | str trim -r -c "\n")'
|
||||
}
|
||||
|
||||
# Jump to git repository root when currently inside a repository.
|
||||
def --env __zoxide_zg [] {
|
||||
if (which ^git | is-empty) {
|
||||
return
|
||||
}
|
||||
|
||||
let top = (^git rev-parse --show-toplevel | complete)
|
||||
if ($top.exit_code != 0) {
|
||||
return
|
||||
}
|
||||
|
||||
let root = ($top.stdout | str trim -r -c "\n")
|
||||
if ($root != "") {
|
||||
cd $root
|
||||
}
|
||||
}
|
||||
|
||||
# =============================================================================
|
||||
#
|
||||
# Commands for zoxide. Disable these using --no-cmd.
|
||||
@@ -66,6 +83,7 @@ def --env --wrapped __zoxide_zi [...rest:string] {
|
||||
|
||||
export alias z = __zoxide_z
|
||||
export alias zi = __zoxide_zi
|
||||
export alias zg = __zoxide_zg
|
||||
|
||||
# =============================================================================
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user