Created
March 20, 2019 08:06
-
-
Save mathiaswking/0c88e1ecf01bbace23f88978be409530 to your computer and use it in GitHub Desktop.
The current bash setup
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
export ANDROID_HOME=~/android/android-sdk | |
export ANDROID_NDK=~/android/android-ndk-r10e | |
export ANDROID_NM=arm-linux-androideabi-nm | |
export PATH=$ANDROID_HOME/platform-tools/:$ANDROID_HOME/tools:$ANDROID_NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/bin:$PATH | |
DEFOLDDIR=~/work/defold | |
cd $DEFOLDDIR | |
alias defoldshell="$DEFOLDDIR/scripts/build.py shell" | |
alias eclipse="/Applications/eclipse/eclipse -vm /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java &" | |
alias android-nm="arm-linux-androideabi-nm" | |
alias android-addr2line="arm-linux-androideabi-addr2line" | |
alias android-strip="arm-linux-androideabi-strip" | |
alias android-ldd="${ANDROID_NDK}/ndk-depends" | |
alias rg="rg -i" | |
alias sha256="shasum -a256 -b" | |
alias sha512="shasum -a512 -b" | |
alias vscode="code" | |
alias jdk8="export JAVA_HOME=`/usr/libexec/java_home -v 1.8.0_60`" | |
alias jdk11="export JAVA_HOME=`/usr/libexec/java_home -v 11.0.2`" | |
function gitfind() { | |
local pattern=$1 | |
git reflog stash -- "*${pattern}*" | |
} | |
alias stashgrep="git stash list -G" | |
alias stashfind=gitfind | |
alias md5_dir="_mychecksum_md5" | |
_mychecksum_md5() { | |
tar c $1 | md5 | |
} | |
alias tree_size="_tree_size" | |
_tree_size() { | |
find $1 -type f | xargs du -ha | /usr/local/opt/coreutils/libexec/gnubin/sort -rh | |
} | |
alias mygrep="_mygrep" | |
_mygrep() { | |
PATTERN=$1 | |
shift | |
grep -r -e "$PATTERN" $* . | |
} | |
if [ -f $(brew --prefix)/etc/bash_completion ]; then | |
. $(brew --prefix)/etc/bash_completion | |
fi | |
#export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\] \[\033[33;1m\]\w\[\033[m\] (\$(git branch 2>/dev/null | grep '^*' | colrm 1 2)) ${IS_DYNAMO_HOME_SET}\$ " | |
RED="\[\033[0;31m\]" | |
YELLOW="\[\033[1;33m\]" | |
GREEN="\[\033[0;32m\]" | |
BLUE="\[\033[1;34m\]" | |
LIGHT_RED="\[\033[1;31m\]" | |
LIGHT_GREEN="\[\033[1;32m\]" | |
WHITE="\[\033[1;37m\]" | |
LIGHT_GRAY="\[\033[0;37m\]" | |
COLOR_NONE="\[\e[0m\]" | |
# https://misc.flogisoft.com/bash/tip_colors_and_formatting | |
IS_DYNAMO_HOME_SET="" | |
if [ "${DYNAMO_HOME}" == "" ]; then | |
# Red | |
IS_DYNAMO_HOME_SET="\e[31mNO DYNAMO_HOME!${COLOR_NONE} " | |
fi | |
function is_git_repository { | |
git branch > /dev/null 2>&1 | |
} | |
# Determine the branch/state information for this git repository. | |
function set_git_branch { | |
# Capture the output of the "git status" command. | |
git_status="$(git status 2> /dev/null)" | |
# Set color based on clean/staged/dirty. | |
if [[ ${git_status} =~ "working directory clean" ]]; then | |
state="${GREEN}" | |
elif [[ ${git_status} =~ "Changes to be committed" ]]; then | |
state="${YELLOW}" | |
else | |
state="${LIGHT_RED}" | |
fi | |
# Set arrow icon based on status against remote. | |
remote_pattern="# Your branch is (.*) of" | |
if [[ ${git_status} =~ ${remote_pattern} ]]; then | |
if [[ ${BASH_REMATCH[1]} == "ahead" ]]; then | |
remote="↑" | |
else | |
remote="↓" | |
fi | |
else | |
remote="" | |
fi | |
diverge_pattern="# Your branch and (.*) have diverged" | |
if [[ ${git_status} =~ ${diverge_pattern} ]]; then | |
remote="↕" | |
fi | |
# Get the name of the branch. | |
branch_pattern="^(# )?On branch ([^${IFS}]*)" | |
if [[ ${git_status} =~ ${branch_pattern} ]]; then | |
branch=${BASH_REMATCH[2]} | |
fi | |
# Set the final branch string. | |
BRANCH="${state}(${branch})${remote}${COLOR_NONE} " | |
} | |
function set_bash_prompt () { | |
# Set the PROMPT_SYMBOL variable. We do this first so we don't lose the | |
# return value of the last command. | |
set_prompt_symbol $? | |
# Set the PYTHON_VIRTUALENV variable. | |
set_virtualenv | |
# Set the BRANCH variable. | |
if is_git_repository ; then | |
set_git_branch | |
else | |
BRANCH='' | |
fi | |
# Set the bash prompt variable. | |
PS1=" | |
${PYTHON_VIRTUALENV}${GREEN}\u ${YELLOW}\w${COLOR_NONE} ${BRANCH} ${IS_DYNAMO_HOME_SET} | |
${PROMPT_SYMBOL} " | |
} | |
function set_prompt_symbol () { | |
if test $1 -eq 0 ; then | |
PROMPT_SYMBOL="\$" | |
else | |
PROMPT_SYMBOL="${LIGHT_RED}\$${COLOR_NONE}" | |
fi | |
} | |
# Determine active Python virtualenv details. | |
function set_virtualenv () { | |
if test -z "$VIRTUAL_ENV" ; then | |
PYTHON_VIRTUALENV="" | |
else | |
PYTHON_VIRTUALENV="${BLUE}[`basename \"$VIRTUAL_ENV\"`]${COLOR_NONE} " | |
fi | |
} | |
# Tell bash to execute this function just before displaying its prompt. | |
PROMPT_COMMAND=set_bash_prompt | |
export PATH="$HOME/.cargo/bin:$PATH" | |
export JAVA_HOME=$(/usr/libexec/java_home -v 11.0.2) | |
export ANDROID_HOME="~/android" | |
export ANDROID_NDK="~/android/android-ndk-r10e" | |
export PATH="${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/bin:$PATH" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment