Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fish completion #94

Merged
merged 1 commit into from
Jun 14, 2022
Merged

Conversation

xfgusta
Copy link
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.

@codecov

This comment was marked as off-topic.

@tavianator
Copy link
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
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.

@tavianator
Copy link
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
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
Owner

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

Copy link
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.

completions/bfs.fish Outdated Show resolved Hide resolved
@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