Skip to content

Instantly share code, notes, and snippets.

@esod
Last active December 30, 2015 19:49
Show Gist options
  • Save esod/7876678 to your computer and use it in GitHub Desktop.
Save esod/7876678 to your computer and use it in GitHub Desktop.
Quickly change drush versions.
I wrote a bash function so one doesn't have to go to the git repo to manually change drush versions.
Add these lines to your .bash_profile:
# Switch Drush version at will
function switchdrushto() {
local cwd=$(pwd)
local drush_location="/usr/local/drush"
local checkout_version="git checkout $@"
local drush_version="drush --version"
cd $drush_location
eval "$checkout_version"
cd $cwd
echo "#####################"
eval "$drush_version"
}
In the function, you'll need to modify the line:
local drush_location="/usr/local/drush"
to
local drush_location="location/of/your/drush"
Save your .bash_profile and source it. You can then execute the function with:
switchdrushto 5.10.0
or
switchdrushto 6.2.0
or whichever branch you choose.
The function goes to the git repo, changes your drush version and returns you to your original folder. No mess. No muss.
The only downside is you have to remember which tag (ex. 5.10.0, 6.2.0, 7.x-5.9) you want to check out.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment