mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
fa9e445342
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.
6 lines
216 B
Fish
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
|