From 9d6312fb9e90ea4a9341de7eebb430f50df98a80 Mon Sep 17 00:00:00 2001 From: Fabio 'c0m3tx' Vitale Date: Tue, 7 Mar 2017 15:17:41 +0100 Subject: [PATCH] Added simple autocompletion for mongodb databases --- plugins/mongo/load_databases.js | 5 +++++ plugins/mongo/mongo.plugin.zsh | 6 ++++++ 2 files changed, 11 insertions(+) create mode 100644 plugins/mongo/load_databases.js create mode 100644 plugins/mongo/mongo.plugin.zsh diff --git a/plugins/mongo/load_databases.js b/plugins/mongo/load_databases.js new file mode 100644 index 00000000..75b79eda --- /dev/null +++ b/plugins/mongo/load_databases.js @@ -0,0 +1,5 @@ +dbs = db.adminCommand( {listDatabases: 1} ).databases; + +for(var i = 0; i < dbs.length; i++) { + print(dbs[i].name); +} diff --git a/plugins/mongo/mongo.plugin.zsh b/plugins/mongo/mongo.plugin.zsh new file mode 100644 index 00000000..7e6c58f0 --- /dev/null +++ b/plugins/mongo/mongo.plugin.zsh @@ -0,0 +1,6 @@ +_mongodbs() { + mypath=$(dirname $0) + compadd $(mongo --quiet $mypath/load_databases.js) +} +compdef _mongodbs mongo +