diff --git a/bookmark.zsh b/bookmark.zsh index dd09660..5c3af4b 100644 --- a/bookmark.zsh +++ b/bookmark.zsh @@ -6,12 +6,16 @@ function __zsh_list_bookmarks { command ls "${ZSH_BOOKMARK_DIR}" } +function __zsh_check_bookmark_name { + ! [[ "${1}" == *'/'* ]] +} # bm function bm { # With no args, list all bookmarks [ "${#}" -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 } cd -P "${ZSH_BOOKMARK_DIR}/${1}" [[ -v ZSH_BOOKMARK_LS ]] && "${ZSH_BOOKMARK_LS}" && ls @@ -31,6 +35,7 @@ function bmadd { [ "${#}" -eq 1 ] && { bmadd "${1}" "${PWD}"; return } 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 echo "A bookmark with the name '${bm_name}' already exists!" local reply @@ -45,6 +50,7 @@ function bmadd { # bmrm 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 } local reply read -q 'reply?Really delete? [y/N] ' diff --git a/init.zsh b/init.zsh index a663184..b290dd1 100644 --- a/init.zsh +++ b/init.zsh @@ -9,8 +9,8 @@ function load_plugin { source "${ZSH_PLUGIN_DIR}/${1}/${1}.plugin.zsh" } -__ZSH_EARLY_LOCAL_FILE="${ZSH_CONFIG_DIR}/local-early.zsh" -[ -e "${__ZSH_EARLY_LOCAL_FILE}" ] && source "${__ZSH_EARLY_LOCAL_FILE}" +ZSH_EARLY_LOCAL_FILE="${ZSH_CONFIG_DIR}/local-early.zsh" +[ -e "${ZSH_EARLY_LOCAL_FILE}" ] && source "${ZSH_EARLY_LOCAL_FILE}" # Some options setopt autocd extendedglob rm_star_silent