mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-01 02:57:47 +08:00
Complete current commandline token with __fish_complete_directories if
Akin to __fish_complete_suffix, __fish_complete_directories now attempts to complete the current commandline token if no token is explicitly passed in as an argument.
This commit is contained in:
parent
82c8abc4dc
commit
5f1168002e
|
@ -1,12 +1,17 @@
|
||||||
#
|
#
|
||||||
# Find directories that complete $argv[1], output them as completions
|
# Find directories that complete $argv[1], output them as completions
|
||||||
# with description $argv[2] if defined, otherwise use 'Directory'
|
# with description $argv[2] if defined, otherwise use 'Directory'.
|
||||||
|
# If no arguments are provided, attempts to complete current commandline token.
|
||||||
#
|
#
|
||||||
function __fish_complete_directories -d "Complete directory prefixes" --argument comp desc
|
function __fish_complete_directories -d "Complete directory prefixes" --argument comp desc
|
||||||
if not set -q desc[1]
|
if not set -q desc[1]
|
||||||
set desc (_ "Directory")
|
set desc (_ "Directory")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not set -q comp[1]
|
||||||
|
set comp (commandline -ct)
|
||||||
|
end
|
||||||
|
|
||||||
set -l dirs $comp*/
|
set -l dirs $comp*/
|
||||||
if set -q dirs[1]
|
if set -q dirs[1]
|
||||||
printf "%s\t$desc\n" $dirs
|
printf "%s\t$desc\n" $dirs
|
||||||
|
|
Loading…
Reference in New Issue
Block a user