Skip to content

Add FFmpeg completions#5922

Merged
faho merged 2 commits into
fish-shell:masterfrom
sorairolake:FFmpeg
Jun 23, 2019
Merged

Add FFmpeg completions#5922
faho merged 2 commits into
fish-shell:masterfrom
sorairolake:FFmpeg

Conversation

@sorairolake
Copy link
Copy Markdown
Contributor

Add completions for ffmpeg, ffplay and ffprobe.

Comment thread share/completions/ffmpeg.fish Outdated
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

Fixed to use builtin command.

@faho faho merged commit e7b4261 into fish-shell:master Jun 23, 2019
@faho
Copy link
Copy Markdown
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.

2 participants