From 46dd1b4d42a153682b45631c6e7d48b7d074a23a Mon Sep 17 00:00:00 2001 From: luotaipeng Date: Wed, 26 Aug 2020 20:56:34 +0800 Subject: [PATCH] Improve goto the special directory similar to system cd command --- goto.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/goto.sh b/goto.sh index 1a1c8b8..35eee60 100644 --- a/goto.sh +++ b/goto.sh @@ -261,6 +261,12 @@ _goto_cleanup() # Changes to the given alias' directory _goto_directory() { + # directly goto the special name that unable register, eg: ~ + if ! [[ $1 =~ ^[[:alnum:]]+[a-zA-Z0-9_-]*$ ]]; then + { builtin cd "$1" 2> /dev/null && return 0; } || \ + { _goto_error "Failed to goto '$1'" && return 1; } + fi + local target target=$(_goto_resolve_alias "$1") || return 1