From ac4a2b6606047f4a3ee548e2afb1364104c07eaa Mon Sep 17 00:00:00 2001 From: Jannik Hoffjann Date: Fri, 5 Jul 2019 12:04:13 +0200 Subject: [PATCH] Remove broken rule --- .pre-commit-config.yaml | 10 +--------- auto_completion.sh | 28 ++++++++++++++++++++++++++++ setup.py | 13 +++++++++++++ 3 files changed, 42 insertions(+), 9 deletions(-) create mode 100755 auto_completion.sh diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ff3f1a9e..4159d694 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,12 +12,4 @@ repos: - id: check-merge-conflict - id: check-yaml - id: trailing-whitespace - exclude: .*\.md$ -- repo: local - hooks: - - id: shell-lint - name: Shell Syntax Check - description: Check Shell Syntax on ALL staged files with user friendly messages and colors - entry: .pre-commit-hooks/shell-lint.sh - language: script - types: [shell] \ No newline at end of file + exclude: .*\.md$ \ No newline at end of file diff --git a/auto_completion.sh b/auto_completion.sh new file mode 100755 index 00000000..2dc64992 --- /dev/null +++ b/auto_completion.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# Inspired by: https://qone.io/python/bash/zsh/2016/04/24/python-click-auto-complete-bash-zsh.html + +if [[ $(basename $SHELL) = 'bash' ]]; +then + if [[ -f ~/.bashrc ]]; + then + echo "Installing bash autocompletion..." + grep -q 'esque-autocompletion' ~/.bashrc + if [[ $? -ne 0 ]]; then + echo "" >> ~/.bashrc + echo 'eval "$(_ESQUE_COMPLETE=source esque)"' >> ~/.esque-autocompletion.sh + echo "source ~/.esque-autocompletion.sh" >> ~/.bashrc + fi + fi +elif [[ $(basename $SHELL) = 'zsh' ]]; +then + if [[ -f ~/.zshrc ]]; + then + echo "Installing zsh autocompletion..." + grep -q 'esque-autocompletion' ~/.zshrc + if [[ $? -ne 0 ]]; then + echo "" >> ~/.zshrc + echo 'eval "$(_ESQUE_COMPLETE=source_zsh esque)"' >> ~/.esque-autocompletion.zsh + echo "source ~/.esque-autocompletion.zsh" >> ~/.zshrc + fi + fi +fi \ No newline at end of file diff --git a/setup.py b/setup.py index 8cdfac62..43bc455d 100644 --- a/setup.py +++ b/setup.py @@ -3,8 +3,10 @@ import codecs import os import sys +from subprocess import call from setuptools import find_packages, setup +from setuptools.command.install import install here = os.path.abspath(os.path.dirname(__file__)) @@ -31,6 +33,16 @@ "pyyaml", ] + +class PostInstallCommand(install): + """Post-installation for installation mode.""" + + def run(self): + install.run(self) + print("installing auto completion") + call(["./auto_completion.sh"]) + + setup( name="esque", version=about["__version__"], @@ -61,4 +73,5 @@ "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", ], + cmdclass={"install": PostInstallCommand}, )