Created
June 13, 2022 22:54
-
-
Save DeProdigy/45bffbd1ef634e4230c6e1bd4cf6c9df to your computer and use it in GitHub Desktop.
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
eval "$(rbenv init -)" | |
# --------------------- | |
# Tab improvements | |
# --------------------- | |
bind 'set completion-ignore-case on' | |
bind 'set show-all-if-ambiguous on' | |
bind 'TAB: menu-complete' | |
# --------------------- | |
# History | |
# --------------------- | |
# Larger bash history (allow 32³ entries; default is 500) | |
export HISTSIZE=32768 | |
export HISTFILESIZE=$HISTSIZE | |
# --------------------- | |
# Colors | |
# --------------------- | |
# Adds colors to LS | |
export CLICOLOR=1 | |
# http://geoff.greer.fm/lscolors/ | |
export LSCOLORS=bxexcxdxbxegedabagacad | |
# prompt colors | |
BLACK="\[\e[0;30m\]" | |
RED="\033[1;31m" | |
ORANGE="\033[1;33m" | |
GREEN="\033[1;32m" | |
PURPLE="\033[1;35m" | |
WHITE="\033[1;37m" | |
YELLOW="\[\e[0;33m\]" | |
CYAN="\[\e[0;36m\]" | |
BLUE="\[\e[0;34m\]" | |
BOLD="" | |
RESET="\033[m" | |
# ----------------- | |
# Git status in the prompt | |
# ----------------- | |
# Long git to show + ? ! | |
is_git_repo() { | |
$(git rev-parse --is-inside-work-tree &> /dev/null) | |
} | |
is_git_dir() { | |
$(git rev-parse --is-inside-git-dir 2> /dev/null) | |
} | |
get_git_branch() { | |
local branch_name | |
# Get the short symbolic ref | |
branch_name=$(git symbolic-ref --quiet --short HEAD 2> /dev/null) || | |
# If HEAD isn't a symbolic ref, get the short SHA | |
branch_name=$(git rev-parse --short HEAD 2> /dev/null) || | |
# Otherwise, just give up | |
branch_name="(unknown)" | |
printf $branch_name | |
} | |
# --------------------- | |
# Git status information | |
# --------------------- | |
prompt_git() { | |
local git_info git_state uc us ut st | |
if ! is_git_repo || is_git_dir; then | |
return 1 | |
fi | |
git_info=$(get_git_branch) | |
# Check for uncommitted changes in the index | |
if ! $(git diff --quiet --ignore-submodules --cached); then | |
uc="+" | |
fi | |
# Check for unstaged changes | |
if ! $(git diff-files --quiet --ignore-submodules --); then | |
us="!" | |
fi | |
# Check for untracked files | |
if [ -n "$(git ls-files --others --exclude-standard)" ]; then | |
ut="${RED}?" | |
fi | |
# Check for stashed files | |
if $(git rev-parse --verify refs/stash &>/dev/null); then | |
st="$" | |
fi | |
git_state=$uc$us$ut$st | |
# Combine the branch name and state information | |
if [[ $git_state ]]; then | |
git_info="$git_info${RESET}[$git_state${RESET}]" | |
fi | |
printf "${WHITE} on ${style_branch}${git_info}" | |
} | |
#---------------------- | |
# style the prompt | |
# --------------------- | |
style_user="\[${RESET}${WHITE}\]" | |
style_path="\[${RESET}${CYAN}\]" | |
style_chars="\[${RESET}${WHITE}\]" | |
style_branch="${RED}" | |
# --------------------- | |
# Build the prompt | |
# --------------------- | |
# Example with committed changes: username ~/documents/GA/wdi on master[+] | |
PS1="" | |
PS1+="${style_user}\u" # Username | |
PS1+="${style_path} \w" # Working directory | |
PS1+="\$(prompt_git)" # Git details | |
PS1+="\n" # Newline | |
PS1+="${style_chars}\$ \[${RESET}\]" # $ (and reset color) | |
# ----------------------- | |
# Alias | |
# ------------------------ | |
alias ll='ls -fa' | |
alias reload="source ~/.bash_profile" | |
alias b="cd .." | |
# prompt before deleting! | |
alias rm="rm -i" | |
alias be="bundle exec" | |
alias defrag="cd ~/Code/Crypto/Defrag" | |
export PATH="/usr/local/sbin:$PATH" | |
export PATH="/usr/local/opt/m4/bin:$PATH" | |
export PATH="/usr/local/sbin:$PATH" | |
export PATH="/opt/homebrew/bin:$PATH" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment