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.
This commit is contained in:
Mahmoud Al-Qudsi 2017-09-20 20:50:10 -05:00
parent 46cf8c6bb7
commit fa9e445342

6
share/completions/j.fish Normal file
View File

@ -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