mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-17 15:53:39 -05:00
Updated Examples (markdown)
54
Examples.md
54
Examples.md
@@ -553,60 +553,6 @@ fi
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Command history not blocked in MSYS2 environment
|
|
||||||
|
|
||||||
```sh
|
|
||||||
# CTRL-R script for MSYS2 environment (requires winpty)
|
|
||||||
# For the most part the same as the original __fzf_history__.
|
|
||||||
_fzf_history_msys2() {
|
|
||||||
local PERL_SCRIPT='
|
|
||||||
BEGIN { getc; $/ = "\n\t"; $HISTCOUNT = $ENV{last_hist} + 1 }
|
|
||||||
s/^[ *]//; print $HISTCOUNT - $. . "\t$_" if !$seen{$_}++
|
|
||||||
'
|
|
||||||
local FZF_OPTS="
|
|
||||||
--height ${FZF_TMUX_HEIGHT:-40%}
|
|
||||||
--bind=ctrl-z:ignore
|
|
||||||
${FZF_DEFAULT_OPTS}
|
|
||||||
-n2..,.. --tiebreak=index
|
|
||||||
--bind=ctrl-r:toggle-sort
|
|
||||||
${FZF_CTRL_R_OPTS}
|
|
||||||
+m --read0
|
|
||||||
"
|
|
||||||
|
|
||||||
# Concurrency is not considered (who needs it?)
|
|
||||||
local WORK_DIR="${TMPDIR:-/tmp}/${FUNCNAME[0]##_}-${UID:-$(id -u)}"
|
|
||||||
mkdir -p "${WORK_DIR}" || return
|
|
||||||
|
|
||||||
# builtin command does not work inside winpty correctly,
|
|
||||||
# so run it here to take output to a file.
|
|
||||||
(set -o pipefail
|
|
||||||
builtin fc -lnr -2147483648 |
|
|
||||||
last_hist=$(HISTTIMEFORMAT='' builtin history 1) \
|
|
||||||
perl -n -l0 -e "${PERL_SCRIPT}" \
|
|
||||||
>"${WORK_DIR}"/input
|
|
||||||
) || return
|
|
||||||
|
|
||||||
# stdin is passed to winpty as-is tty, and input/output
|
|
||||||
# to/from fzf is via file.
|
|
||||||
winpty -- bash -c "
|
|
||||||
FZF_DEFAULT_OPTS='${FZF_OPTS}' fzf --query '${READLINE_LINE}' \
|
|
||||||
<'${WORK_DIR}'/input >'${WORK_DIR}'/output
|
|
||||||
" || return
|
|
||||||
|
|
||||||
# Get fzf output from file.
|
|
||||||
READLINE_LINE=$(sed -E 's|^[0-9]*\s*||' "${WORK_DIR}"/output)
|
|
||||||
if [[ -z "${READLINE_POINT}" ]]; then
|
|
||||||
echo "${READLINE_LINE}"
|
|
||||||
else
|
|
||||||
READLINE_POINT=0x7fffffff
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
bind -m emacs-standard -x '"\C-r": _fzf_history_msys2'
|
|
||||||
bind -m vi-command -x '"\C-r": _fzf_history_msys2'
|
|
||||||
bind -m vi-insert -x '"\C-r": _fzf_history_msys2'
|
|
||||||
```
|
|
||||||
|
|
||||||
### Processes
|
### Processes
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
|||||||
Reference in New Issue
Block a user