Skip to content

Instantly share code, notes, and snippets.

@zachharkey
Created August 14, 2013 22:02
Show Gist options
  • Save zachharkey/6236110 to your computer and use it in GitHub Desktop.
Save zachharkey/6236110 to your computer and use it in GitHub Desktop.
foo
# Works just like the `cd` shell alias above, with one additional
# feature: `cdd @remote-site` works like `ssh @remote-site`,
# whereas cd above will fail unless the site alias is local. If
# you prefer the `ssh` behavior, you can rename this shell alias
# to `cd`.
function cdd() {
s="$1"
if [ -z "$s" ]
then
builtin cd
elif [ "${s:0:1}" == "@" ] || [ "${s:0:1}" == "%" ]
then
d="$(drush drupal-directory $s 2>/dev/null)"
$(drush sa ${s%%:*} --component=remote-host > /dev/null 2>&1)
if [ $? != 0 ]
then
echo "cd $d"
builtin cd "$d"
else
if [ -n "$d" ]
then
c="cd \"$d\" \; bash"
drush -s ${s%%:*} ssh --tty --escaped "$c"
drush ${s%%:*} ssh --tty --escaped "$c"
else
drush ssh ${s%%:*}
fi
fi
else
builtin cd "$s"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment