Skip to content

Instantly share code, notes, and snippets.

@sgeto
Created November 17, 2016 02:47
Show Gist options
  • Save sgeto/7d971c5e5f274f3dc8a5c10927485635 to your computer and use it in GitHub Desktop.
Save sgeto/7d971c5e5f274f3dc8a5c10927485635 to your computer and use it in GitHub Desktop.
My .bash_aliases
#-------------------
# Personnal Aliases
#-------------------
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# -> Prevents accidentally clobbering files.
alias mkdir='mkdir -p'
alias h='history'
alias hh='history | grep '
alias j='jobs -l'
alias which='type -a'
alias ..='cd ..'
# Pretty-print of some PATH variables:
alias path='echo -e ${PATH//:/\\n}'
alias libpath='echo -e ${LD_LIBRARY_PATH//:/\\n}'
alias du='du -kh' # Makes a more readable output.
alias df='df -kTh'
#-------------------------------------------------------------
# The 'ls' family (this assumes you use a recent GNU ls).
#-------------------------------------------------------------
# Add colors for filetype and human-readable sizes by default on 'ls':
alias ls='ls -h --color'
alias lx='ls -lXB' # Sort by extension.
alias lk='ls -lSr' # Sort by size, biggest last.
alias lt='ls -ltr' # Sort by date, most recent last.
alias lc='ls -ltcr' # Sort by/show change time,most recent last.
alias lu='ls -ltur' # Sort by/show access time,most recent last.
# The ubiquitous 'll': directories first, with alphanumeric sorting:
alias ll="ls -lv --group-directories-first"
alias lm='ll |more' # Pipe through 'more'
alias lr='ll -R' # Recursive ls.
alias la='ll -A' # Show hidden files.
alias tree='tree -Csuh' # Nice alternative to 'recursive ls' ...
alias tree2="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"
alias lt='ls -laptr' #oldest first sort
alias labc='ls -lap' #alphabetical sort
alias lsd="ls -alF | grep /$"
#alias la="ls --color -lAGbh --time-style='+%b %d %Y %H:%M'"
#-------------------------------------------------------------
# Spelling typos - highly personnal and keyboard-dependent :-)
#-------------------------------------------------------------
alias xs='cd'
alias vf='cd'
alias moer='more'
alias moew='more'
alias kk='ll'
# Aliases that use xtitle
alias top='htop'
alias htop='xtitle Processes on $HOST && htop'
alias make='xtitle Making $(basename $PWD) ; make'
# mine
# Show me the size (sorted) of only the folders in this directory
# alias folders="find . -maxdepth 1 -type d -print | xargs du -sk | sort -rn"
# modified it slightly so that directories with spaces don't cause errors
alias folders="find . -maxdepth 1 -type d -print0 | xargs -0 du -sk | sort -rn"
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
# am I on the internet?
alias pg='ping google.com -c 4'
# install remove update packages and automatically respond yes to confirmation prompt
alias ins="sudo apt-get install -y"
alias upd="sudo apt-get update"
alias upg="sudo apt-get upgrade"
alias rem="sudo apt-get remove -y"
# Tail all logs in /var/log
alias logs="find /var/log -type f -exec file {} \; | grep 'text' | cut -d' ' -f1 | sed -e's/:$//g' | grep -v '[0-9]$' | xargs tail -f"
# holy shit!
alias e='du * -cs | sort -nr | head'
# Git related
alias gs='git status'
alias gc='git commit'
alias ga='git add'
alias gd='git diff'
alias gb='git branch'
alias gl='git log'
alias gsb='git show-branch'
alias gco='git checkout'
alias gg='git grep'
alias gk='gitk --all'
alias gr='git rebase'
alias gri='git rebase --interactive'
alias gcp='git cherry-pick'
alias grm='git rm'
# Monitor logs
# alias syslog='sudo tail -100f /var/log/syslog'
# alias messages='sudo tail -100f /var/log/messages'
# For nano editor
alias nano='nano -w'
#wget
alias wget='wget -c'
#netstat
alias ports='netstat -tulanp'
#Get free mem stats
alias mem='free -h'
# Get your current public IP
alias ip="curl icanhazip.com"
# Make mount command output pretty and human readable format
alias mount='mount |column -t'
#progress bar on file copy. Useful evenlocal.
alias cpProgress="rsync --progress -ravz"
#Show text file without comment (#) lines (Nice alias for /etc files which have tons of comments like /etc/squid.conf)
alias nocomment='grep -Ev '\''^(#|$)'\'''
#Opens current directory in a file explorer
alias explore='nautilus .'
#Opens a file with whatever program would open by double clicking on it in a GUI file explorer
#Usage: try someDocument.doc
alias try='gnome-open'
# Display a random crass ascii art from www.asciiartfarts.com
# alias art='wget -qO - http://www.asciiartfarts.com/random.cgi | sed -n '/<pre>/,/<\/pre>/p' | sed -n '/<table*/,/<\/table>/p' | sed '1d' | sed '$d' | recode html..ascii'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment