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
39
Examples.md
39
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')
|
||||
```
|
||||
```
|
||||
|
||||
### [fzf-marker](https://github.com/liangguohuan/fzf-marker)
|
||||
The terminal command Tweak https://github.com/pindexis/marker.git
|
||||
|
||||
[](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
|
||||
```
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user