Created
May 18, 2009 14:26
-
-
Save tomlea/113513 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
| ## Tom's Magical "Don't Mate Your Root" Script | |
| # Prevents "mate /" from crashing your Mac. | |
| function mateforce(){ | |
| `which mate` $* | |
| } | |
| function line_count_less_than(){ | |
| ruby -e " | |
| max_count = ARGV.first.to_i | |
| count = 0 | |
| while STDIN.gets | |
| count += 1 | |
| exit 1 if count > max_count | |
| end | |
| exit 0 | |
| " $* | |
| } | |
| function mate(){ | |
| if find $* -type f | grep -v '.git' | line_count_less_than 10000 | |
| then | |
| mateforce $* | |
| else | |
| echo "Too many files!" | |
| echo "If you are sure you wish to do this, then please use mateforce" | |
| false | |
| fi | |
| } | |
| function m(){ | |
| if [ -z $1 ] | |
| then | |
| mate . | |
| else | |
| mate $* | |
| fi | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment