Skip to content

Instantly share code, notes, and snippets.

@Jahhein
Created June 9, 2017 19:00
Show Gist options
  • Save Jahhein/e481da99e2a48e4241cc206d4400567b to your computer and use it in GitHub Desktop.
Save Jahhein/e481da99e2a48e4241cc206d4400567b to your computer and use it in GitHub Desktop.
Bash/ZSH aliases
# ============================================================================ #
# Aliases
# ============================================================================ #
# ---------------------------------------------------------------------------- #
# Utility
# ---------------------------------------------------------------------------- #
alias cd..='cd ../' # Go back 1 directory level
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 ~="cd ~" # ~: Go Home
alias cp='cp -iv' # Better copy; verbose and check for copies
alias mv='mv -iv' # Better move ; verbose and check for copies
alias mkdir='mkdir -pv' # Better make directory
alias rm='rm -v ' # Verbose remove
alias rmall='rm -rfv ' # Remove all within directory.
alias rmEmptyDirs='find . -empty -type d -delete' # Removes empty directories from current directory and sub directories
alias l='ls -FGlAhp' # Better list directory
alias ll='ls -lah'
alias ldots='ls -d .* ' # Lists all dotfiles in directory
alias f='open -a Finder ./' # Opens current directory in MacOS Finder
alias c='clear' # Clear terminal display
alias x='exit' # Exit terminal
alias ln='\ln -sFfvi '
alias less='less -FSRXc' # Less pipe
alias find-cmd='type -a' # Find executables
alias path="echo ${PATH//:/\\n}" # Echo all executable Paths
alias fix_stty='stty sane' # Restore terminal settings when screwed up
alias cic='set completion-ignore-case On' # Make tab-completion case-insensitive
alias DT="tee ${HOME}/Desktop/terminalOut.txt" # DT: Pipe content to file on MacOS Desktop
alias where='where -s ' # Detailed location on symlinks
alias mute="osascript -e 'set volume output muted true'" # Mute audio
alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"
alias reload="exec ${SHELL} -l" # Reload shell
# ---------------------------------------------------------------------------- #
# Directories
# ---------------------------------------------------------------------------- #
alias workspace="cd ${WORKSPACE}"
alias projects="cd ${WORKSPACE}/projects"
alias archives="cd ${WORKSPACE}/archives"
alias temporary="cd ${WORKSPACE}/temporary"
alias settings="cd ${SETTINGS}"
alias documents="cd ${HOME}/Documents"
alias downloads="cd ${HOME}/Downloads"
alias desktop="cd ${HOME}/Desktop"
alias vols="cd /Volumes"
# ---------------------------------------------------------------------------- #
# Security
# ---------------------------------------------------------------------------- #
alias verifyCS='codesign -vvv --display --deep-verify ' # Apple's codesign verification check
alias clamscan-simple='sudo clamscan -r --bell -i ' # ClamAV
# ---------------------------------------------------------------------------- #
# File Permissions
# ---------------------------------------------------------------------------- #
alias chownCurrentUser='sudo chown -Rv $(whoami) '
alias chownDeveloper='sudo chown -Rv $(whoami):developer '
alias chmod700='chmod -Rv 700 '
alias chmod600='chmod -Rv 600 '
# ---------------------------------------------------------------------------- #
# Files & Management
# ---------------------------------------------------------------------------- #
alias numFiles='echo $(ls -1 | wc -l)' # numFiles: Count of non-hidden files in current dir
alias make1mb='mkfile 1m ./1MB.dat' # make1mb: Creates a file of 1mb size (all zeros)
alias make5mb='mkfile 5m ./5MB.dat' # make5mb: Creates a file of 5mb size (all zeros)
alias make10mb='mkfile 10m ./10MB.dat' # make10mb: Creates a file of 10mb size (all zeros)
alias rmFileDuplicates='fdupes -rdN ' # fdupes -- removes duplicate files.
alias updateLocate='sudo /usr/libexec/locate.updatedb' # Update locate database
# Full Recursive Directory Listing
alias lr='ls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/ /'\'' -e '\''s/-/|/'\'' | less'
# ---------------------------------------------------------------------------- #
# Searching
# ---------------------------------------------------------------------------- #
alias qfind="find . -name " # Quickly search for file
# ---------------------------------------------------------------------------- #
# Diagnostics (CPU, RAM)
# ---------------------------------------------------------------------------- #
alias memHogsTop='top -l 1 -o rsize | head -20'
alias memHogsPs='ps wwaxm -o pid,stat,vsize,rss,time,command | head -10'
alias cpu_hogs='ps wwaxr -o pid,stat,%cpu,time,command | head -10'
alias topForever='top -l 9999999 -s 10 -o cpu'
alias ttop="top -R -F -s 10 -o rsize" # Recommended 'top' invocation to minimize resources
# ---------------------------------------------------------------------------- #
# Networking
# ---------------------------------------------------------------------------- #
alias myip='curl ip.appspot.com' # myip: Public facing IP Address
alias netCons='lsof -i' # netCons: Show all open TCP/IP sockets
alias lsock='sudo /usr/sbin/lsof -i -P' # lsock: Display open sockets
alias lsockU='sudo /usr/sbin/lsof -nP | grep UDP' # lsockU: Display only open UDP sockets
alias lsockT='sudo /usr/sbin/lsof -nP | grep TCP' # lsockT: Display only open TCP sockets
alias ipInfo0='ipconfig getpacket en0' # ipInfo0: Get info on connections for en0
alias ipInfo1='ipconfig getpacket en1' # ipInfo1: Get info on connections for en1
alias openPorts='sudo lsof -i | grep LISTEN' # openPorts: All listening connections
alias showBlocked='sudo ipfw list' # showBlocked: All ipfw rules inc/ blocked IPs
alias sniff="sudo ngrep -d 'en1' -t '^(GET|POST) ' 'tcp and port 80'"
alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E \"Host\: .*|GET \/.*\""
# ---------------------------------------------------------------------------- #
# System
# ---------------------------------------------------------------------------- #
alias mountReadWrite='/sbin/mount -uw /' # For use when booted into single-user
# ---------------------------------------------------------------------------- #
# Web
# ---------------------------------------------------------------------------- #
alias apacheEdit='sudo edit /etc/httpd/httpd.conf' # apacheEdit: Edit httpd.conf
alias apacheRestart='sudo apachectl graceful' # apacheRestart: Restart Apache
alias editHosts='sudo edit /etc/hosts' # editHosts: Edit /etc/hosts file
alias herr='tail /var/log/httpd/error_log' # herr: Tails HTTP error logs
alias apacheLogs="less +F /var/log/apache2/error_log" # Apachelogs: Shows apache error logs
# ---------------------------------------------------------------------------- #
# Homebrew (OSX) Packages
# ---------------------------------------------------------------------------- #
# NOTE: homebrew offers an alias tap and functions file
alias todo='devtodo ' # Devtodo package
alias git='hub' # Hub package
alias tree='tree -ACSfDNpu ' # Tree package
# ---------------------------------------------------------------------------- #
# Bower
# ---------------------------------------------------------------------------- #
alias bower='noglob bower'
# ---------------------------------------------------------------------------- #
# Git
# ---------------------------------------------------------------------------- #
alias clone='git clone -v --recursive '
alias status='git status -v '
alias pull='git pull -v '
alias fetch='git fetch -v '
alias remotes='git remote -v '
alias push='git push -v '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment