summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-10-25 01:05:50 +0200
committeremkael <emkael@tlen.pl>2016-10-25 01:05:50 +0200
commit817ac4550e149c91f007417cb43dcc80d28dbd5d (patch)
tree18bdd88cc3b86058203b94dd784ddda378938a95
parentb65598d80c891b95b61cb023a47cf6d3f9f9194c (diff)
* bash autocomplete script for backend-run
-rw-r--r--.bash_completion1
-rw-r--r--.envrc1
-rwxr-xr-xbin/list-backend-scripts3
-rwxr-xr-xbin/load-bash-autocomplete12
4 files changed, 17 insertions, 0 deletions
diff --git a/.bash_completion b/.bash_completion
new file mode 100644
index 0000000..12c4029
--- /dev/null
+++ b/.bash_completion
@@ -0,0 +1 @@
+complete -C list-backend-scripts backend-run
diff --git a/.envrc b/.envrc
index 234188d..d4ebc7e 100644
--- a/.envrc
+++ b/.envrc
@@ -1 +1,2 @@
PATH_add bin
+load-bash-autocomplete
diff --git a/bin/list-backend-scripts b/bin/list-backend-scripts
new file mode 100755
index 0000000..7f91060
--- /dev/null
+++ b/bin/list-backend-scripts
@@ -0,0 +1,3 @@
+#!/bin/bash
+DIR=$(dirname $0)
+find "$DIR/../app/backend" -maxdepth 1 -name \*.py -printf '%f\n' | sed 's/\.py$//' | grep "^$2"
diff --git a/bin/load-bash-autocomplete b/bin/load-bash-autocomplete
new file mode 100755
index 0000000..53c50fb
--- /dev/null
+++ b/bin/load-bash-autocomplete
@@ -0,0 +1,12 @@
+#!/bin/bash
+if [ -f ~/.bash_completion ]; then
+ cat .bash_completion | while read LINE
+ do
+ grep -q "$LINE" ~/.bash_completion || {
+ echo "$LINE" >> ~/.bash_completion
+ echo 'added "'$LINE'" to .bash_completion, reload your shell to use auto-complete'
+ }
+ done
+else
+ cp .bash_completion ~/.bash_completion
+fi