Last active
August 29, 2015 13:57
-
-
Save varemenos/9632251 to your computer and use it in GitHub Desktop.
oh-my-zsh Functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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