aboutsummaryrefslogtreecommitdiff
path: root/bash_completions
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2017-09-18 21:04:04 +0200
committerKarel Kočí <cynerd@email.cz>2017-09-18 21:04:04 +0200
commit39da53ab62b710a231cef8cea50bfa316816f2ad (patch)
tree013b95275afb91d4f8e575f5cf942f3429a61789 /bash_completions
parent04029c520f4cd1c7fbf9444e6ba5304b632d23f4 (diff)
downloadmyconfigs-39da53ab62b710a231cef8cea50bfa316816f2ad.tar.gz
myconfigs-39da53ab62b710a231cef8cea50bfa316816f2ad.tar.bz2
myconfigs-39da53ab62b710a231cef8cea50bfa316816f2ad.zip
Add completions for usbkey
Diffstat (limited to 'bash_completions')
-rw-r--r--bash_completions/usbkey35
1 files changed, 35 insertions, 0 deletions
diff --git a/bash_completions/usbkey b/bash_completions/usbkey
new file mode 100644
index 0000000..10cb0b9
--- /dev/null
+++ b/bash_completions/usbkey
@@ -0,0 +1,35 @@
+# Bash completion file for usbkey
+# vim: ft=sh
+
+_usbkey_mounted() {
+ mount | grep "/media/usbkey" | grep -q "/dev/mapper/usbkey"
+}
+
+_usbkey() {
+ local cur prev
+ _init_completion || return
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ if [[ $COMP_CWORD -gt 1 ]]; then
+ _usbkey_mounted || return
+ case "${COMP_WORDS[1]}" in
+ ssh-import)
+ [ -d "/media/usbkey/ssh" ] || return
+ local keys
+ for F in $(find "/media/usbkey/ssh" -name '*.pub'); do
+ F="${F#/media/usbkey/ssh/}"
+ keys="$keys ${F%.pub}"
+ done
+ COMPREPLY+=($(compgen -W "${keys}" -- ${cur}))
+ ;;
+ esac
+ else
+ local ops="-h --help mount sync"
+ if _usbkey_mounted; then
+ ops="$ops unmount ssh-list ssh-generate ssh-import"
+ fi
+ COMPREPLY+=($(compgen -W "${ops}" -- ${cur}))
+ fi
+}
+
+complete -F _usbkey usbkey