Skip to content

Instantly share code, notes, and snippets.

@ppdeassis
Last active January 26, 2020 19:31
Show Gist options
  • Save ppdeassis/349bea0b0997ea4eab23 to your computer and use it in GitHub Desktop.
Save ppdeassis/349bea0b0997ea4eab23 to your computer and use it in GitHub Desktop.
bash profile
# Tell ls to be colourful
export CLICOLOR=1
export LSCOLORS=Exfxcxdxbxegedabagacad
# Tell grep to highlight matches
export GREP_OPTIONS='--color=auto'
# ignore dupes on bash history
export HISTCONTROL=ignoredups
#Prompt and prompt colors
# 30m - Black
# 31m - Red
# 32m - Green
# 33m - Yellow
# 34m - Blue
# 35m - Purple
# 36m - Cyan
# 37m - White
# 0 - Normal
# 1 - Bold
function prompt {
local BLACK="\[\033[0;30m\]"
local BLACKBOLD="\[\033[1;30m\]"
local RED="\[\033[0;31m\]"
local REDBOLD="\[\033[1;31m\]"
local GREEN="\[\033[0;32m\]"
local GREENBOLD="\[\033[1;32m\]"
local YELLOW="\[\033[0;33m\]"
local YELLOWBOLD="\[\033[1;33m\]"
local BLUE="\[\033[0;34m\]"
local BLUEBOLD="\[\033[1;34m\]"
local PURPLE="\[\033[0;35m\]"
local PURPLEBOLD="\[\033[1;35m\]"
local CYAN="\[\033[0;36m\]"
local CYANBOLD="\[\033[1;36m\]"
local WHITE="\[\033[0;37m\]"
local WHITEBOLD="\[\033[1;37m\]"
local NO_COLOR="\[\e[0m\]"
# NOTE: to add a line break, use \n
# export PS1="$WHITE\u$GREEN@$CYAN\h$GREEN:\w ${WHITE}\$(__git_ps1 \" %s \") \n${PURPLE}⬢ \$(~/.rvm/bin/rvm-prompt) $GREEN\$$NO_COLOR "
local __GIT_BRANCH="\$(__git_ps1 \" %s \")"
# getting versions using asdf - too slow
# local __RUBY_CUR_VERSION="\$(asdf current ruby | awk -F' ' '{print \$1}')"
# local __PYTHON_CUR_VERSION="\$(asdf current python | awk -F' ' '{print \$1}')"
# local __NODE_CUR_VERSION="\$(asdf current nodejs | awk -F' ' '{print \$1}')"
# local __CRYSTAL_CUR_VERSION="\$(asdf current crystal | awk -F' ' '{print \$1}')"
#
# getting versions from binaries
local __RUBY_CUR_VERSION="\$(ruby --version | awk 'NR==1 {print \$2}')"
local __PYTHON_CUR_VERSION="\$(python --version | awk 'NR==1 {print \$2}')"
local __NODE_CUR_VERSION="\$(node --version)"
local __CRYSTAL_CUR_VERSION="\$(crystal --version | awk 'NR==1 {print \$2}')"
# - the same, but evaluated only once (on shell startup)
#local __RUBY_CUR_VERSION=$(ruby --version | awk 'NR==1 {print $2}')
#local __PYTHON_CUR_VERSION=$(python --version | awk 'NR==1 {print $2}')
#local __NODE_CUR_VERSION=$(node --version)
#local __CRYSTAL_CUR_VERSION=$(crystal --version | awk 'NR==1 {print $2}')
export PS1="${WHITE}\u${GREEN}@${CYAN}\h${GREEN}:\w ${WHITE}${__GIT_BRANCH}\n${PURPLE}rb ${__RUBY_CUR_VERSION} ${GREEN}py ${__PYTHON_CUR_VERSION} ${WHITE}node ${__NODE_CUR_VERSION} ${PURPLE}cr ${__CRYSTAL_CUR_VERSION}\n${GREEN}→${NO_COLOR} "
}
# XXX: we'll invoke it at the end of the file, after loading `asdf`
# prompt
export EDITOR='subl -w'
# aliases
# ----
alias ll="ls -lah"
alias root="sudo su -"
# consistency aliases
alias uuidgen='uuidgen | tr "[:upper:]" "[:lower:]"'
# bundler - ruby gem
alias b="bundle exec"
# hooks
# ----
# enabling bash-completion
[ -f "$(brew --prefix)/etc/bash_completion" ] && source "$(brew --prefix)/etc/bash_completion"
# # NVM
# # ----
# export NVM_DIR="$HOME/.nvm"
# [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
# [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# # pyenv
# # ----
# if command -v pyenv 1>/dev/null 2>&1; then
# eval "$(pyenv init -)"
# fi
# # RVM
# # ----
# # Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
# [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
# export PATH="$PATH:$HOME/.rvm/bin"
# asdf
# ----
\. $HOME/.asdf/asdf.sh
\. $HOME/.asdf/completions/asdf.bash
# Yarn
# ----
# IMPORTANT: must be after asdf, to use asdf source commands
export PATH="$(yarn global bin):/usr/local/sbin:$PATH"
# after loading deps, print prompt/PS1 properly
prompt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment