Skip to content

Instantly share code, notes, and snippets.

@guilsa
Forked from natelandau/.bash_profile
Last active April 8, 2020 22:07
Show Gist options
  • Select an option

  • Save guilsa/abb500819c6eb22ddc5961e42081538d to your computer and use it in GitHub Desktop.

Select an option

Save guilsa/abb500819c6eb22ddc5961e42081538d to your computer and use it in GitHub Desktop.
Bash/Zsh Profile (mofidied to work for Linux & Mac, reduced to my favorites and not interfere with zsh)
# Revised by Guilherme to work for Linux & Mac. Reduced to my favorites and not interfere with zsh.
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration [*]
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management [*]
# 4. Searching [*]
# 5. Process Management [*]
# 6. Networking
#
# [*] empty for now
# ---------------------------------------------------------------------------
# -------------------------------
# 1. ENVIRONMENT CONFIGURATION
# -------------------------------
# Empty for now
# -----------------------------
# 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 less='less -FSRXc' # Preferred 'less' implementation
cd() { builtin cd "$@"; ll; } # Always list directory contents upon 'cd'
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 c='clear' # c: Clear terminal display
alias path='echo -e ${PATH//:/\\n}' # path: Echo all executable Paths
alias show_options='shopt' # Show_options: display bash options settings
alias fix_stty='stty sane' # fix_stty: Restore terminal settings when screwed up
mcd () { mkdir -p "$1" && cd "$1"; } # mcd: Makes new Dir and jumps inside
# -------------------------------
# 3. FILE AND FOLDER MANAGEMENT
# -------------------------------
# extract: Extract most know archives with one command
# ---------------------------------------------------------
# (kept for reference, needs testing in Linux)
# 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
# }
# ---------------------------
# 4. SEARCHING
# ---------------------------
# Empty for now
# ---------------------------
# 5. PROCESS MANAGEMENT
# ---------------------------
# Empty for now
# ---------------------------
# 6. NETWORKING
# ---------------------------
alias linuxGetIP4='curl -s4 checkip.dns.he.net | grep -Po '(\d+\.){3}\d+' # myip: Public facing IP Address
alias openPorts='sudo lsof -i | grep LISTEN' # openPorts: All listening connections
# ii: display useful host related informaton
# -------------------------------------------------------------------
ii() {
echo -e "\nYou are logged on ${RED}$HOST"
echo -e "\nAdditionnal information:$NC " ; uname -a
echo -e "\n${RED}Users logged on:$NC " ; w -h
echo -e "\n${RED}Current date :$NC " ; date
echo -e "\n${RED}Machine stats :$NC " ; uptime
echo -e "\n${RED}Public facing IP Address :$NC " ;myip
echo
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment