mirror of
https://github.com/junegunn/fzf.git
synced 2026-05-19 23:10:06 +08:00
fzf-tmux: Use mktemp, and fix TERM quoting (#4664)
This commit is contained in:
committed by
GitHub
parent
b389616030
commit
9725eac314
+7
-8
@@ -159,11 +159,11 @@ fi
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Clean up named pipes on exit
|
# Clean up named pipes on exit
|
||||||
id=$RANDOM
|
tmpdir=$(mktemp -d "${TMPDIR:-/tmp}/fzf-tmux-XXXXXX")
|
||||||
argsf="${TMPDIR:-/tmp}/fzf-args-$id"
|
argsf="$tmpdir/args"
|
||||||
fifo1="${TMPDIR:-/tmp}/fzf-fifo1-$id"
|
fifo1="$tmpdir/fifo1"
|
||||||
fifo2="${TMPDIR:-/tmp}/fzf-fifo2-$id"
|
fifo2="$tmpdir/fifo2"
|
||||||
fifo3="${TMPDIR:-/tmp}/fzf-fifo3-$id"
|
fifo3="$tmpdir/fifo3"
|
||||||
if tmux_win_opts=$(tmux show-options -p remain-on-exit \; show-options -p synchronize-panes 2> /dev/null); then
|
if tmux_win_opts=$(tmux show-options -p remain-on-exit \; show-options -p synchronize-panes 2> /dev/null); then
|
||||||
tmux_win_opts=($(sed '/ off/d; s/synchronize-panes/set-option -p synchronize-panes/; s/remain-on-exit/set-option -p remain-on-exit/; s/$/ \\;/' <<< "$tmux_win_opts"))
|
tmux_win_opts=($(sed '/ off/d; s/synchronize-panes/set-option -p synchronize-panes/; s/remain-on-exit/set-option -p remain-on-exit/; s/$/ \\;/' <<< "$tmux_win_opts"))
|
||||||
tmux_off_opts='; set-option -p synchronize-panes off ; set-option -p remain-on-exit off'
|
tmux_off_opts='; set-option -p synchronize-panes off ; set-option -p remain-on-exit off'
|
||||||
@@ -172,8 +172,7 @@ else
|
|||||||
tmux_off_opts='; set-window-option synchronize-panes off ; set-window-option remain-on-exit off'
|
tmux_off_opts='; set-window-option synchronize-panes off ; set-window-option remain-on-exit off'
|
||||||
fi
|
fi
|
||||||
cleanup() {
|
cleanup() {
|
||||||
\rm -f $argsf $fifo1 $fifo2 $fifo3
|
\rm -rf "$tmpdir"
|
||||||
|
|
||||||
# Restore tmux window options
|
# Restore tmux window options
|
||||||
if [[ ${#tmux_win_opts[@]} -gt 1 ]]; then
|
if [[ ${#tmux_win_opts[@]} -gt 1 ]]; then
|
||||||
eval "tmux ${tmux_win_opts[*]}"
|
eval "tmux ${tmux_win_opts[*]}"
|
||||||
@@ -196,7 +195,7 @@ cleanup() {
|
|||||||
trap 'cleanup 1' SIGUSR1
|
trap 'cleanup 1' SIGUSR1
|
||||||
trap 'cleanup' EXIT
|
trap 'cleanup' EXIT
|
||||||
|
|
||||||
envs="export TERM=$TERM "
|
envs="export TERM=$(printf %q "$TERM") "
|
||||||
if [[ $opt =~ "-E" ]]; then
|
if [[ $opt =~ "-E" ]]; then
|
||||||
if [[ $tmux_version == 3.2 ]]; then
|
if [[ $tmux_version == 3.2 ]]; then
|
||||||
FZF_DEFAULT_OPTS="--margin 0,1 $FZF_DEFAULT_OPTS"
|
FZF_DEFAULT_OPTS="--margin 0,1 $FZF_DEFAULT_OPTS"
|
||||||
|
|||||||
Reference in New Issue
Block a user