diff options
author | Karel Kočí <cynerd@email.cz> | 2017-09-18 21:04:04 +0200 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2017-09-18 21:04:04 +0200 |
commit | 39da53ab62b710a231cef8cea50bfa316816f2ad (patch) | |
tree | 013b95275afb91d4f8e575f5cf942f3429a61789 /zsh_completions/usbkey | |
parent | 04029c520f4cd1c7fbf9444e6ba5304b632d23f4 (diff) | |
download | myconfigs-39da53ab62b710a231cef8cea50bfa316816f2ad.tar.gz myconfigs-39da53ab62b710a231cef8cea50bfa316816f2ad.tar.bz2 myconfigs-39da53ab62b710a231cef8cea50bfa316816f2ad.zip |
Add completions for usbkey
Diffstat (limited to 'zsh_completions/usbkey')
-rw-r--r-- | zsh_completions/usbkey | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/zsh_completions/usbkey b/zsh_completions/usbkey new file mode 100644 index 0000000..0de1375 --- /dev/null +++ b/zsh_completions/usbkey @@ -0,0 +1,48 @@ +#compdef usbkey +#autoload + +_usbkey_mounted() { + mount | grep "/media/usbkey" | grep -q "/dev/mapper/usbkey" +} + +_usbkey () { + local cmd + if (( CURRENT > 2)); then + _usbkey_mounted || return + operation=${words[2]} + # Run the completion for the subcommand + case "${operation}" 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+=("${F%.pub}") + done + _describe -t keys 'usbkey' keys + ;; + # TODO + esac + else + local operations=( + "mount:Mount key of usb driver" + "unmount:Unmount usb driver" + "sync:Synchronize drive to bakup drive" + ) + if _usbkey_mounted; then + operations+=( + "gpg-import:Import gpg key" + "ssh-import:Import ssh key" + "ssh-generate:Generate new ssh key" + "ssh-list:List all keys in store" + "openvpn-list:List all keys" + "openvpn-get:Get keys for some host" + "openvpn-generate:Generate key for new host" + ) + fi + _describe -t operations 'usbkey' operations + _arguments : "--help[Output help message]" + fi +} + +_usbkey |