Skip to content

Instantly share code, notes, and snippets.

@varemenos
Last active August 29, 2015 13:57
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 varemenos/9632251 to your computer and use it in GitHub Desktop.
Save varemenos/9632251 to your computer and use it in GitHub Desktop.
oh-my-zsh Functions
# creates a directory and cds into it
function mkd() {
mkdir -p "$@" && cd "$@"
}
# lists zombie processes
function zombie() {
ps aux | awk '{if ($8=="Z") { print $2 }}'
}
#lists npm packages installed
function npmls() {
npm ls --depth=0 "$@" 2>/dev/null
}
# Go up [n] directories
function up() {
local cdir="$(pwd)"
if [[ "${1}" == "" ]]; then
cdir="$(dirname "${cdir}")"
elif ! [[ "${1}" =~ ^[0-9]+$ ]]; then
echo "Error: argument must be a number"
elif ! [[ "${1}" -gt "0" ]]; then
echo "Error: argument must be positive"
else
for i in {1..${1}}; do
local ncdir="$(dirname "${cdir}")"
if [[ "${cdir}" == "${ncdir}" ]]; then
break
else
cdir="${ncdir}"
fi
done
fi
cd "${cdir}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment