m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-18 08:13:40 -05:00

The terminal command Tweak https://github.com/pindexis/marker.git

hanson
2017-05-26 11:33:48 -05:00
parent c9afa3ef5c
commit 95982a4c2f

@@ -714,3 +714,40 @@ Search through your LastPass vault with [LastPass CLI](https://github.com/lastpa
```sh ```sh
$ lpass show -c --password $(lpass ls | fzf | awk '{print $(NF)}' | sed 's/\]//g') $ lpass show -c --password $(lpass ls | fzf | awk '{print $(NF)}' | sed 's/\]//g')
``` ```
### [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
```