-
-
Save KeyboardCowboy/5110970 to your computer and use it in GitHub Desktop.
Quick directory traversal with Drush Aliases and Bash.Do you use drush aliases? Drip this little snippet into your .bash_profile or .bash_rc and start saving bucketloads of time.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
# Quick directory change for drush. | |
# While inside a Drupal site, simply cdd to a module or theme by name. | |
# Add an alias to quickly jump to that site's root or any theme or module within that site | |
# | |
# EX. | |
# $ cdd zen (takes you to zen theme within current Drupal site) | |
# $ cdd @mysite (takes to you mysite root) | |
# $ cdd @mysite zen (takes you to zen theme in mysite from anywhere on the server) | |
## | |
function cdd { | |
# Derrive the path | |
if [ -z $1 ]; then | |
GO=`drush dd` | |
elif [ -n $1 ] && [ -z $2 ] && [ ${1:0:1} != "@" ]; then | |
GO=`drush dd $1` | |
elif [ -n $1 ] && [ -z $2 ] && [ ${1:0:1} == "@" ]; then | |
GO=`drush $1 dd` | |
elif [ -n $1 ] && [ -n $2 ] && [ ${1:0:1} == "@" ]; then | |
GO=`drush $1 dd $2` | |
fi | |
# Make sure we have a legit path before we try to change dir. | |
if [ -n "$GO" ] && [ -d $GO ]; then | |
cd $GO | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment