summaryrefslogtreecommitdiff
path: root/.config/zsh/oh-my-zsh/plugins/lxd
diff options
context:
space:
mode:
authorPedro Pereira <pedro.hr.pereira@proton.me>2026-10-16 15:19:13 -0300
committerPedro Pereira <pedro.hr.pereira@proton.me>2026-10-16 15:19:13 -0300
commit1eb69e9a795cc19450178c07d8d382622bc7ad70 (patch)
treeb6bc60605044fe929986f31b3b6bf4fee9b56e14 /.config/zsh/oh-my-zsh/plugins/lxd
first commit
Diffstat (limited to '.config/zsh/oh-my-zsh/plugins/lxd')
-rw-r--r--.config/zsh/oh-my-zsh/plugins/lxd/README.md9
-rw-r--r--.config/zsh/oh-my-zsh/plugins/lxd/lxd.plugin.zsh26
2 files changed, 35 insertions, 0 deletions
diff --git a/.config/zsh/oh-my-zsh/plugins/lxd/README.md b/.config/zsh/oh-my-zsh/plugins/lxd/README.md
new file mode 100644
index 0000000..cea45e3
--- /dev/null
+++ b/.config/zsh/oh-my-zsh/plugins/lxd/README.md
@@ -0,0 +1,9 @@
+# lxd
+
+This plugin provides completion for [lxd](https://linuxcontainers.org/lxd/), as well as aliases
+for frequent lxc commands.
+
+To use it add `lxd` to the plugins array in your zshrc file.
+
+```zsh
+plugins=(... lxd)
diff --git a/.config/zsh/oh-my-zsh/plugins/lxd/lxd.plugin.zsh b/.config/zsh/oh-my-zsh/plugins/lxd/lxd.plugin.zsh
new file mode 100644
index 0000000..a6a0742
--- /dev/null
+++ b/.config/zsh/oh-my-zsh/plugins/lxd/lxd.plugin.zsh
@@ -0,0 +1,26 @@
+_lxc_get_command_list () {
+ $_comp_command1 | sed "1,/Available Commands/d" | awk '/^[ \t]*[a-z]+/ { print $1 }'
+}
+
+_lxc_get_subcommand_list () {
+ $_comp_command1 ${words[2]} | sed "1,/Available Commands/d" | awk '/^[ \t]*[a-z]+/ { print $1 }'
+}
+
+_lxc () {
+ local curcontext="$curcontext" state line
+ typeset -A opt_args
+ _arguments \
+ '1: :->command'\
+ '*: :->args'
+
+ case $state in
+ command)
+ compadd $(_lxc_get_command_list)
+ ;;
+ *)
+ compadd $(_lxc_get_subcommand_list)
+ ;;
+ esac
+}
+
+compdef _lxc lxc