Skip to content

Instantly share code, notes, and snippets.

@MarksCode
Created June 20, 2017 07:03
Show Gist options
  • Save MarksCode/9638e4474fc84cf1b33a509fdd07e6b1 to your computer and use it in GitHub Desktop.
Save MarksCode/9638e4474fc84cf1b33a509fdd07e6b1 to your computer and use it in GitHub Desktop.
# Description: This file holds all my BASH configurations and aliases
#
# Open sublime
alias subl='/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl'
#
# ---------------------------------------------------------------------------
fileCount () {
if [[ ${#} -ne 1 ]]; then
echo "Usage: fileCount <dirname>"
else
if [[ -d ${1} ]]; then
find "$1" -type f | wc -l
else
echo "${1} not a directory"
fi
fi
}
export GITAWAREPROMPT=~/.bash/git-aware-prompt
source "${GITAWAREPROMPT}/main.sh"
# -------------------------------
# 1. ENVIRONMENT CONFIGURATION
# -------------------------------
# Change Prompt
# ------------------------------------------------------------
export PS1="\n________________________________________________________________________________\n\[\033[32m\]\h: \[\033[33;1m\]\w\[\033[m\] \[$txtcyn\]\$git_branch\[$txtrst\] => "
# Set Paths
# ------------------------------------------------------------
export PATH="$PATH:/usr/local/bin/"
export PATH="/usr/local/git/bin:/sw/bin/:/usr/local/bin:/usr/local/:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
# Set Default Editor (change 'Nano' to the editor of your choice)
# ------------------------------------------------------------
export EDITOR=/usr/bin/vim
# Set default blocksize for ls, df, du
# ------------------------------------------------------------
export BLOCKSIZE=1k
# Add color to terminal
# ------------------------------------------------------------
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
# -----------------------------
# 2. MAKE TERMINAL BETTER
# -----------------------------
alias cp='cp -iv' # Preferred 'cp' implementation
alias mv='mv -iv' # Preferred 'mv' implementation
alias mkdir='mkdir -pv' # Preferred 'mkdir' implementation
alias ll='ls -FGlAhp' # Preferred 'ls' implementation
alias cd..='cd ../' # Go back 1 directory level (for fast typers)
alias ..='cd ../' # Go back 1 directory level
alias ...='cd ../../' # Go back 2 directory levels
alias .3='cd ../../../' # Go back 3 directory levels
alias .4='cd ../../../../' # Go back 4 directory levels
alias .5='cd ../../../../../' # Go back 5 directory levels
alias .6='cd ../../../../../../' # Go back 6 directory levels
alias f='open -a Finder ./' # f: Opens current directory in MacOS Finder
alias ~="cd ~" # ~: Go Home
mcd () { mkdir -p "$1" && cd "$1"; } # mcd: Makes new Dir and jumps inside
trash () { command mv "$@" ~/.Trash ; } # trash: Moves a file to the MacOS trash
# -------------------------------
# 3. FILE AND FOLDER MANAGEMENT
# -------------------------------
zipf () { zip -r "$1".zip "$1" ; } # zipf: To create a ZIP archive of a folder
# extract: Extract most know archives with one command
# ---------------------------------------------------------
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar e $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment