summaryrefslogtreecommitdiffstats
path: root/office/khal/khal-complete.bash
diff options
context:
space:
mode:
Diffstat (limited to 'office/khal/khal-complete.bash')
-rw-r--r--office/khal/khal-complete.bash29
1 files changed, 29 insertions, 0 deletions
diff --git a/office/khal/khal-complete.bash b/office/khal/khal-complete.bash
new file mode 100644
index 0000000000..1a8fd294fd
--- /dev/null
+++ b/office/khal/khal-complete.bash
@@ -0,0 +1,29 @@
+_khal_completion() {
+ local IFS=$'\n'
+ local response
+
+ response=$(env COMP_WORDS="${COMP_WORDS[*]}" COMP_CWORD=$COMP_CWORD _KHAL_COMPLETE=bash_complete $1)
+
+ for completion in $response; do
+ IFS=',' read type value <<< "$completion"
+
+ if [[ $type == 'dir' ]]; then
+ COMPREPLY=()
+ compopt -o dirnames
+ elif [[ $type == 'file' ]]; then
+ COMPREPLY=()
+ compopt -o default
+ elif [[ $type == 'plain' ]]; then
+ COMPREPLY+=($value)
+ fi
+ done
+
+ return 0
+}
+
+_khal_completion_setup() {
+ complete -o nosort -F _khal_completion khal
+}
+
+_khal_completion_setup;
+