diff --git a/Examples.md b/Examples.md index 7057006..825ec55 100644 --- a/Examples.md +++ b/Examples.md @@ -713,4 +713,41 @@ Search through your LastPass vault with [LastPass CLI](https://github.com/lastpa ```sh $ lpass show -c --password $(lpass ls | fzf | awk '{print $(NF)}' | sed 's/\]//g') -``` \ No newline at end of file +``` + +### [fzf-marker](https://github.com/liangguohuan/fzf-marker) +The terminal command Tweak https://github.com/pindexis/marker.git + +[![asciicast](https://asciinema.org/a/122370.png)](https://asciinema.org/a/122370?autoplay=1) + +``` +# marker templete select +_fzf_marker_display() { + local selected + if selected=$(cat ${FZF_MARKER_CONF_DIR:-~/.config/marker}/*.txt | + sed -e 's/\(^[a-zA-Z0-9_-]\+\)\s/\x1b[38;5;255m\1\x1b[0m /' -e 's/\s*\(#\+\)\(.*\)/\x1b[38;5;8m \1\2\x1b[0m/' | + fzf --bind 'tab:down,btab:up' --height=80% --ansi -q "$LBUFFER"); then + LBUFFER=$(echo $selected | sed 's/\s*#.*//') + fi + zle redisplay +} + +# move the cursor the next placeholder +function _fzf_move_cursor_to_next_placeholder { + match=$(echo "$BUFFER" | perl -nle 'print $& if m{\{\{.+?\}\}}' | head -n 1) + if [[ ! -z "$match" ]]; then + len=${#match} + match=$(echo "$match" | sed 's/"/\\"/g') + placeholder_offset=$(echo "$BUFFER" | python -c 'import sys;keyboard_input = raw_input if sys.version_info[0] == 2 else input; print(keyboard_input().index("'$match'"))') + CURSOR="$placeholder_offset" + BUFFER="${BUFFER[1,$placeholder_offset]}${BUFFER[$placeholder_offset+1+$len,-1]}" + fi +} + +zle -N _fzf_marker_display +zle -N _fzf_move_cursor_to_next_placeholder +bindkey "${FZF_MARKER_DISPLAY_KEY:-\C-@}" _fzf_marker_display +bindkey "${FZF_MARKER_NEXT_PLACEHOLDER_KEY:-\C-v}" _fzf_move_cursor_to_next_placeholder +``` + +