Update emacs-bookmark.zsh
This commit is contained in:
parent
f22d24b042
commit
9b90c216f3
@ -2,6 +2,7 @@
|
||||
|
||||
# Enable color utilities
|
||||
autoload colors && colors
|
||||
autoload regexp-replace
|
||||
|
||||
__bm_bookmark_cache=()
|
||||
|
||||
@ -97,7 +98,7 @@ function __bm_list_bookmarks {
|
||||
|
||||
function _bookmarks {
|
||||
for ((i = 1; i < ${#__bm_bookmark_cache}; i+=4)); do
|
||||
compadd "${__bm_bookmark_cache[${i}]}"
|
||||
compadd -S '/' "${__bm_bookmark_cache[${i}]}"
|
||||
done
|
||||
}
|
||||
|
||||
@ -127,7 +128,28 @@ function bm {
|
||||
fi
|
||||
}
|
||||
function _bm {
|
||||
_arguments '1::bookmark:_bookmarks'
|
||||
local arg="${words[${CURRENT}]}"
|
||||
if ! [[ "${arg}" == */* ]]; then
|
||||
_arguments '1::bookmark:_bookmarks'
|
||||
else
|
||||
local loc=(${(f)"$(__bm_bookmark_location "${arg}")"})
|
||||
if [[ -d "${loc[1]}" ]]; then
|
||||
local parts=(${(s:/:)loc[3]})
|
||||
local bm="${${(s:/:)${arg}}[1]}"
|
||||
local subdir="${(j:/:)parts[1,${#parts}-1]}"
|
||||
local search="${parts[${#parts}]}"
|
||||
if ((${#parts} > 0)) && [[ "${arg}" == */ ]]; then
|
||||
subdir="${subdir}/${search}"
|
||||
subdir="${subdir#/}"
|
||||
search=""
|
||||
fi
|
||||
for file in "${loc[1]}/${subdir}/${search}"*(/); do
|
||||
local clean_file="${bm}/${file#"${loc[1]}"}"
|
||||
regexp-replace clean_file '/+' '/'
|
||||
compadd -U -S '/' "${clean_file}"
|
||||
done
|
||||
fi
|
||||
fi
|
||||
}
|
||||
compdef _bm bm
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user