Commit 9715eedc authored by Rob Muhlestein's avatar Rob Muhlestein 👌

search edit GOLD

parent 76c1509b
......@@ -168,6 +168,18 @@ _edit() {
cd $dir
}
_sedit () {
declare -a list
local IFS=$'\n'
readarray list < <(_search "$1")
[[ ${#list[@]} -eq 0 ]] && echo "$(sol r)Not found: $(sol c)$1$(sol x)" && return 1
[[ ${#list[@]} -eq 1 ]] && _edit "${list[0]%% *}" && return $?
select node in ${list[@]}; do
_edit "${node%% *}"
return $?
done
}
_last () {
local file="$KNWORK/.kn/last/edit"
if [[ -f "$file" ]]; then
......@@ -289,7 +301,7 @@ _search () {
local n=${line%% *}
local t=${line/$n }
local title=${t#* }
[[ "${title,,}" =~ "${1,,}" ]] && echo "$line"
[[ "${title,,}" =~ ${1,,} ]] && echo "$line"
done
}
......@@ -315,13 +327,15 @@ _help () {
echo " rm - interactively removes a specific node"
echo " e[dit] [NODE] - edits a NODE or last, runs .kn/vimscript if found"
echo " E[dit] [NODE] - edits a NODE or last, no vimscript"
echo " se[dit] REGX - searches for REGX in titles and prompts to edit"
echo " sE[dit] REGX - same as se[dit] but without .kn/vimscript"
echo " ls - lists all nodes, sorted"
echo " lp - lists all nodes with paths, sorted"
echo " ll - lists all nodes with titles, sorted"
echo " lli [TYPE] - lists all nodes with titles ignoring TYPE (default: index)"
echo " i[ndex] - generate the master index node"
echo " t[emplate] - open .kn/theme/index.html in vim"
echo " search|? - search for keyword in node name or titles"
echo " s[earch]|\? - search for keyword in node name or titles"
echo
echo "NODE is a lower-case, no space slug at the top level"
echo "TYPE is a class of nodes (ex: \$KNWORK/.kn/ignore/index)"
......@@ -352,13 +366,15 @@ case "$1" in
rm) shift; _rm "$@" ;;
edit|e) shift; _edit "$@" ;;
Edit|E) shift; NOVIMSCRIPT=1 _edit "$@" ;;
sedit|se) shift; _sedit "$@" ;;
sEdit|sE) shift; NOVIMSCRIPT=1 _sedit "$@" ;;
ls) shift; _ls "$@" ;;
ll) shift; _ll "$@" ;;
lli) shift; _llignore "$@" ;;
lp) shift; _lp "$@" ;;
index|i) shift; _index "$@" ;;
template|t) vim "$KNWORK/.kn/theme/index.html" ;;
search|\?) shift; _search "$@" ;;
s|search|\?) shift; _search "$@" ;;
*) _help | more ;;
esac
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment