Last active
February 13, 2018 03:11
-
-
Save dyspop/f8b468a3e210eb9d2b702e6c7e930bb2 to your computer and use it in GitHub Desktop.
Fun and useful terminal prompt with autoenv
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
#!/bin/bash | |
alias ll='ls -hartlG' | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' | |
} | |
export PS1="🤖 \h\n👤 \u\n📁 \w\n🌳 \$(parse_git_branch)\n🤘 " | |
function cd { | |
# check for and deactivate the bin/activate before we exit | |
if [ -f */bin/activate ] ; then | |
# but only deactivate if we are not in a subdirectory of the virtual env | |
# we do this by checking to see if we're in a filesystem directory | |
if ! [ "$(df -P . | awk 'NR==2 {print $6}')" = ${@} ] ; then | |
deactivate | |
fi | |
fi | |
# change directory to the path given | |
builtin cd "$@" | |
# check for and activate after changing directory | |
if [ -f */bin/activate ] ; then | |
source */bin/activate | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment