summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brulhart2019-05-31 18:40:57 +0200
committerSimon Brulhart2019-05-31 18:40:57 +0200
commit5aa7a1cb48412b72a0edde84b10849bf5073bb92 (patch)
treeff921997509eb84e68bef535349a064fa75141a0
parent58fc5ab4c0739616c929d3f4ab3f5592e36dc0d3 (diff)
downloadaur-5aa7a1cb48412b72a0edde84b10849bf5073bb92.tar.gz
Add bash/zsh completion
-rw-r--r--.SRCINFO6
-rw-r--r--PKGBUILD19
-rw-r--r--taxi-complete.bash21
-rw-r--r--taxi-complete.zsh30
4 files changed, 72 insertions, 4 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 8afbf7757ce5..b8268c2a4576 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,7 +1,7 @@
pkgbase = python-taxi
pkgdesc = Timesheeting tool that focuses on simplicity
pkgver = 4.5.1
- pkgrel = 1
+ pkgrel = 2
url = https://github.com/sephii/taxi
arch = any
license = custom
@@ -12,7 +12,11 @@ pkgbase = python-taxi
depends = python-six
optdepends = python-taxi-zebra: Zebra backend for Taxi
source = python-taxi-4.5.1.tar.gz::https://github.com/sephii/taxi/archive/4.5.1.tar.gz
+ source = taxi-complete.bash
+ source = taxi-complete.zsh
sha512sums = 963e0c7bdc2eb273b65833d6cfecb08613a348767c2c65e421ff5dedc073f014855a22b291fb45795bd7005758d75e830e4c6650fed65ee08d93fef82993cacf
+ sha512sums = 646ac547f52fb9a1c8498a9d1d431a3c19b41faacd86b7344ffb8c2334e6b01b765945882e5180c7f658b8c3f6a7887a690171b624326b5b3fa3ecda59344ccc
+ sha512sums = d02c0e3489dba8841eff335571088b739911d4c541623971cfef9b1628ea6960ad748e1e6c4cc1dfdd20dc88fc289f8078dbb51fa0402eed4868c45e87f4106a
pkgname = python-taxi
diff --git a/PKGBUILD b/PKGBUILD
index 304dafac6dfc..3025ef23d6e8 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -2,7 +2,7 @@
pkgname='python-taxi'
pkgver=4.5.1
-pkgrel=1
+pkgrel=2
pkgdesc="Timesheeting tool that focuses on simplicity"
arch=('any')
license=('custom')
@@ -10,8 +10,14 @@ url="https://github.com/sephii/taxi"
depends=('python-appdirs' 'python-click' 'python-six')
makedepends=('python' 'python-setuptools')
optdepends=("python-taxi-zebra: Zebra backend for Taxi")
-source=("$pkgname-$pkgver.tar.gz::https://github.com/sephii/taxi/archive/$pkgver.tar.gz")
-sha512sums=('963e0c7bdc2eb273b65833d6cfecb08613a348767c2c65e421ff5dedc073f014855a22b291fb45795bd7005758d75e830e4c6650fed65ee08d93fef82993cacf')
+source=(
+ "$pkgname-$pkgver.tar.gz::https://github.com/sephii/taxi/archive/$pkgver.tar.gz"
+ taxi-complete.bash
+ taxi-complete.zsh
+)
+sha512sums=('963e0c7bdc2eb273b65833d6cfecb08613a348767c2c65e421ff5dedc073f014855a22b291fb45795bd7005758d75e830e4c6650fed65ee08d93fef82993cacf'
+ '646ac547f52fb9a1c8498a9d1d431a3c19b41faacd86b7344ffb8c2334e6b01b765945882e5180c7f658b8c3f6a7887a690171b624326b5b3fa3ecda59344ccc'
+ 'd02c0e3489dba8841eff335571088b739911d4c541623971cfef9b1628ea6960ad748e1e6c4cc1dfdd20dc88fc289f8078dbb51fa0402eed4868c45e87f4106a')
build() {
cd "$srcdir/taxi-$pkgver"
@@ -22,4 +28,11 @@ package() {
cd "$srcdir/taxi-$pkgver"
python setup.py install --root="$pkgdir" --optimize=1
install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
+
+ cd "$srcdir"
+ # Completion file is generated by running `_TAXI_COMPLETE=source taxi > taxi-complete.bash`
+ install -Dm644 taxi-complete.bash "$pkgdir"/usr/share/bash-completion/completions/taxi
+ # Completion file is generated by running `_TAXI_COMPLETE=source_zsh taxi > taxi-complete.zsh`
+ # and adding `#compdef taxi` on the first line
+ install -Dm644 taxi-complete.zsh "$pkgdir"/usr/share/zsh/site-functions/_taxi
}
diff --git a/taxi-complete.bash b/taxi-complete.bash
new file mode 100644
index 000000000000..344818505527
--- /dev/null
+++ b/taxi-complete.bash
@@ -0,0 +1,21 @@
+_taxi_completion() {
+ local IFS=$'
+'
+ COMPREPLY=( $( env COMP_WORDS="${COMP_WORDS[*]}" \
+ COMP_CWORD=$COMP_CWORD \
+ _TAXI_COMPLETE=complete $1 ) )
+ return 0
+}
+
+_taxi_completionetup() {
+ local COMPLETION_OPTIONS=""
+ local BASH_VERSION_ARR=(${BASH_VERSION//./ })
+ # Only BASH version 4.4 and later have the nosort option.
+ if [ ${BASH_VERSION_ARR[0]} -gt 4 ] || ([ ${BASH_VERSION_ARR[0]} -eq 4 ] && [ ${BASH_VERSION_ARR[1]} -ge 4 ]); then
+ COMPLETION_OPTIONS="-o nosort"
+ fi
+
+ complete $COMPLETION_OPTIONS -F _taxi_completion taxi
+}
+
+_taxi_completionetup;
diff --git a/taxi-complete.zsh b/taxi-complete.zsh
new file mode 100644
index 000000000000..6af1e3e2e46e
--- /dev/null
+++ b/taxi-complete.zsh
@@ -0,0 +1,30 @@
+#compdef taxi
+
+_taxi_completion() {
+ local -a completions
+ local -a completions_with_descriptions
+ local -a response
+ response=("${(@f)$( env COMP_WORDS="${words[*]}" \
+ COMP_CWORD=$((CURRENT-1)) \
+ _TAXI_COMPLETE="complete_zsh" \
+ taxi )}")
+
+ for key descr in ${(kv)response}; do
+ if [[ "$descr" == "_" ]]; then
+ completions+=("$key")
+ else
+ completions_with_descriptions+=("$key":"$descr")
+ fi
+ done
+
+ if [ -n "$completions_with_descriptions" ]; then
+ _describe -V unsorted completions_with_descriptions -U -Q
+ fi
+
+ if [ -n "$completions" ]; then
+ compadd -U -V unsorted -Q -a completions
+ fi
+ compstate[insert]="automenu"
+}
+
+compdef _taxi_completion taxi;