-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(zsh): improved zoxide interactions
- Loading branch information
1 parent
93b4650
commit 9fbe1ad
Showing
2 changed files
with
48 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env zsh | ||
|
||
_z_cd() { | ||
cd "$@" || return "$?" | ||
|
||
if [ "$_ZO_ECHO" = "1" ]; then | ||
echo "$PWD" | ||
fi | ||
} | ||
|
||
z() { | ||
if [ "$#" -eq 0 ]; then | ||
_z_cd ~ | ||
elif [ "$#" -eq 1 ] && [ "$1" = '-' ]; then | ||
if [ -n "$OLDPWD" ]; then | ||
_z_cd "$OLDPWD" | ||
else | ||
echo 'zoxide: $OLDPWD is not set' | ||
return 1 | ||
fi | ||
else | ||
_zoxide_result="$(zoxide query -- "$@")" && _z_cd "$_zoxide_result" | ||
fi | ||
check_nvmrc | ||
} | ||
|
||
zi() { | ||
_zoxide_result="$(zoxide query -i -- "$@")" && _z_cd "$_zoxide_result" | ||
} | ||
|
||
|
||
alias za='zoxide add' | ||
|
||
alias zq='zoxide query' | ||
alias zqi='zoxide query -i' | ||
|
||
alias zr='zoxide remove' | ||
zri() { | ||
_zoxide_result="$(zoxide query -i -- "$@")" && zoxide remove "$_zoxide_result" | ||
} | ||
|
||
|
||
_zoxide_hook() { | ||
zoxide add "$(pwd -L)" | ||
} | ||
|
||
chpwd_functions=(${chpwd_functions[@]} "_zoxide_hook") |