Created
October 15, 2017 17:19
-
-
Save brossetti1/943142924964a133ea83b49b6b506ce3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Generic Utilities | |
using_port() { | |
ps -p $(lsof -i:$1 -Fp | cut -c 2-) | |
} | |
most_used() { | |
history | awk '{a[$4]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head -20 | |
} | |
echoRun() { | |
START=$(date +%s) | |
echo "> $1" | |
eval time $1 | |
END=$(date +%s) | |
DIFF=$(( $END - $START )) | |
echo "It took $DIFF seconds" | |
} | |
sanitize() { | |
echo $1 | tr ": /." "-" | tr -d ",'\"" | |
} | |
# history grep tail | |
hgt() { | |
fc -l 1 | grep -i --color=auto $1 | tail -n 40 | |
} | |
funcs() { | |
# With cheating by looking at the _functions completion function, I'm able to | |
# answer your question: | |
# | |
# The functions are stored in an associative array functions, so to get only the | |
# funtion names (k flag for keys) in alphabetical order (o flag for ordering) | |
# then use which <func_name> to see the definition of that function | |
print -l ${(ok)functions} | |
} | |
marked() { | |
if [[ -f $1 ]]; then | |
open -a marked.app $1 | |
echo found file $1 | |
else | |
open -a marked.app | |
echo no file existing $1 | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment