Created
February 21, 2012 12:57
-
-
Save said-and-done/e47b28a624c3cd455fed 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
#append to your .bashrc | |
# followed by [source ~/.bashrc] to re-evaluate bash file. | |
clear_cache(){ | |
base="/var/www/" | |
cache="htdocs/app/tmp/cache/" | |
if [[ $PWD =~ $base([^/]+) ]] | |
then | |
find $base${BASH_REMATCH[1]}/$cache -type f ! -iname "*.log" -delete | |
fi | |
} | |
tail_logs(){ | |
base="/var/www/" | |
temp="htdocs/app/tmp/" | |
if [[ $PWD =~ $base([^/]+) ]] | |
then | |
tail -f $base${BASH_REMATCH[1]}/logs/php_error.log $base${BASH_REMATCH[1]}/${temp}logs/* | |
fi | |
} | |
#git commit to production | |
gc(){ | |
msg="*bump*"; | |
message=${@:-$msg} | |
git status; | |
git commit -am "$message" && git push origin master:production | |
} | |
#git commit after adding all | |
gca(){ | |
msg="*bump it*"; | |
message=${@:-$msg} | |
git status; | |
(cd $(git rev-parse --show-toplevel)/app && git add . && git commit -m "$message" && git push origin master:production) | |
} | |
#find trailing commas in path | |
trailing_comma(){ | |
find "$@" -type f -name '*.js' -not -name "*.min.*" -exec awk 'function _parseline(s){if(s ~ inlineRegex){_pr(s, FNR,inlineRegex);}else if(s ~ nlRegex){ln=FNR;prev=s;do{getline;}while(!NF);if(match($0, /^\W*\}/)){_pr(prev, ln,nlRegex);}else{_parseline($0);}};}function _pr(s, linenr, regex){hi=gensub(regex, "\033[32;41m\\0 \033[37;40m", "g", s);print "\033[35;40m" FILENAME ":" "\033[32;40m" linenr "\033[37;40m","\t",hi;}BEGIN{inlineRegex=",[[:blank:]]*}";nlRegex=",[[:blank:]]*$";}inlineRegex,nlRegex{_parseline($0);}' {} \; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment