Created
April 7, 2019 02:24
-
-
Save MatthewVance/49f2a2344594e67247395d2c4f584770 to your computer and use it in GitHub Desktop.
Bash Aliases
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
######### | |
# Aliases | |
######### | |
# Configure aliases to work when prefixed with sudo | |
alias sudo='sudo ' | |
# ------------------------------------ | |
# Apt-get | |
# ------------------------------------ | |
# Install package (e.g., apti nginx) | |
alias apti='sudo apt-get install -V' | |
# List files installed to your system from package-name (e.g., pkgfiles nginx) | |
alias pkgfiles='dpkg --listfiles' | |
# Completely remove packages, including conf files (e.g., aptpurge nginx) | |
alias aptpurge='sudo apt-get remove --purge' | |
# Remove a package (e.g., aptrm nginx) | |
alias aptrm='sudo apt-get remove' | |
# Search for package (e.g., apts nginx) | |
alias apts='apt-cache search' | |
# Search for package (e.g., aptshow nginx) | |
alias aptshow='apt-cache show' | |
# Update apt-get | |
alias aptupd='sudo apt-get update' | |
# Upgrade packages | |
alias aptupg='sudo apt-get dist-upgrade -V' | |
# Full package upgrade | |
alias aptupgd='sudo apt-get dist-upgrade -V && sudo apt-get autoremove' | |
# Full package update and upgrade | |
alias aptuu='sudo apt-get update && sudo apt-get dist-upgrade -V && sudo apt-get autoremove' | |
# ------------------------------------ | |
# AWS | |
# ------------------------------------ | |
alias aws='/home/matt/dev/repos/github.com/MatthewVance/aws/.venv/bin/aws' | |
# ------------------------------------ | |
# Common Commands | |
# ------------------------------------ | |
# cd | |
## shortcut for going up directories | |
alias ..='cd ..' # Move up one dir | |
alias ...='cd ../..' # up two | |
alias ....='cd ../../..' # up three | |
## Go to previous directory | |
alias -- -='cd -' | |
## Go to parent directory even if space is forgotten | |
alias cd..='cd ..' | |
# cp | |
# Warn before overwriting existing file and show what was copied by default | |
alias cp='cp -iv' | |
# Grep | |
# Also use grep with color | |
alias grep='grep --color=auto' | |
alias fgrep='fgrep --color=auto' | |
alias egrep='egrep --color=auto' | |
# ls | |
## Classify and columns | |
alias ls='ls -CF' | |
## Long, human readable, and classify | |
alias lsal='ls -lhF' | |
## Almost all, long, human readable, and classify | |
alias lsal='ls -AlhF' | |
## Almost all, classify, and columns | |
alias lsa='ls -AFC' | |
## Sorted by time with longer time format, with almost all, long, and human readable | |
alias lsalt='ls -Alt --time-style=long-iso' | |
# history | |
## Make searching history with grep easier (also helpful because it shows command numbers) | |
alias histg='history | grep' | |
# mkdir | |
## Make adding any parent directories a default behavior and show every directory creation | |
alias mkdir='mkdir -pv' | |
# mv | |
# Warn before overwriting an existing file and show what was copied by default | |
alias mv='mv -iv' | |
# Remove (force removal of folders and show what was done) | |
alias rr='rm -rfv' | |
# sudo | |
alias s='sudo' | |
# ------------------------------------ | |
# Compute Hashes | |
# ------------------------------------ | |
alias sha1='shasum' | |
alias sha256='shasum -a 256' | |
alias sha512='shasum -a 512' | |
# ------------------------------------ | |
# Docker aliases and function | |
# ------------------------------------ | |
# Ideas from https://github.com/tcnksm/docker-alias | |
# Always use `sudo` with `docker` since required on my distro | |
alias docker='sudo docker' | |
# Execute interactive container, (e.g., $dex base /bin/bash) | |
alias dex='docker exec -i -t' | |
# Get images | |
alias di='docker images' | |
# Get container IP (e.g., dip 47d57c66ab05) | |
alias dip="docker inspect --format '{{ .NetworkSettings.IPAddress }}'" | |
# Run interactive container, (e.g., $dki debian:jessie /bin/bash) | |
alias dit='docker run -i -t' | |
# Return most recent container ID | |
alias dl='docker ps -l -q' | |
# Show all containers, including stopped ones | |
alias dpsa='docker ps -a' | |
# Show list of running containers | |
alias dps='docker ps' | |
# ------------------------------------ | |
# GPG | |
# ------------------------------------ | |
# Import key from keyserver | |
alias gpgget='gpg --recv-key' | |
# ------------------------------------ | |
# Miscellaneous | |
# ------------------------------------ | |
# Recursively delete `.DS_Store` files | |
alias cleanup_dsstore="find . -name '*.DS_Store' -type f -ls -delete" | |
alias clean='clear' | |
alias c='clear' | |
alias m='man' | |
# Stop NGINX service | |
alias nginxstop='sudo kill -QUIT $( cat /var/run/nginx.pid )' | |
alias week='date +%U' | |
# Start SSH Agent with 1 hour ID lifetimes | |
alias sshagent='eval "$(ssh-agent -s -t 3600)"' | |
alias quit='exit' | |
# ------------------------------------ | |
# Navigation | |
# ------------------------------------ | |
alias dl='cd ~/Downloads' | |
alias dt='cd ~/Desktop' | |
alias proj='cd ~/dev/repos/github.com/MatthewVance/' | |
# ------------------------------------ | |
# Network | |
# ------------------------------------ | |
# Curl | |
# Get web server headers | |
alias header='curl -I' | |
# IP Address (i.e., public address when behind a NAT router) | |
alias ip='dig +short myip.opendns.com @resolver1.opendns.com' | |
# Netstat | |
# Show network interfaces | |
alias interfaces='netstat -i' | |
# Show open ports | |
alias ports='netstat -tulanp' | |
# Show established TCP connections | |
alias nsest='netstat -atnp | grep ESTABLISHED' | |
alias nsestwatch="watch -d -n0 'netstat -atnp | grep ESTABLISHED'" | |
# Find port for running program (e.g. nsfind ssh) | |
alias nsfind='netstat -ap | grep' | |
# Show listening TCP connections with process id and user | |
alias nspu='sudo netstat -ltpe' | |
# Watch netstat | |
alias nswatch='netstat -c' | |
# Ping | |
# Limit ping to a 4 count by default | |
alias ping='ping -c 4' | |
# ------------------------------------ | |
# Program shortcuts | |
# ------------------------------------ | |
alias g='git' | |
alias h='history' | |
alias n='nano' | |
# ------------------------------------ | |
# Python | |
# ------------------------------------ | |
# Virtual environments | |
alias vestart='source ./venv/bin/activate' | |
alias vestop='deactivate' | |
# ------------------------------------ | |
# System Power | |
# ------------------------------------ | |
alias restart='sudo shutdown –r now' | |
alias shutdown='sudo shutdown –h now' | |
# ------------------------------------ | |
# System Stats | |
# ------------------------------------ | |
## List disk usage in human-readable units, filesystem type, and total at end | |
alias df='df -Tha --total' | |
## Summarize disk usage of recursively for all files in human readable form and sorted with grand total at the end | |
alias du='du -ach | sort -h' | |
## Display free and used system memory in human readable form with total at bottom | |
alias free='free -ht' | |
## Use preferred ps format as default | |
alias ps='ps auxf' | |
# Make process table searchable (i.e., psg bash) | |
alias psg='ps aux | grep -v grep | grep -i -e VSZ -e' | |
## Show top processes eating memory | |
alias psmem='ps auxf | sort -nr -k 4 | head -10' | |
alias psmemwatch=watch="watch -d -n0 'ps auxf | sort -nr -k 4 | head -10'" | |
## Show top processes eating CPU | |
alias pscpu='ps auxf | sort -nr -k 3 | head -10' | |
## Watch top processes eating CPU | |
alias pscpuwatch="watch -d -n0 'ps auxf | sort -nr -k 3 | head -10'" | |
## Show CPU info | |
alias cpuinfo='lscpu' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment