From cadec731afd2480ccf9bffe0761c08f8937c0bc6 Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Thu, 10 Nov 2022 20:43:33 -0800 Subject: [PATCH] Update bookmark.zsh --- bookmark.zsh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bookmark.zsh b/bookmark.zsh index 5c3af4b..12ac4aa 100644 --- a/bookmark.zsh +++ b/bookmark.zsh @@ -16,7 +16,8 @@ function bm { [ "${#}" -eq 0 ] && { __zsh_list_bookmarks; return } # Otherwise, goto the bookmark in argv[1] __zsh_check_bookmark_name "${1}" || { echo "No such bookmark: '${1}'!"; return 1 } - [ -e "${ZSH_BOOKMARK_DIR}/${1}" ] || { echo "No such bookmark: '${1}'!"; return 1 } + [ -L "${ZSH_BOOKMARK_DIR}/${1}" ] || { echo "No such bookmark: '${1}'!"; return 1 } + [ -e "${ZSH_BOOKMARK_DIR}/${1}" ] || { echo "The bookmark '${1}' refers to a non-existant file!"; return 1 } cd -P "${ZSH_BOOKMARK_DIR}/${1}" [[ -v ZSH_BOOKMARK_LS ]] && "${ZSH_BOOKMARK_LS}" && ls } @@ -36,7 +37,7 @@ function bmadd { local real_path="$(realpath "${2}")" local bm_name="${1}" __zsh_check_bookmark_name "${bm_name}" || { echo "Invalid bookmark: '${1}'!"; return 1 } - if [ -e "${ZSH_BOOKMARK_DIR}/${bm_name}" ]; then + if [ -L "${ZSH_BOOKMARK_DIR}/${bm_name}" ]; then echo "A bookmark with the name '${bm_name}' already exists!" local reply read -q 'reply?Overwrite? [y/N] ' @@ -51,7 +52,7 @@ function bmadd { function bmrm { [ "${#}" -eq 0 ] && { echo "usage: bmrm "; return 1 } __zsh_check_bookmark_name "${1}" || { echo "No bookmark with the name '${1}' exists!"; return 1 } - [ -e "${ZSH_BOOKMARK_DIR}/${1}" ] || { echo "No bookmark with the name '${1}' exists!"; return 1 } + [ -L "${ZSH_BOOKMARK_DIR}/${1}" ] || { echo "No bookmark with the name '${1}' exists!"; return 1 } local reply read -q 'reply?Really delete? [y/N] ' printf '\n'