Instantly share code, notes, and snippets.

View .shell_utils.sh
#!/usr/bin/env bash
#===============================================================================
#
# FILE: .shell_utils.sh
#
# USAGE: ./.shell_utils.sh
#
# DESCRIPTION: Add utility functions to the shell. Replaces a lot of aliases
# and functions in my .bashrc and .zshrc files.
# The goal for this file is to house functions useful in both shells
View extract.sh
extract () {
# Extract the contents of a compressed file
# Most common archive types are currently supported
# Support for new types can be added using the "case" block below:
if [ -f "$1" ] ; then
# Check that a file actually exists at $1
echo "Trying to extract file '$1'..."
case "$1" in
*.tar.bz2) tar xvjf "$1" ;;
*.tar.gz) tar xvzf "$1" ;;