Skip to content

Instantly share code, notes, and snippets.

@carmelyne
Created February 3, 2016 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carmelyne/28d58433bbb0ff9b2676 to your computer and use it in GitHub Desktop.
Save carmelyne/28d58433bbb0ff9b2676 to your computer and use it in GitHub Desktop.
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