diff --git a/lib/bashrc.d/docker_aliases.shared b/lib/bashrc.d/docker_aliases.shared index 7da3cbf..8c0bcff 100644 --- a/lib/bashrc.d/docker_aliases.shared +++ b/lib/bashrc.d/docker_aliases.shared @@ -7,35 +7,40 @@ if [ -n "$UTOOLS_DOCKER_ALIASES" ]; then # alias dm=docker-machine #fi function dm() { - if [ "$1" == use -a -n "$2" -a -f ~/etc/default/dk ]; then - # chercher les aliases éventuels - local machine="$2"; shift; shift - machine="$( - CLUSTERDIRS=() - DM_ALIASES=() - source ~/etc/default/dk - for alias_machine in "${DM_ALIASES[@]}"; do - if [ "${alias_machine%%:*}" == "$machine" ]; then - echo "${alias_machine#*:}" - exit - fi - done - for clusterdir in "${CLUSTERDIRS[@]}"; do - if [ -f "$clusterdir/0config/configure.conf" ]; then - DM_ALIASES=() - source "$clusterdir/0config/configure.conf" - for alias_machine in "${DM_ALIASES[@]}"; do - if [ "${alias_machine%%:*}" == "$machine" ]; then - echo "${alias_machine#*:}" - exit - fi - done - fi - done - echo "$machine" - )" - set -- use "$machine" "$@" + case "$1" in + use|ssh) + if [ -n "$2" -a -f ~/etc/default/dk ]; then + # chercher les aliases éventuels + local cmd="$1"; shift + local machine="$1"; shift + machine="$( + CLUSTERDIRS=() + DM_ALIASES=() + source ~/etc/default/dk + for alias_machine in "${DM_ALIASES[@]}"; do + if [ "${alias_machine%%:*}" == "$machine" ]; then + echo "${alias_machine#*:}" + exit fi + done + for clusterdir in "${CLUSTERDIRS[@]}"; do + if [ -f "$clusterdir/0config/configure.conf" ]; then + DM_ALIASES=() + source "$clusterdir/0config/configure.conf" + for alias_machine in "${DM_ALIASES[@]}"; do + if [ "${alias_machine%%:*}" == "$machine" ]; then + echo "${alias_machine#*:}" + exit + fi + done + fi + done + echo "$machine" +)" + set -- "$cmd" "$machine" "$@" + fi + ;; + esac if [ "$DOCKER_MACHINE_WRAPPED" == true ]; then __docker_machine_wrapper "$@" else