Skip to content

Commit

Permalink
Complete current commandline token with __fish_complete_directories if
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mqudsi committed May 12, 2018
1 parent 82c8abc commit 5f11680
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion share/functions/__fish_complete_directories.fish
@@ -1,12 +1,17 @@
#
# 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
if not set -q desc[1]
set desc (_ "Directory")
end

if not set -q comp[1]
set comp (commandline -ct)
end

set -l dirs $comp*/
if set -q dirs[1]
printf "%s\t$desc\n" $dirs
Expand Down

0 comments on commit 5f11680

Please sign in to comment.