Last active
November 12, 2018 00:59
-
-
Save sebnitu/a4dceab1df590cd51d3e8d450590ee01 to your computer and use it in GitHub Desktop.
My personal bash profile
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
# ------------------------------------------------------------------------------ | |
# Bash Profile | |
# --- | |
# This file is loaded whenever a console or terminal window is opened. It can | |
# also be reloaded by using the `profile` alias. | |
# | |
# GitHub Gist: | |
# https://gist.github.com/sebnitu/a4dceab1df590cd51d3e8d450590ee01 | |
# | |
# Bookmarks: | |
# 1. Color variables | |
# 2. Linux prompt | |
# 3. Directory Shortcuts | |
# 4. End | |
# | |
# ------------------------------------------------------------------------------ | |
# 1. Color variables | |
# --- | |
# All color options: | |
# Black 0;30 Dark Gray 1;30 | |
# Red 0;31 Light Red 1;31 | |
# Green 0;32 Light Green 1;32 | |
# Brown/Orange 0;33 Yellow 1;33 | |
# Blue 0;34 Light Blue 1;34 | |
# Purple 0;35 Light Purple 1;35 | |
# Cyan 0;36 Light Cyan 1;36 | |
# Light Gray 0;37 White 1;37 | |
# ------------------------------------------------------------------------------ | |
# Generic colors | |
COLOR='1;36' | |
# Color start and end vars | |
C_START="\033[${COLOR}m" | |
C_END="\033[0m" | |
# Color start function | |
# Allows you to add a custom color value | |
function c_start { | |
printf "\033[$1m" | |
} | |
# Color end function | |
# Returns the color to the default | |
function c_end { | |
printf "\033[0m" | |
} | |
# Let us know that this file was loaded | |
echo -e " | |
$(c_start '1;30')Loading bash profile [~/.bash_profile] $(c_start '1;34')...$(c_end) | |
" | |
# Reload this bash profile | |
alias profile=". ~/.bash_profile" | |
# ------------------------------------------------------------------------------ | |
# 2. Linux prompt | |
# --- | |
# Recommended variables: | |
# \d The date, in "Weekday Month Date" format (e.g., "Tue May 26") | |
# \h The hostname, up to the first . (e.g. deckard) | |
# \t The time, in 24-hour HH:MM:SS format | |
# \T The time, in 12-hour HH:MM:SS format | |
# \@ The time, in 12-hour am/pm format | |
# \u The username of the current user | |
# \W The basename of $PWD | |
# \[ Begin a sequence of non-printing characters. (like color escape | |
# sequences). This allows bash to calculate word wrapping correctly. | |
# \] End a sequence of non-printing characters | |
# | |
# For more details on special prompt variables, check out: | |
# https://ss64.com/bash/syntax-prompt.html | |
# ------------------------------------------------------------------------------ | |
# Function that adds the current git branch to prompt | |
function parse_gb { | |
cut -c17- .git/HEAD 2> /dev/null | |
} | |
# Set the Linux prompt | |
PS1="\h:\[\033[${C_START}\]\$(parse_gb) \[${C_END}\]\W$ " | |
# ------------------------------------------------------------------------------ | |
# 3. Directory Shortcuts | |
# ------------------------------------------------------------------------------ | |
# Directory aliases | |
alias goto_sites="cd ~/Documents/Sites" | |
alias goto_tools="cd ~/Documents/Tools" | |
alias goto_clients="goto_sites; cd clients" | |
alias goto_avelient="goto_sites; cd avelient" | |
alias goto_sandbox="goto_sites; cd sandbox" | |
# Project aliases | |
alias goto_baseweb="goto_sandbox; cd BaseWeb" | |
alias goto_vrembem="goto_sandbox; cd vrembem" | |
alias goto_sebnitu="goto_sandbox; cd sebnitu.github.io" | |
# ------------------------------------------------------------------------------ | |
# 4. End | |
# ------------------------------------------------------------------------------ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment