summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authora1346054 <36859588+a1346054@users.noreply.github.com>2021-08-14 11:33:21 +0000
committerJunegunn Choi <junegunn.c@gmail.com>2021-08-15 16:03:26 +0900
commite53b4bb4398a3ed8950d6709bf207f4b9b4e1cbc (patch)
tree7ca18b685d280cdb941ae4e9d63e87c717244d0c /shell
parentab247a1309c987af1e92f3aa3fec9e14b4633428 (diff)
always use [[ ... ]] and not [ ... ] in bash completions
Diffstat (limited to 'shell')
-rw-r--r--shell/completion.bash22
1 files changed, 11 insertions, 11 deletions
diff --git a/shell/completion.bash b/shell/completion.bash
index bc9f29fa..a9e6d4c1 100644
--- a/shell/completion.bash
+++ b/shell/completion.bash
@@ -35,9 +35,9 @@ fi
bind '"\e[0n": redraw-current-line'
__fzf_comprun() {
- if [ "$(type -t _fzf_comprun 2>&1)" = function ]; then
+ if [[ "$(type -t _fzf_comprun 2>&1)" = function ]]; then
_fzf_comprun "$@"
- elif [ -n "$TMUX_PANE" ] && { [ "${FZF_TMUX:-0}" != 0 ] || [ -n "$FZF_TMUX_OPTS" ]; }; then
+ elif [[ -n "$TMUX_PANE" ]] && { [[ "${FZF_TMUX:-0}" != 0 ]] || [[ -n "$FZF_TMUX_OPTS" ]]; }; then
shift
fzf-tmux ${FZF_TMUX_OPTS:--d${FZF_TMUX_HEIGHT:-40%}} -- "$@"
else
@@ -140,14 +140,14 @@ _fzf_handle_dynamic_completion() {
orig_cmd="$1"
orig_var="_fzf_orig_completion_$cmd"
orig="${!orig_var##*#}"
- if [ -n "$orig" ] && type "$orig" > /dev/null 2>&1; then
+ if [[ -n "$orig" ]] && type "$orig" > /dev/null 2>&1; then
$orig "$@"
- elif [ -n "$_fzf_completion_loader" ]; then
+ elif [[ -n "$_fzf_completion_loader" ]]; then
orig_complete=$(complete -p "$orig_cmd" 2> /dev/null)
_completion_loader "$@"
ret=$?
# _completion_loader may not have updated completion for the command
- if [ "$(complete -p "$orig_cmd" 2> /dev/null)" != "$orig_complete" ]; then
+ if [[ "$(complete -p "$orig_cmd" 2> /dev/null)" != "$orig_complete" ]]; then
__fzf_orig_completion < <(complete -p "$orig_cmd" 2> /dev/null)
if [[ "$__fzf_nospace_commands" = *" $orig_cmd "* ]]; then
eval "${orig_complete/ -F / -o nospace -F }"
@@ -171,17 +171,17 @@ __fzf_generic_path_completion() {
[[ $base = *"/"* ]] && dir="$base"
while true; do
- if [ -z "$dir" ] || [ -d "$dir" ]; then
+ if [[ -z "$dir" ]] || [[ -d "$dir" ]]; then
leftover=${base/#"$dir"}
leftover=${leftover/#\/}
- [ -z "$dir" ] && dir='.'
- [ "$dir" != "/" ] && dir="${dir/%\//}"
+ [[ -z "$dir" ]] && dir='.'
+ [[ "$dir" != "/" ]] && dir="${dir/%\//}"
matches=$(eval "$1 $(printf %q "$dir")" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore $FZF_DEFAULT_OPTS $FZF_COMPLETION_OPTS $2" __fzf_comprun "$4" -q "$leftover" | while read -r item; do
printf "%q$3 " "$item"
done)
matches=${matches% }
[[ -z "$3" ]] && [[ "$__fzf_nospace_commands" = *" ${COMP_WORDS[0]} "* ]] && matches="$matches "
- if [ -n "$matches" ]; then
+ if [[ -n "$matches" ]]; then
COMPREPLY=( "$matches" )
else
COMPREPLY=( "$cur" )
@@ -234,7 +234,7 @@ _fzf_complete() {
selected=$(FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore $FZF_DEFAULT_OPTS $FZF_COMPLETION_OPTS $str_arg" __fzf_comprun "${rest[0]}" "${args[@]}" -q "$cur" | $post | tr '\n' ' ')
selected=${selected% } # Strip trailing space not to repeat "-o nospace"
- if [ -n "$selected" ]; then
+ if [[ -n "$selected" ]]; then
COMPREPLY=("$selected")
else
COMPREPLY=("$cur")
@@ -330,7 +330,7 @@ __fzf_defc() {
opts="$3"
orig_var="_fzf_orig_completion_${cmd//[^A-Za-z0-9_]/_}"
orig="${!orig_var}"
- if [ -n "$orig" ]; then
+ if [[ -n "$orig" ]]; then
printf -v def "$orig" "$func"
eval "$def"
else