Skip to content

Commit

Permalink
[fzf-tmux] Use double brackets
Browse files Browse the repository at this point in the history
For consistency and (negligible) performance improvement
  • Loading branch information
junegunn committed Jul 10, 2016
1 parent 0fb5b76 commit 0f87b2d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions bin/fzf-tmux
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ skip=""
swap=""
close=""
term=""
[ -n "$LINES" ] && lines=$LINES || lines=$(tput lines)
[[ -n "$LINES" ]] && lines=$LINES || lines=$(tput lines)
while [ $# -gt 0 ]; do
arg="$1"
case "$arg" in
Expand Down Expand Up @@ -91,8 +91,8 @@ while [ $# -gt 0 ]; do
shift
done

if ! [ -n "$TMUX" -a "$lines" -gt 15 ]; then
fzf "${args[@]}"
if [[ -z "$TMUX" ]] || [[ "$lines" -le 15 ]]; then
"$fzf" "${args[@]}"
exit $?
fi

Expand All @@ -116,7 +116,7 @@ cleanup() {
rm -f $argsf $fifo1 $fifo2 $fifo3

# Remove temp window if we were zoomed
if [ -n "$zoomed" ]; then
if [[ -n "$zoomed" ]]; then
tmux swap-pane -t $original_window \; \
select-window -t $original_window \; \
kill-window -t $tmp_window \; \
Expand All @@ -126,8 +126,8 @@ cleanup() {
trap cleanup EXIT SIGINT SIGTERM

envs="env TERM=$TERM "
[ -n "$FZF_DEFAULT_OPTS" ] && envs="$envs FZF_DEFAULT_OPTS=$(printf %q "$FZF_DEFAULT_OPTS")"
[ -n "$FZF_DEFAULT_COMMAND" ] && envs="$envs FZF_DEFAULT_COMMAND=$(printf %q "$FZF_DEFAULT_COMMAND")"
[[ -n "$FZF_DEFAULT_OPTS" ]] && envs="$envs FZF_DEFAULT_OPTS=$(printf %q "$FZF_DEFAULT_OPTS")"
[[ -n "$FZF_DEFAULT_COMMAND" ]] && envs="$envs FZF_DEFAULT_COMMAND=$(printf %q "$FZF_DEFAULT_COMMAND")"

mkfifo -m o+w $fifo2
mkfifo -m o+w $fifo3
Expand All @@ -142,7 +142,7 @@ for arg in "${args[@]}"; do
opts="$opts \"$arg\""
done

if [ -n "$term" -o -t 0 ]; then
if [[ -n "$term" ]] || [[ -t 0 ]]; then
cat <<< "\"$fzf\" $opts > $fifo2; echo \$? > $fifo3 $close" > $argsf
tmux set-window-option synchronize-panes off \;\
set-window-option remain-on-exit off \;\
Expand Down

0 comments on commit 0f87b2d

Please sign in to comment.