Last active
December 26, 2015 03:08
-
-
Save peterjaap/7083400 to your computer and use it in GitHub Desktop.
See which branch you are on immediately after entering a directory with a Git repository. Add this piece of code to your ~/.bash_profile file to run 'git branch' every time you enter a directory with a Git repository. You can comment out line 5 if you do not want to show the Magento version that is being used, if found.
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
function runOnFolderEntry() { | |
if [ "$PWD" != "$MYOLDPWD" ]; then | |
MYOLDPWD="$PWD"; | |
showGitBranch ${MYOLDPWD}; | |
showMagentoVersion ${MYOLDPWD}; | |
fi | |
} | |
function showGitBranch() { | |
if [ -d "$1/.git" ]; then | |
git branch | |
fi | |
} | |
function showMagentoVersion() { | |
if [ -f "$1/app/Mage.php" ]; then | |
php -r "include '$1/app/Mage.php'; echo 'Magento version ' . Mage::getVersion(); echo \"\n\";" | |
fi | |
} | |
export PROMPT_COMMAND=runOnFolderEntry |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment