From fa9e445342aa4ffa6f2be68af62247aeed03f586 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Wed, 20 Sep 2017 20:50:10 -0500 Subject: [PATCH] Add history-based completions for autojump's j command j does not have any "logical" source of completions, but it almost often called with arguments that have been seen before (since it is used to jump to favorite/recent directories). We can search the history for possible completions and use those. This is an example of the behavior mentioned in #4344 as a possible enhancement for fish 3.0, where completions can be provided from history if none are otherwise found. --- share/completions/j.fish | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 share/completions/j.fish diff --git a/share/completions/j.fish b/share/completions/j.fish new file mode 100644 index 000000000..04c45411d --- /dev/null +++ b/share/completions/j.fish @@ -0,0 +1,6 @@ +function __history_completions + set -l tokens (commandline --current-process --tokenize) + history --prefix (commandline) | string replace -r \^$tokens[1]\\s\* "" +end + +complete -k -c j -a '(__history_completions)' -f