Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion templates/bash.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function __zoxide_z() {
__zoxide_cd ~
elif [[ $# -eq 1 && $1 == '-' ]]; then
__zoxide_cd "${OLDPWD}"
elif [[ $# -eq 1 && -d $1 ]]; then
elif [[ $# -eq 1 && -d ${1%%+(/)} ]]; then
__zoxide_cd "$1"
elif [[ $# -eq 2 && $1 == '--' ]]; then
__zoxide_cd "$2"
Expand Down
2 changes: 1 addition & 1 deletion templates/fish.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function __zoxide_z
__zoxide_cd $HOME
else if test "$argv" = -
__zoxide_cd -
else if test $argc -eq 1 -a -d $argv[1]
else if test $argc -eq 1 -a -d (string replace -r '/+$' '' -- $argv[1])
__zoxide_cd $argv[1]
else if test $argc -eq 2 -a $argv[1] = --
__zoxide_cd -- $argv[2]
Expand Down
14 changes: 12 additions & 2 deletions templates/posix.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,18 @@ __zoxide_z() {
\command printf 'zoxide: $OLDPWD is not set'
return 1
fi
elif [ "$#" -eq 1 ] && [ -d "$1" ]; then
__zoxide_cd "$1"
elif [ "$#" -eq 1 ]; then
__zoxide_arg="$1"
# Strip trailing slashes for directory test
while [ "${__zoxide_arg}" != "${__zoxide_arg%/}" ] && [ "${__zoxide_arg}" != / ]; do
__zoxide_arg="${__zoxide_arg%/}"
done
if [ -d "${__zoxide_arg}" ]; then
__zoxide_cd "$1"
else
__zoxide_result="$(\command zoxide query --exclude "$(__zoxide_pwd || \command true)" -- "$@")" &&
__zoxide_cd "${__zoxide_result}"
fi
else
__zoxide_result="$(\command zoxide query --exclude "$(__zoxide_pwd || \command true)" -- "$@")" &&
__zoxide_cd "${__zoxide_result}"
Expand Down
10 changes: 8 additions & 2 deletions templates/tcsh.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@ if ("$#__zoxide_args" == 0) then\
else\
if ("$#__zoxide_args" == 1 && "$__zoxide_args[1]" == "-") then\
cd -\
else if ("$#__zoxide_args" == 1 && -d "$__zoxide_args[1]") then\
cd "$__zoxide_args[1]"\
else if ("$#__zoxide_args" == 1) then\
set __zoxide_arg_tmp = `echo "$__zoxide_args[1]" | sed "s|/*$||"`\
if (-d "$__zoxide_arg_tmp") then\
cd "$__zoxide_args[1]"\
else\
set __zoxide_pwd = `{{ pwd_cmd }}`\
set __zoxide_result = "`zoxide query --exclude '"'"'$__zoxide_pwd'"'"' -- $__zoxide_args`" && cd "$__zoxide_result"\
endif\
else\
set __zoxide_pwd = `{{ pwd_cmd }}`\
set __zoxide_result = "`zoxide query --exclude '"'"'$__zoxide_pwd'"'"' -- $__zoxide_args`" && cd "$__zoxide_result"\
Expand Down
2 changes: 1 addition & 1 deletion templates/zsh.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function __zoxide_z() {
__zoxide_doctor
if [[ "$#" -eq 0 ]]; then
__zoxide_cd ~
elif [[ "$#" -eq 1 ]] && { [[ -d "$1" ]] || [[ "$1" = '-' ]] || [[ "$1" =~ ^[-+][0-9]+$ ]]; }; then
elif [[ "$#" -eq 1 ]] && { [[ -d "${1%%/##}" ]] || [[ "$1" = '-' ]] || [[ "$1" =~ ^[-+][0-9]+$ ]]; }; then
__zoxide_cd "$1"
elif [[ "$#" -eq 2 ]] && [[ "$1" = "--" ]]; then
__zoxide_cd "$2"
Expand Down
Loading