From 144af5116a5a048fe2e6a8424d1143c12fce9864 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Wed, 27 Jun 2018 14:42:42 -0500 Subject: [PATCH] Allow `functions -e` completions to complete hidden __fish functions ...but only if the user has started their function name argument with an underscore. --- share/completions/functions.fish | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/share/completions/functions.fish b/share/completions/functions.fish index c25e9777e..6010f583a 100644 --- a/share/completions/functions.fish +++ b/share/completions/functions.fish @@ -1,4 +1,13 @@ -complete -c functions -s e -l erase -d "Erase function" -x -a "(functions -n)" +function __fish_maybe_list_all_functions + # if the current commandline token starts with an _, list all functions + if string match -qr -- '^_' (commandline -ct) + functions -an + else + functions -n + end +end + +complete -c functions -s e -l erase -d "Erase function" -x -a "(__fish_maybe_list_all_functions)" complete -c functions -xa "(functions -na)" -d "Function" complete -c functions -s a -l all -d "Show hidden functions" complete -c functions -s h -l help -d "Display help and exit"