Created
October 3, 2018 22:02
-
-
Save NZSmartie/caa8cd3500f349df3aa57491c365d76d to your computer and use it in GitHub Desktop.
Sets up your IDF_PATH and PATH for use with ESP32 development. also provides `deactivate` function to cleanup
This file contains hidden or 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 | |
_PRE_IDF_PATH=$PATH | |
_PRE_IDF_PS1=$PS1 | |
_PWD=$(dirname $(realpath $BASH_SOURCE)) | |
export PATH=$PATH:$_PWD/xtensa-esp32-elf/bin | |
export IDF_PATH=$_PWD/esp-idf | |
parse_git_branch () { | |
git -C $IDF_PATH symbolic-ref HEAD --short 2>/dev/null | |
} | |
parse_git_tag () { | |
git -C $IDF_PATH describe --tags 2> /dev/null | |
} | |
parse_git_branch_or_tag() { | |
local OUT="$(parse_git_branch)" | |
if [ -z "$OUT" ]; then | |
OUT="$(parse_git_tag)"; | |
elif [ -z "$OUT" ]; then | |
OUT="empty" | |
fi | |
echo $OUT | |
} | |
export PS1="(esp-idf: $(parse_git_branch_or_tag)) "$PS1 | |
deactivate() { | |
export PATH=$_PRE_IDF_PATH | |
export PS1=$_PRE_IDF_PS1 | |
unset _PRE_IDF_PATH | |
unset _PRE_IDF_PS1 | |
unset IDF_PATH | |
unset -f deactivate # Remove this function | |
} | |
unset _PWD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment