Skip to content

Instantly share code, notes, and snippets.

@mmxcrono
Last active March 1, 2024 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmxcrono/a9f2dee4a43a53cdb6c4e1d2d056afc7 to your computer and use it in GitHub Desktop.
Save mmxcrono/a9f2dee4a43a53cdb6c4e1d2d056afc7 to your computer and use it in GitHub Desktop.
Add terminal colors, git branch name, convenient aliases to your ~/.bashrc file
# --------------
# Functions
# --------------
# Parse branch name and format output
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
# Switch to main or a new branch based on current one
get() {
if [ -z $1 ]; then
git checkout main
else
git switch "ASEO-$1" 2>/dev/null || git switch -c "ASEO-$1" || git checkout "ASEO-$1";
fi
}
# Enter bash terminal for specified docker container name
# Use ctrl + d to log out as usual
ds() {
if [ -z $1 ]; then
echo docker container name is required
return 1
else
docker exec -it $1 bash
fi
}
# Sync with ti repos
tisync() {
gh repo sync mmxcrono/marketplace -b qa
gh repo sync mmxcrono/ti-infrastructure-code -b master
}
# --------------
# Aliases
# --------------
# List
alias ls='ls $LS_OPTIONS'
alias ll='ls -lah $LS_OPTIONS'
# Git Push
alias gp='git push -u origin HEAD'
# Mac Brew
alias brew='/opt/homebrew/bin/brew'
alias phpunit='./vendor/bin/phpunit'
# --------------
# Exports
# --------------
# Show git branch in prompt
export PS1="\u@\h \[\e[32m\]\w \[\e[91m\]\$(parse_git_branch)\[\e[00m\]$ "
# Colors for files/folders
export LS_OPTIONS='--color=auto'
export VOLTA_HOME="$HOME/.volta"
export PATH="$VOLTA_HOME/bin:$PATH"
export PATH="/usr/local/bin:$PATH"
export PATH="/usr/bin:$PATH"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment