Skip to content

Commit faab292

Browse files
committed
feat: no empty command completion if no_empty_cmd_completion is on
On some systems, generating the entire list of available commands takes a long time. `no_empty_cmd_completion` is semantically close enough to piggyback on it here. Closes #926
1 parent 9f7931a commit faab292

26 files changed

+80
-26
lines changed

bash_completion

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2702,6 +2702,15 @@ _complete_as_root()
27022702
[[ $EUID -eq 0 || ${root_command-} ]]
27032703
}
27042704

2705+
# Complete on available commands, subject to `no_empty_cmd_completion`.
2706+
#
2707+
# @since 2.12
2708+
_comp_compgen_commands()
2709+
{
2710+
[[ ! ${cur-} ]] && shopt -q no_empty_cmd_completion && return
2711+
_comp_compgen -- -c
2712+
}
2713+
27052714
# @since 2.12
27062715
_comp_longopt()
27072716
{

completions/_svn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ _comp_cmd_svn()
3939
;;
4040
--editor-cmd | --diff-cmd | --diff3-cmd)
4141
compopt -o filenames
42-
_comp_compgen -- -c
42+
_comp_compgen_commands
4343
return
4444
;;
4545
esac

completions/cpio

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ _comp_cmd_cpio()
2323
;;
2424
--rsh-command)
2525
compopt -o filenames
26-
_comp_compgen -- -c
26+
_comp_compgen_commands
2727
return
2828
;;
2929
esac

completions/dpkg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ _comp_cmd_dpkg()
130130
return
131131
;;
132132
--status-logger)
133-
_comp_compgen -- -c
133+
_comp_compgen_commands
134134
return
135135
;;
136136
--verify-format)

completions/fio

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ _comp_cmd_fio()
7575
;;
7676
--trigger | --trigger-remote)
7777
compopt -o filenames
78-
_comp_compgen -- -c
78+
_comp_compgen_commands
7979
return
8080
;;
8181
--aux-path)
@@ -88,7 +88,7 @@ _comp_cmd_fio()
8888
return
8989
;;
9090
--exec_postrun | --exec_prerun)
91-
_comp_compgen -- -c
91+
_comp_compgen_commands
9292
return
9393
;;
9494
--uid)

completions/firefox

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ _comp_cmd_firefox()
3333
return
3434
;;
3535
--debugger | -d)
36-
_comp_compgen -- -c
36+
_comp_compgen_commands
3737
return
3838
;;
3939
esac

completions/man

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ _comp_cmd_man()
3030
;;
3131
--pager | -${noargopts}P)
3232
compopt -o filenames
33-
_comp_compgen -- -c
33+
_comp_compgen_commands
3434
return
3535
;;
3636
--preprocessor | -${noargopts}p)

completions/mr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ _comp_cmd_mr()
5555
return
5656
;;
5757
run)
58-
_comp_compgen -- -c
58+
_comp_compgen_commands
5959
return
6060
;;
6161
*)

completions/mussh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ _comp_cmd_mussh()
3939
;;
4040
-c)
4141
compopt -o filenames
42-
_comp_compgen -a -- -c
42+
_comp_compgen -a commands
4343
return
4444
;;
4545
esac

completions/mypy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ _comp_cmd_mypy()
2525
return
2626
;;
2727
--python-executable)
28-
_comp_compgen -c "${cur:-py}" -- -c
28+
_comp_compgen -c "${cur:-py}" commands
2929
return
3030
;;
3131
--*-dir | --*-report)

0 commit comments

Comments
 (0)