Skip to content

Instantly share code, notes, and snippets.

@pythoninthegrass
Created December 11, 2017 04:13
Show Gist options
  • Save pythoninthegrass/8ce92c08453cf13e31e3ad6e024e50fd to your computer and use it in GitHub Desktop.
Save pythoninthegrass/8ce92c08453cf13e31e3ad6e024e50fd to your computer and use it in GitHub Desktop.
WSL Ubuntu .bash_aliases
# SOURCES:
# http://unix.stackexchange.com/a/122188
# https://natelandau.com/my-mac-osx-bash_profile
# https://jonsuh.com/blog/bash-command-line-shortcuts
# https://news.ycombinator.com/item?id=8159771
# .bashrc: https://gist.github.com/evdokimovm/67e4fcd938af98528aa108574626e522
# ---------------------------
# ETC
# ---------------------------
alias gam="/Users/$(whoami)/bin/gam/gam" # Google API
alias cp='cp -iv' # Preferred 'cp' implementation
alias mv='mv -iv' # Preferred 'mv' implementation
alias less='less -FSRXc' # Preferred 'less' implementation
alias cw='history -cw' # Clear terminal buffer
alias wc='echo $(ls -1 | wc -l)' # Number of files in directory
alias c='clear' # c: Clear terminal display
alias which='type -all' # which: Find executables
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
alias f='open -a Finder ./' # f: Opens current directory in MacOS Finder
alias diff='diff -W $(( $(tput cols) - 2 ))' # Make diff Use Full Terminal Width in Side-by-Side Mode
eval $(thefuck --alias) # "Magnificent app which corrects your previous console command."
# ---------------------------
# DIRECTORIES
# ---------------------------
alias mkdir='mkdir -pv' # Preferred 'mkdir' implementation
alias ll='ls -FGlAhp' # Preferred 'ls' implementation
cd() { builtin cd "$@"; ll; } # Always list directory contents upon 'cd'
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
# cd follows aliases
function cd {
if [ ${#1} == 0 ]; then
builtin cd
elif [ -d "${1}" ]; then
builtin cd "${1}"
elif [[ -f "${1}" || -L "${1}" ]]; then
path=$(getTrueName "$1")
builtin cd "$path"
else
builtin cd "${1}"
fi
}
# do sudo, or sudo the last command if no argument given
s() {
if [[ $# == 0 ]]; then
sudo $(history -p '!!')
else
sudo "$@"
fi
}
# ---------------------------
# NETWORKING
# ---------------------------
alias ip='curl icanhazip.com' # Your public IP address
alias netCons='lsof -i' # netCons: Show all open TCP/IP sockets
alias flushdns='sudo discoveryutil udnsflushcaches' # Flush DNS (Yosemite)
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment