nshtg / mpv-bash-completion

Featureful Bash completion for the mpv video player. Linux/BSD/OSX.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mpv-bash-completion

Latest release: 3.3.18

AUR package Gentoo package

A script for generating a Bash completion script for the popular mpv video player. It features...

  • Completion for all --options,
  • Type-based completion for --option arguments for choices, flags, integers and floats,
  • Completion for upper/lower bounds for integer- and float-type argument ranges where applicable,
  • Completion of filter lists as arguments to --vf and --af style options as well as completion of filter parameters while composing filter lists,
  • Similarly, parameter completion for video and audio outputs (--vo, --ao),
  • Regular file name completion.

Supported distributions / operating systems

For the distributions listed here, packages have been created and are being actively maintained. For other platforms and distributions, you can build the completion by yourself, see below, as long as the platform can run mpv and the dependencies.

Distribution Repository Package/Port Maintainer Comment
Arch Linux AUR mpv-bash-completion-git @2ion Automatic completion updates via pacman hook
Gentoo Linux, Funtoo Linux Mainline app-shells/mpv-bash-completion @coacher
OpenSuSE Leap, Tumbleweed mpv-bash-completion
macOS Custom homebrew tap @2ion/mpv-bash-completion @2ion See instructions here

Retired packages

There used to be Debian and Ubuntu packages for mpv-bash-completion, but I cannot maintain them any longer. If you're interested, you can get the package source from the debian branch.

Source code

The main repository is on Github.

git clone https://github.com/2ion/mpv-bash-completion.git

Tarballs of tagged releases can be downloaded here.

Dependencies

  • Awk (any awk: gawk, nawk, mawk, etc -- should do)
  • Bash 4
  • Lua 5.1 or 5.2 or 5.3 or LuaJIT
  • mpv >= 0.25

Note on older mpv versions: The mpv command line has changed considerably since version 0.25, making it impossible to support older versions due to the huge number of special cases that would need to be covered. For compatbility with older mpv releases, please use a historic version of mpv-bash-completion.

Optional dependencies

  • xrandr: for dynamic resolution detection and completion under X11 and xwayland

Supporting inputrc configuration

We recommend the following setting for snappier and more luxurious completion experience: To the file ~/.inputrc, add the lines

set blink-matching-paren On
set colored-stats On
set completion-ignore-case On
set show-all-if-ambiguous On
set visible-stats On

Launch a new shell to use the setting.

Enable media file filtering

By default, when you tab-complete an input media file, the completion does not filter media file arguments by extension. You may optionally enable filtering and override the default filter glob expression.

You may set the following shell variables to control this functionality (for example, in ~/.bashrc or ~/.bash_profile). It doesn't matter if the variables are set before or after the Bash completion code is loaded.

# Enable filtering.
_mpv_use_media_globexpr=1

# Override the default media glob expression.
# Display the default value using `echo $_mpv_media_globexpr`.
_mpv_media_globexpr='@(mkv)'

You should have extglob enabled for the default filter to work correctly (e.g. in ~/.bashrc):

shopt -s extglob

Installation

You can just generate the completion script or build a package for one of the supported platforms.

Platform-agnostic method

# You may set the following environment variables beforehand:
# export MPV_BASHCOMPGEN_VERBOSE=1 # verbose debug/progress output
# export MPV_BASHCOMPGEN_MPV_CMD=mpv # path or command to execute mpv, defaults to 'mpv'

./gen.lua > mpv.sh
source ./mpv.sh

Homebrew

Note: Since I do not have access to a Mac computer anymore, I cannot maintain this formula any longer. I am leaving it here for the time being hoping it is still working.

You can simply install using the provided formula. You need to reinstall every time you upgrade mpv in order to update the completion function to match the current mpv build.

brew tap 2ion/mpv-bash-completion https://github.com/2ion/mpv-bash-completion.git
brew install --HEAD mpv-bash-completion

About

Featureful Bash completion for the mpv video player. Linux/BSD/OSX.

License:GNU General Public License v3.0


Languages

Language:Lua 95.7%Language:Makefile 2.3%Language:Ruby 2.0%