Skip to content

Add fish completion#94

Merged
tavianator merged 1 commit intotavianator:mainfrom
xfgusta:add-fish-completion
Jun 14, 2022
Merged

Add fish completion#94
tavianator merged 1 commit intotavianator:mainfrom
xfgusta:add-fish-completion

Conversation

@xfgusta
Copy link
Copy Markdown
Contributor

@xfgusta xfgusta commented Jun 11, 2022

Here are some things I couldn't figure out how to implement:

!
(
)
,
-newerXY REFERENCE

I also don't know if I should add a completion for -noleaf.

The completion is installed in the /usr/share/fish/vendor_completions.d directory.

See #32.

@xfgusta xfgusta force-pushed the add-fish-completion branch from e20fed4 to 4e049ad Compare June 11, 2022 21:26
@codecov

This comment was marked as off-topic.

@tavianator
Copy link
Copy Markdown
Owner

Here are some things I couldn't figure out how to implement:

!
(
)
,

These aren't too important, since they're one character tab completion doesn't help much :)

-newerXY REFERENCE

These are handled by expanding out the full set of possibilities for bash and zsh. Maybe fish can do something similar?

-newer{a,B,c,m}{a,B,c,m}

'*-newer'{a,B,c,m}{a,B,c,m}'[find files where timestamp 1 is newer than timestamp 2 of reference FILE]:reference file:_files'

I also don't know if I should add a completion for -noleaf.

The bash and zsh ones have it, so fish might as well too.

@xfgusta
Copy link
Copy Markdown
Contributor Author

xfgusta commented Jun 13, 2022

These are handled by expanding out the full set of possibilities for bash and zsh. Maybe fish can do something similar?

I managed to do this using the following code:

# handle -newer{a,B,c,m}{a,B,c,m} FILE
for x in {a,B,c,m}
    for y in {a,B,c,m}
        complete -c bfs -o newer$x$y -d "Find files whose $x""time is newer than the $y""time of specified file" -F
    end
end

# handle -newer{a,B,c,m}t TIMESTAMP
for x in {a,B,c,m}
    complete -c bfs -o newer$x"t" -d "Find files whose $x""time is newer than specified timestamp" -x
end

It generates these completions (except the first one):

image

Does it look right?

The bash and zsh ones have it, so fish might as well too.

Added.

@xfgusta xfgusta force-pushed the add-fish-completion branch from 4e049ad to d87b30f Compare June 13, 2022 16:32
@tavianator
Copy link
Copy Markdown
Owner

Looks right to me. $x""time looks weird but I guess it's right, since fish doesn't support ${x}time.

@xfgusta
Copy link
Copy Markdown
Contributor Author

xfgusta commented Jun 13, 2022

$x""time looks weird but I guess it's right, since fish doesn't support ${x}time.

Unfortunately I couldn't come up with a better solution. Maybe something like this:

string join '' "Find files whose " $x "time is newer than the " $y "time of specified file"

@tavianator
Copy link
Copy Markdown
Owner

I think $x""time is better than that, might as well keep it

Copy link
Copy Markdown
Owner

@tavianator tavianator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I tried it out locally and it works. Just have the one question about -ls.

Comment thread completions/bfs.fish Outdated
@xfgusta xfgusta force-pushed the add-fish-completion branch from d87b30f to e311f2e Compare June 14, 2022 21:02
@tavianator tavianator merged commit a792d49 into tavianator:main Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants