fish-shell/share/completions/j.fish
Mahmoud Al-Qudsi fa9e445342 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.
2017-09-20 20:50:10 -05:00

6 lines
216 B
Fish

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