# ln -s bash_completion /etc/bash_completion.d/mdk
# source /etc/bash_completion.d/mdk
+function _gt() {
+ local BIN CUR OPTS
+ BIN="mdk"
+ CUR="${COMP_WORDS[COMP_CWORD]}"
+ OPTS=""
+ if [[ "${COMP_CWORD}" == 1 ]]; then
+ OPTS=$($BIN info -ln 2> /dev/null)
+ fi
+ COMPREPLY=( $(compgen -W "${OPTS}" -- ${CUR}) )
+ return 0
+}
+
function _mdk() {
local BIN CMD CUR PREV OPTS
COMPREPLY=()
return 0
}
+# MDK autocomplete
if [[ -n "$(which mdk)" ]]; then
complete -F _mdk mdk
fi
+
+# Autocomplete for extra/goto_instance
+if [[ -n "$(type -t gt)" ]]; then
+ complete -F _gt gt
+ complete -F _gt gtd
+fi
--- /dev/null
+#
+# Moodle Development Kit
+#
+# Copyright (c) 2013 Frédéric Massart - FMCorz.net
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# http://github.com/FMCorz/mdk
+#
+
+# This file defines a function to quickly go to into an MDK instance.
+#
+# To install on Ubuntu, source this file into your ~/.bashrc file:
+#
+# if [ -f /usr/share/moodle-sdk/extra/goto_instance ]; then
+# . /usr/share/moodle-sdk/extra/goto_instance
+# fi
+#
+# Then source ~/.bashrc:
+#
+# source ~/.bashrc
+#
+
+# Go to instance directory.
+function gt() {
+ DIR=`mdk config show dirs.www`
+ eval DIR="$DIR/$1"
+ if [[ ! -d $DIR ]]; then
+ echo "Could not resolve path"
+ return
+ fi
+ cd "$DIR"
+}
+
+# Go to instance data directory.
+function gtd() {
+ DIR=`mdk config show dirs.storage`
+ DATADIR=`mdk config show dataDir`
+ eval DIR="$DIR/$1/$DATADIR"
+ if [[ ! -d $DIR ]]; then
+ echo "Could not resolve path"
+ return
+ fi
+ cd $DIR
+}
\ No newline at end of file