Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
bash
#############
# Colors #
#############
# Set prompt: " username@hostname/directory/tree $ " (with colors)
export PS1=" \[\e[32;1m\]\u\[\e[0m\]\[\e[32m\]@\h\[\e[36m\]\w \[\e[33m\]\$ \[\e[0m\]"
#########
# AlIAS #
#########
alias home='cd ~'
alias l='ls -lah'
alias h='history'
alias hg='history|grep'
alias c='clear'
alias ..='cd ..'
alias ...='cd ../..'
# Create and change to directory
function mkcd {
if [ $# -ne 1 ]; then
echo "usage: mkcd directory_name"
elif [ -d "${1}" ]; then
echo "(directory already existed)"
cd "$1"
elif [ -e "${1}" ]; then
echo "file exists"
else
mkdir "${1}" && cd "${1}"
fi
}
# Remove empty working directory
function rmwd {
if (shopt -s nullglob dotglob; f=(*); ((! ${#f[@]}))); then
# directory is empty
rmdir `"pwd"`
cd ..
else
echo "not empty"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment