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 FFmpeg completions #5922

Merged
merged 2 commits into from Jun 23, 2019
Merged

Add FFmpeg completions #5922

merged 2 commits into from Jun 23, 2019

Conversation

sorairolake
Copy link
Contributor

Add completions for ffmpeg, ffplay and ffprobe.

complete -x -c ffmpeg -s h -s "?" -o help -l help -a "
long
full
(ffmpeg -loglevel quiet -decoders | grep -v -e '=' -e ':\$' -e '^\s-' | sed 's/[\t ]/\t/g' | cut -f 3 | sed 's/^/decoder=/g')
Copy link
Member

Choose a reason for hiding this comment

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

Could you rewrite this to use our string builtin?

E.g. `string match -rv '=|:$|^\s-' | string replace -ra '\s' \t

Copy link
Member

Choose a reason for hiding this comment

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

Also this seems like prime use of a for-loop or even function:

for thing in encoder demuxer muxer filter
    printf '%s\n' $thing=(ffmpeg -loglevel quiet -{$thing}s | ...)
end

Copy link
Member

Choose a reason for hiding this comment

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

And instead of using cut based on whitespace, which has to use a different field just because this does a positional "ED" thing, use string trim to trim leading whitespace. That way it won't break if e.g. ffmpeg decides to actually display "ED" for some of these, or to start displaying it as ".D" (like the legend says!)

Copy link
Member

Choose a reason for hiding this comment

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

I.e. I'd roughly do this as

for thing in encoder demuxer muxer filter
    printf '%s\n' $thing=(ffmpeg -loglevel quiet -"$thing"s | 
                          string trim |
                          string match -rv '=|:\$|^\s-' | 
                          string replace -rf '\S+\s+(\S+)\s+(\S+)' '$1\t$2')
end

@faho faho added this to the fish 3.1.0 milestone Jun 5, 2019
@sorairolake
Copy link
Contributor Author

Fixed to use builtin command.

@faho faho merged commit e7b4261 into fish-shell:master Jun 23, 2019
@faho
Copy link
Member

faho commented Jun 23, 2019

Very nice, merged!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants