mirror of
https://github.com/beetbox/beets.git
synced 2025-12-07 00:53:08 +01:00
Merge pull request #5081 from mthies-unibi/zsh-completion-fixes
Fixes zsh completion dependency on specific awk/sed/sqlite3 versions and settings
This commit is contained in:
commit
ddb34de72a
2 changed files with 8 additions and 3 deletions
|
|
@ -281,6 +281,10 @@ Bug fixes:
|
||||||
displayed unless the detail configuration is enabled.
|
displayed unless the detail configuration is enabled.
|
||||||
* :doc:`/plugins/web`: Fix range request support, allowing to play large audio/
|
* :doc:`/plugins/web`: Fix range request support, allowing to play large audio/
|
||||||
opus files using e.g. a browser/firefox or gstreamer/mopidy directly.
|
opus files using e.g. a browser/firefox or gstreamer/mopidy directly.
|
||||||
|
* Fix bug where `zsh` completion script made assumptions about the specific
|
||||||
|
variant of `awk` installed and required specific settings for `sqlite3`
|
||||||
|
and caching in `zsh`.
|
||||||
|
:bug:`3546`
|
||||||
|
|
||||||
For plugin developers:
|
For plugin developers:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@ local BEETS_LIBRARY=~/.config/beets/library.db
|
||||||
local BEETS_CONFIG=~/.config/beets/config.yaml
|
local BEETS_CONFIG=~/.config/beets/config.yaml
|
||||||
# Use separate caches for file locations, command completions, and query completions.
|
# Use separate caches for file locations, command completions, and query completions.
|
||||||
# This allows the use of different rules for when to update each one.
|
# This allows the use of different rules for when to update each one.
|
||||||
zstyle ":completion:${curcontext}:" cache-policy _beet_check_cache
|
zstyle ":completion:${curcontext%:*}:*" cache-policy _beet_check_cache
|
||||||
|
zstyle ":completion:${curcontext%:*}:*" use-cache true
|
||||||
_beet_check_cache () {
|
_beet_check_cache () {
|
||||||
local cachefile="$(basename ${1})"
|
local cachefile="$(basename ${1})"
|
||||||
if [[ ! -a "${1}" ]] || [[ "${1}" -ot =beet ]]; then
|
if [[ ! -a "${1}" ]] || [[ "${1}" -ot =beet ]]; then
|
||||||
|
|
@ -51,7 +52,7 @@ if ! _retrieve_cache beetscmds || _cache_invalid beetscmds; then
|
||||||
# Useful function for joining grouped lines of output into single lines (taken from _completion_helpers)
|
# Useful function for joining grouped lines of output into single lines (taken from _completion_helpers)
|
||||||
_join_lines() {
|
_join_lines() {
|
||||||
awk -v SEP="$1" -v ARG2="$2" -v START="$3" -v END2="$4" 'BEGIN {if(START==""){f=1}{f=0};
|
awk -v SEP="$1" -v ARG2="$2" -v START="$3" -v END2="$4" 'BEGIN {if(START==""){f=1}{f=0};
|
||||||
if(ARG2 ~ "^[0-9]+"){LINE1 = "^[[:space:]]{,"ARG2"}[^[:space:]]"}else{LINE1 = ARG2}}
|
if(ARG2 ~ "^[0-9]+"){LINE1 = "^[[:space:]]{0,"ARG2"}[^[:space:]]"}else{LINE1 = ARG2}}
|
||||||
($0 ~ END2 && f>0 && END2!="") {exit}
|
($0 ~ END2 && f>0 && END2!="") {exit}
|
||||||
($0 ~ START && f<1) {f=1; if(length(START)!=0){next}}
|
($0 ~ START && f<1) {f=1; if(length(START)!=0){next}}
|
||||||
($0 ~ LINE1 && f>0) {if(f<2){f=2; printf("%s",$0)}else{printf("\n%s",$0)}; next}
|
($0 ~ LINE1 && f>0) {if(f<2){f=2; printf("%s",$0)}else{printf("\n%s",$0)}; next}
|
||||||
|
|
@ -109,7 +110,7 @@ _beet_field_values() {
|
||||||
if [[ "$(sqlite3 ${~BEETS_LIBRARY} ${sqlcmd} 2>&1)" =~ "no such column" ]]; then
|
if [[ "$(sqlite3 ${~BEETS_LIBRARY} ${sqlcmd} 2>&1)" =~ "no such column" ]]; then
|
||||||
sqlcmd="select distinct value from item_attributes where key=='$1' and value!='';"
|
sqlcmd="select distinct value from item_attributes where key=='$1' and value!='';"
|
||||||
fi
|
fi
|
||||||
output="$(sqlite3 ${~BEETS_LIBRARY} ${sqlcmd} 2>/dev/null | sed -rn '/^-+$/,${{/^[- ]+$/n};p}')"
|
output="$(sqlite3 -list -noheader ${~BEETS_LIBRARY} ${sqlcmd} 2>/dev/null)"
|
||||||
fieldvals=("${(f)output[@]}")
|
fieldvals=("${(f)output[@]}")
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue