Repository: matthewmccullough/scripts Branch: master Commit: 40b246165445 Files: 101 Total size: 121.1 KB Directory structure: gitextract_3n48agbq/ ├── .gitignore ├── LICENSE ├── README.md ├── ReComment.scpt ├── ackgradle ├── bamboo ├── battery ├── beep-timer-ignite/ │ └── BeepTimerIgnite.groovy ├── chksha1 ├── colornetstat ├── crashplan-start ├── crashplan-stop ├── doforever ├── ejectall ├── ejectalldisks.scpt ├── find-eclipse-workspaces ├── findjarcontaining ├── fixbrewperms ├── generaterandomchanges ├── generaterandomfiles ├── git-cdandpull ├── git-cdandsvnrebase ├── git-completion ├── git-compressallrepos ├── git-deletealltags ├── git-draw ├── git-fetchrecursive ├── git-finddirty ├── git-findunpushed ├── git-gc_recursive ├── git-graphlive ├── git-plotrepo.rb ├── git-publish-branch ├── git-rank-contributors ├── git-rmignored ├── git-wtf ├── git.nr ├── github-gem-install ├── gitnewrepo ├── hg-cdpullandupdate ├── history.cuttail ├── historytailbash ├── historytailzsh ├── hub.zsh_completion ├── imageconvert ├── iphoto-reverttooriginals ├── isappinstalled ├── iterm ├── jenkins-start ├── jenkins-start-8090 ├── lein ├── loopthis ├── macosx-rescan-services-menu ├── macports-cleanup ├── macports-update ├── macprefs ├── markdown-andopen ├── markdown-here ├── markdown.pl ├── mdlstaglist ├── mvim ├── mysql-start ├── mysql-stop ├── openmeta ├── openmetaallfileshere ├── openmetaallfoldershere ├── openmetalisttags ├── orgtomarkdown ├── orgtomarkdowndots ├── p4diff ├── p4merge ├── pinboard-backup ├── postgresql-start ├── postgresql-stop ├── prepmigrate-brew ├── prepmigrate-gems ├── prepmigrate-port ├── ql ├── ramdisk ├── removedropboxconflicts ├── replace-word-in-filename ├── resty ├── rilconvert ├── scmupdateallprojects ├── setmaven2 ├── setmaven3 ├── setmavenpoly ├── svncdandupdate ├── tabstospacesfor ├── terminal ├── terminal.scpt ├── timemachine-findonlyononeside ├── timemachine-verify ├── treelive ├── unzipall ├── vacuummail ├── visualvm ├── vmware-start ├── welcome ├── wireshark-auth └── zshverboseoff ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ pinboard-backup-matthew.sh pinboard-backup-matthew ================================================ FILE: LICENSE ================================================ # License The prose, course text, slide layouts, class outlines, diagrams, HTML, CSS, and Markdown code in the set of educational materials located in this repository are licensed as _CC BY 3.0_. The Octocat, GitHub logo and other already-copyrighted and already-reserved trademarks and images are not covered by this license. ------------------------ # Attribution 3.0 Unported (CC BY 3.0) This is a [human-readable summary](http://creativecommons.org/licenses/by/3.0/deed.en_US) of the [Legal Code (the full license)](http://creativecommons.org/licenses/by/3.0/legalcode). ## You are free: * to Share — to copy, distribute and transmit the work * to Remix — to adapt the work to make commercial use of the work ## Under the following conditions: * Attribution — You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). ## With the understanding that: * Waiver — Any of the above conditions can be waived if you get permission from the copyright holder. * Public Domain — Where the work or any of its elements is in the public domain under applicable law, that status is in no way affected by the license. * Other Rights — In no way are any of the following rights affected by the license: * Your fair dealing or fair use rights, or other applicable copyright exceptions and limitations; * The author's moral rights; * Rights other persons may have either in the work itself or in how the work is used, such as publicity or privacy rights. Notice — For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to this web page. -------------------------------- # Attribution 3.0 Unported (CC BY 3.0) http://creativecommons.org/licenses/by/3.0/legalcode CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM ITS USE. License THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS. 1. Definitions "Adaptation" means a work based upon the Work, or upon the Work and other pre-existing works, such as a translation, adaptation, derivative work, arrangement of music or other alterations of a literary or artistic work, or phonogram or performance and includes cinematographic adaptations or any other form in which the Work may be recast, transformed, or adapted including in any form recognizably derived from the original, except that a work that constitutes a Collection will not be considered an Adaptation for the purpose of this License. For the avoidance of doubt, where the Work is a musical work, performance or phonogram, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered an Adaptation for the purpose of this License. "Collection" means a collection of literary or artistic works, such as encyclopedias and anthologies, or performances, phonograms or broadcasts, or other works or subject matter other than works listed in Section 1(f) below, which, by reason of the selection and arrangement of their contents, constitute intellectual creations, in which the Work is included in its entirety in unmodified form along with one or more other contributions, each constituting separate and independent works in themselves, which together are assembled into a collective whole. A work that constitutes a Collection will not be considered an Adaptation (as defined above) for the purposes of this License. "Distribute" means to make available to the public the original and copies of the Work or Adaptation, as appropriate, through sale or other transfer of ownership. "Licensor" means the individual, individuals, entity or entities that offer(s) the Work under the terms of this License. "Original Author" means, in the case of a literary or artistic work, the individual, individuals, entity or entities who created the Work or if no individual or entity can be identified, the publisher; and in addition (i) in the case of a performance the actors, singers, musicians, dancers, and other persons who act, sing, deliver, declaim, play in, interpret or otherwise perform literary or artistic works or expressions of folklore; (ii) in the case of a phonogram the producer being the person or legal entity who first fixes the sounds of a performance or other sounds; and, (iii) in the case of broadcasts, the organization that transmits the broadcast. "Work" means the literary and/or artistic work offered under the terms of this License including without limitation any production in the literary, scientific and artistic domain, whatever may be the mode or form of its expression including digital form, such as a book, pamphlet and other writing; a lecture, address, sermon or other work of the same nature; a dramatic or dramatico-musical work; a choreographic work or entertainment in dumb show; a musical composition with or without words; a cinematographic work to which are assimilated works expressed by a process analogous to cinematography; a work of drawing, painting, architecture, sculpture, engraving or lithography; a photographic work to which are assimilated works expressed by a process analogous to photography; a work of applied art; an illustration, map, plan, sketch or three-dimensional work relative to geography, topography, architecture or science; a performance; a broadcast; a phonogram; a compilation of data to the extent it is protected as a copyrightable work; or a work performed by a variety or circus performer to the extent it is not otherwise considered a literary or artistic work. "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation. "Publicly Perform" means to perform public recitations of the Work and to communicate to the public those public recitations, by any means or process, including by wire or wireless means or public digital performances; to make available to the public Works in such a way that members of the public may access these Works from a place and at a place individually chosen by them; to perform the Work to the public by any means or process and the communication to the public of the performances of the Work, including by public digital performance; to broadcast and rebroadcast the Work by any means including signs, sounds or images. "Reproduce" means to make copies of the Work by any means including without limitation by sound or visual recordings and the right of fixation and reproducing fixations of the Work, including storage of a protected performance or phonogram in digital form or other electronic medium. 2. Fair Dealing Rights. Nothing in this License is intended to reduce, limit, or restrict any uses free from copyright or rights arising from limitations or exceptions that are provided for in connection with the copyright protection under copyright law or other applicable laws. 3. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below: to Reproduce the Work, to incorporate the Work into one or more Collections, and to Reproduce the Work as incorporated in the Collections; to create and Reproduce Adaptations provided that any such Adaptation, including any translation in any medium, takes reasonable steps to clearly label, demarcate or otherwise identify that changes were made to the original Work. For example, a translation could be marked "The original work was translated from English to Spanish," or a modification could indicate "The original work has been modified."; to Distribute and Publicly Perform the Work including as incorporated in Collections; and, to Distribute and Publicly Perform Adaptations. For the avoidance of doubt: Non-waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme cannot be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme can be waived, the Licensor waives the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; and, Voluntary License Schemes. The Licensor waives the right to collect royalties, whether individually or, in the event that the Licensor is a member of a collecting society that administers voluntary licensing schemes, via that society, from any exercise by You of the rights granted under this License. The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. Subject to Section 8(f), all rights not expressly granted by Licensor are hereby reserved. 4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions: You may Distribute or Publicly Perform the Work only under the terms of this License. You must include a copy of, or the Uniform Resource Identifier (URI) for, this License with every copy of the Work You Distribute or Publicly Perform. You may not offer or impose any terms on the Work that restrict the terms of this License or the ability of the recipient of the Work to exercise the rights granted to that recipient under the terms of the License. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties with every copy of the Work You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Work, You may not impose any effective technological measures on the Work that restrict the ability of a recipient of the Work from You to exercise the rights granted to that recipient under the terms of the License. This Section 4(a) applies to the Work as incorporated in a Collection, but this does not require the Collection apart from the Work itself to be made subject to the terms of this License. If You create a Collection, upon notice from any Licensor You must, to the extent practicable, remove from the Collection any credit as required by Section 4(b), as requested. If You create an Adaptation, upon notice from any Licensor You must, to the extent practicable, remove from the Adaptation any credit as required by Section 4(b), as requested. If You Distribute, or Publicly Perform the Work or any Adaptations or Collections, You must, unless a request has been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or if the Original Author and/or Licensor designate another party or parties (e.g., a sponsor institute, publishing entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; (ii) the title of the Work if supplied; (iii) to the extent reasonably practicable, the URI, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and (iv) , consistent with Section 3(b), in the case of an Adaptation, a credit identifying the use of the Work in the Adaptation (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). The credit required by this Section 4 (b) may be implemented in any reasonable manner; provided, however, that in the case of a Adaptation or Collection, at a minimum such credit will appear, if a credit for all contributing authors of the Adaptation or Collection appears, then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors. For the avoidance of doubt, You may only use the credit required by this Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by the Original Author, Licensor and/or Attribution Parties, as appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original Author, Licensor and/or Attribution Parties. Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable law, if You Reproduce, Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or Collections, You must not distort, mutilate, modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author's honor or reputation. Licensor agrees that in those jurisdictions (e.g. Japan), in which any exercise of the right granted in Section 3(b) of this License (the right to make Adaptations) would be deemed to be a distortion, mutilation, modification or other derogatory action prejudicial to the Original Author's honor and reputation, the Licensor will waive or not assert, as appropriate, this Section, to the fullest extent permitted by the applicable national law, to enable You to reasonably exercise Your right under Section 3(b) of this License (right to make Adaptations) but not otherwise. 5. Representations, Warranties and Disclaimer UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. 6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 7. Termination This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Adaptations or Collections from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License. Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above. 8. Miscellaneous Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License. Each time You Distribute or Publicly Perform an Adaptation, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License. If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent. This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You. The rights granted under, and the subject matter referenced, in this License were drafted utilizing the terminology of the Berne Convention for the Protection of Literary and Artistic Works (as amended on September 28, 1979), the Rome Convention of 1961, the WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and the Universal Copyright Convention (as revised on July 24, 1971). These rights and subject matter take effect in the relevant jurisdiction in which the License terms are sought to be enforced according to the corresponding provisions of the implementation of those treaty provisions in the applicable national law. If the standard suite of rights granted under applicable copyright law includes additional rights not granted under this License, such additional rights are deemed to be included in the License; this License is not intended to restrict the license of any rights under applicable law. Creative Commons Notice Creative Commons is not a party to this License, and makes no warranty whatsoever in connection with the Work. Creative Commons will not be liable to You or any party on any legal theory for any damages whatsoever, including without limitation any general, special, incidental or consequential damages arising in connection to this license. Notwithstanding the foregoing two (2) sentences, if Creative Commons has expressly identified itself as the Licensor hereunder, it shall have all rights and obligations of Licensor. Except for the limited purpose of indicating to the public that the Work is licensed under the CCPL, Creative Commons does not authorize the use by either party of the trademark "Creative Commons" or any related trademark or logo of Creative Commons without the prior written consent of Creative Commons. Any permitted use will be in compliance with Creative Commons' then-current trademark usage guidelines, as may be published on its website or otherwise made available upon request from time to time. For the avoidance of doubt, this trademark restriction does not form part of this License. Creative Commons may be contacted at http://creativecommons.org/. ================================================ FILE: README.md ================================================ # Matthew's Shell Scripts These are a series of utility scripts for Bash and ZShell from Matthew McCullough. Many are derived from prior works of open source, but some original URLs have been lost. Please point out any original art URLs and they will be added. I always strive to give credit to prior art authors. Please fork, fix, enhance, and send pull requests. # MIT License Copyright (c) 2010, Matthew McCullough, Ambient Ideas, LLC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: ackgradle ================================================ #!/bin/bash echo Searching for \"$1\" in gradle files. ack -a "$1" **/*.gradle ================================================ FILE: bamboo ================================================ #!/bin/bash pushd /Applications/Dev/Bamboo/ bamboo.sh $1 popd echo REMINDER: Bamboo runs on port 8085 ================================================ FILE: battery ================================================ #!/bin/sh ioreg -l | grep -E '(Max|Current)Capacity' | cut -d= -f2 | perl -e'@b=; printf"%d%%\n",100*$b[1]/$b[0]' ================================================ FILE: beep-timer-ignite/BeepTimerIgnite.groovy ================================================ import java.io.File; import java.io.IOException; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.DataLine; import javax.sound.sampled.FloatControl; import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.SourceDataLine; import javax.sound.sampled.UnsupportedAudioFileException; public class BeepTimerIgnite extends Thread { public static void main(String[] args) { 20.times { sleep(15000) //println "Beep!\007\007\007\r\n"; new BeepTimerIgnite("ping.wav") } } private String filename; private Position curPosition; private final int EXTERNAL_BUFFER_SIZE = 524288; // 128Kb enum Position { LEFT, RIGHT, NORMAL }; public BeepTimerIgnite(String wavfile) { filename = wavfile; curPosition = Position.NORMAL; } public BeepTimerIgnite(String wavfile, Position p) { filename = wavfile; curPosition = p; } public void run() { File soundFile = new File(filename); if (!soundFile.exists()) { System.err.println("Wave file not found: " + filename); return; } AudioInputStream audioInputStream = null; try { audioInputStream = AudioSystem.getAudioInputStream(soundFile); } catch (UnsupportedAudioFileException e1) { e1.printStackTrace(); return; } catch (IOException e1) { e1.printStackTrace(); return; } AudioFormat format = audioInputStream.getFormat(); SourceDataLine auline = null; DataLine.Info info = new DataLine.Info(SourceDataLine.class, format); try { auline = (SourceDataLine) AudioSystem.getLine(info); auline.open(format); } catch (LineUnavailableException e) { e.printStackTrace(); return; } catch (Exception e) { e.printStackTrace(); return; } if (auline.isControlSupported(FloatControl.Type.PAN)) { FloatControl pan = (FloatControl) auline .getControl(FloatControl.Type.PAN); if (curPosition == Position.RIGHT) pan.setValue(1.0f); else if (curPosition == Position.LEFT) pan.setValue(-1.0f); } auline.start(); int nBytesRead = 0; byte[] abData = new byte[EXTERNAL_BUFFER_SIZE]; try { while (nBytesRead != -1) { nBytesRead = audioInputStream.read(abData, 0, abData.length); if (nBytesRead >= 0) auline.write(abData, 0, nBytesRead); } } catch (IOException e) { e.printStackTrace(); return; } finally { auline.drain(); auline.close(); } } } ================================================ FILE: chksha1 ================================================ #!/bin/bash newfilehash=$(openssl sha1 $1) existingsha1=$(cat $2) if [ "${existingsha1}" = "${newfilehash}" ]; then echo "Key is valid."; else echo "Key is _not_ valid!!!"; fi ================================================ FILE: colornetstat ================================================ #!/bin/bash # colorize netstat output color_red=`echo "33[0;31m"` color_green=`echo "33[0;32m"` color_yellow=`echo "33[0;33m"` color_blue=`echo "33[0;34m"` color_purple=`echo "33[0;35m"` color_cyan=`echo "33[1;36m"` no_color=`echo "33[0m"` netstat ${@} |sed -e "s/^.* ESTABLISH.*$/${color_green}&${no_color}/; s/^.* LIST.*$/${color_cyan}&${no_color}/; s/^.* *.WAIT$/${color_red}&${no_color}/; s/^.* CLOSING$/${color_red}&${no_color}/; s/^.* SYN.*$/${color_yellow}&${no_color}/; s/^.* FIN.*$/${color_yellow}&${no_color}/; s/^.* *.ACK/${color_yellow}&${no_color}/" ================================================ FILE: crashplan-start ================================================ #!/bin/sh sudo launchctl load /Library/LaunchDaemons/com.crashplan.engine.plist ================================================ FILE: crashplan-stop ================================================ #!/bin/sh sudo launchctl unload /Library/LaunchDaemons/com.crashplan.engine.plist ================================================ FILE: doforever ================================================ #!/bin/bash #Ensure we have the quantity specified on the CLI if [ -z "$2" ]; then ARG_ERR=ERR; fi if [ -z "$1" ]; then ARG_ERR=ERR; fi if [ -n "$ARG_ERR" ]; then echo "Usage: " exit fi delay=$1 commandtorun=$2 while true; do $commandtorun sleep $delay done # The same thing can be written as a one-liner # while true; do echo ./genoutput && sleep 15; done ================================================ FILE: ejectall ================================================ #!/bin/sh # Eject all disks 2 and above. # 0 and 1 are typically Macintosh HD and the Recovery Disk diskutil list | grep '/dev/disk[2-9]' | sed 's/\/dev\//diskutil eject /' | sh ================================================ FILE: find-eclipse-workspaces ================================================ #!/bin/sh #One Approach is to CD to the folder and PWD it #set -v off #find . -type d -name .metadata | sed "s/.metadata//" | sed "s/^/pushd \"/" | sed "s/$/\"; echo \$PWD; popd/" | sh # Hints obtained from: # http://stackoverflow.com/questions/4935278/concatenate-a-string-to-the-end-of-every-output-line-in-bash-csh #A second approach is to capture $PWD and replace the ./ in the path with it find . -type d -name .metadata | sed "s/.metadata//" | sed "s/^\.//" | sed "s/\/$//" | while read line; do echo $PWD$line; done ================================================ FILE: findjarcontaining ================================================ #!/bin/sh #Example Usage: findjars com/ambientideas/groovy CLASSNAMETOFIND="$1" echo "Searching all JARs recursively..." for eachjar in `find . -iname "*.jar"` do #echo "Searching in $eachjar ..." jar tvf $eachjar | grep $CLASSNAMETOFIND > /dev/null if [ $? == 0 ] then echo "******* Located \"$CLASSNAMETOFIND\" in $eachjar *******" fi done ================================================ FILE: fixbrewperms ================================================ #!/bin/bash sudo chown -R $USER /usr/local ================================================ FILE: generaterandomchanges ================================================ #!/bin/bash #Ensure we have the quantity specified on the CLI if [ -z "$3" ]; then ARG_ERR=ERR; fi if [ -z "$2" ]; then ARG_ERR=ERR; fi if [ -z "$1" ]; then ARG_ERR=ERR; fi if [ -n "$ARG_ERR" ]; then echo "Usage: " exit fi count=$1 filenamebase=$2 filenameextension=$3 for (( filenumber = 1; filenumber <= $count ; filenumber++ )); do echo "Some new random text: $RANDOM" >> $filenamebase$filenumber.$filenameextension git add $filenamebase$filenumber.$filenameextension git commit -m"A random change of $RANDOM to $filenamebase$filenumber.$filenameextension" done ================================================ FILE: generaterandomfiles ================================================ #!/bin/bash #Ensure we have the quantity specified on the CLI if [ -z "$3" ]; then ARG_ERR=ERR; fi if [ -z "$2" ]; then ARG_ERR=ERR; fi if [ -z "$1" ]; then ARG_ERR=ERR; fi if [ -n "$ARG_ERR" ]; then echo "Usage: " exit fi count=$1 filenamebase=$2 filenameextension=$3 for (( filenumber = 1; filenumber <= $count ; filenumber++ )); do echo "Some random text: $RANDOM" > $filenamebase$filenumber.$filenameextension; done ================================================ FILE: git-cdandpull ================================================ #!/bin/bash echo =================== START ==================== pushd $1 echo Git pulling $1 from origin to master git pull origin master popd echo ==================== END ===================== ================================================ FILE: git-cdandsvnrebase ================================================ #!/bin/bash echo =================== START ==================== pushd $1 echo Git svn rebasing $1 git svn rebase popd echo ==================== END ===================== ================================================ FILE: git-completion ================================================ #!/bin/bash # # bash completion support for core Git. # # Copyright (C) 2006,2007 Shawn O. Pearce # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). # Distributed under the GNU General Public License, version 2.0. # # The contained completion routines provide support for completing: # # *) local and remote branch names # *) local and remote tag names # *) .git/remotes file names # *) git 'subcommands' # *) tree paths within 'ref:path/to/file' expressions # *) common --long-options # # To use these routines: # # 1) Copy this file to somewhere (e.g. ~/.git-completion.sh). # 2) Added the following line to your .bashrc: # source ~/.git-completion.sh # # 3) You may want to make sure the git executable is available # in your PATH before this script is sourced, as some caching # is performed while the script loads. If git isn't found # at source time then all lookups will be done on demand, # which may be slightly slower. # # 4) Consider changing your PS1 to also show the current branch: # PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ ' # # The argument to __git_ps1 will be displayed only if you # are currently in a git repository. The %s token will be # the name of the current branch. # # To submit patches: # # *) Read Documentation/SubmittingPatches # *) Send all patches to the current maintainer: # # "Shawn O. Pearce" # # *) Always CC the Git mailing list: # # git@vger.kernel.org # __gitdir () { if [ -z "$1" ]; then if [ -n "$__git_dir" ]; then echo "$__git_dir" elif [ -d .git ]; then echo .git else git rev-parse --git-dir 2>/dev/null fi elif [ -d "$1/.git" ]; then echo "$1/.git" else echo "$1" fi } __git_ps1 () { local b="$(git symbolic-ref HEAD 2>/dev/null)" if [ -n "$b" ]; then if [ -n "$1" ]; then printf "$1" "${b##refs/heads/}" else printf " (%s)" "${b##refs/heads/}" fi fi } __gitcomp () { local all c s=$'\n' IFS=' '$'\t'$'\n' local cur="${COMP_WORDS[COMP_CWORD]}" if [ $# -gt 2 ]; then cur="$3" fi for c in $1; do case "$c$4" in --*=*) all="$all$c$4$s" ;; *.) all="$all$c$4$s" ;; *) all="$all$c$4 $s" ;; esac done IFS=$s COMPREPLY=($(compgen -P "$2" -W "$all" -- "$cur")) return } __git_heads () { local cmd i is_hash=y dir="$(__gitdir "$1")" if [ -d "$dir" ]; then for i in $(git --git-dir="$dir" \ for-each-ref --format='%(refname)' \ refs/heads ); do echo "${i#refs/heads/}" done return fi for i in $(git-ls-remote "$1" 2>/dev/null); do case "$is_hash,$i" in y,*) is_hash=n ;; n,*^{}) is_hash=y ;; n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;; n,*) is_hash=y; echo "$i" ;; esac done } __git_tags () { local cmd i is_hash=y dir="$(__gitdir "$1")" if [ -d "$dir" ]; then for i in $(git --git-dir="$dir" \ for-each-ref --format='%(refname)' \ refs/tags ); do echo "${i#refs/tags/}" done return fi for i in $(git-ls-remote "$1" 2>/dev/null); do case "$is_hash,$i" in y,*) is_hash=n ;; n,*^{}) is_hash=y ;; n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;; n,*) is_hash=y; echo "$i" ;; esac done } __git_refs () { local cmd i is_hash=y dir="$(__gitdir "$1")" if [ -d "$dir" ]; then if [ -e "$dir/HEAD" ]; then echo HEAD; fi for i in $(git --git-dir="$dir" \ for-each-ref --format='%(refname)' \ refs/tags refs/heads refs/remotes); do case "$i" in refs/tags/*) echo "${i#refs/tags/}" ;; refs/heads/*) echo "${i#refs/heads/}" ;; refs/remotes/*) echo "${i#refs/remotes/}" ;; *) echo "$i" ;; esac done return fi for i in $(git-ls-remote "$dir" 2>/dev/null); do case "$is_hash,$i" in y,*) is_hash=n ;; n,*^{}) is_hash=y ;; n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;; n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;; n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;; n,*) is_hash=y; echo "$i" ;; esac done } __git_refs2 () { local i for i in $(__git_refs "$1"); do echo "$i:$i" done } __git_refs_remotes () { local cmd i is_hash=y for i in $(git-ls-remote "$1" 2>/dev/null); do case "$is_hash,$i" in n,refs/heads/*) is_hash=y echo "$i:refs/remotes/$1/${i#refs/heads/}" ;; y,*) is_hash=n ;; n,*^{}) is_hash=y ;; n,refs/tags/*) is_hash=y;; n,*) is_hash=y; ;; esac done } __git_remotes () { local i ngoff IFS=$'\n' d="$(__gitdir)" shopt -q nullglob || ngoff=1 shopt -s nullglob for i in "$d/remotes"/*; do echo ${i#$d/remotes/} done [ "$ngoff" ] && shopt -u nullglob for i in $(git --git-dir="$d" config --list); do case "$i" in remote.*.url=*) i="${i#remote.}" echo "${i/.url=*/}" ;; esac done } __git_merge_strategies () { if [ -n "$__git_merge_strategylist" ]; then echo "$__git_merge_strategylist" return fi sed -n "/^all_strategies='/{ s/^all_strategies='// s/'// p q }" "$(git --exec-path)/git-merge" } __git_merge_strategylist= __git_merge_strategylist="$(__git_merge_strategies 2>/dev/null)" __git_complete_file () { local pfx ls ref cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in ?*:*) ref="${cur%%:*}" cur="${cur#*:}" case "$cur" in ?*/*) pfx="${cur%/*}" cur="${cur##*/}" ls="$ref:$pfx" pfx="$pfx/" ;; *) ls="$ref" ;; esac COMPREPLY=($(compgen -P "$pfx" \ -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \ | sed '/^100... blob /s,^.* ,, /^040000 tree /{ s,^.* ,, s,$,/, } s/^.* //')" \ -- "$cur")) ;; *) __gitcomp "$(__git_refs)" ;; esac } __git_complete_revlist () { local pfx cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in *...*) pfx="${cur%...*}..." cur="${cur#*...}" __gitcomp "$(__git_refs)" "$pfx" "$cur" ;; *..*) pfx="${cur%..*}.." cur="${cur#*..}" __gitcomp "$(__git_refs)" "$pfx" "$cur" ;; *.) __gitcomp "$cur." ;; *) __gitcomp "$(__git_refs)" ;; esac } __git_commands () { if [ -n "$__git_commandlist" ]; then echo "$__git_commandlist" return fi local i IFS=" "$'\n' for i in $(git help -a|egrep '^ ') do case $i in *--*) : helper pattern;; applymbox) : ask gittus;; applypatch) : ask gittus;; archimport) : import;; cat-file) : plumbing;; check-attr) : plumbing;; check-ref-format) : plumbing;; commit-tree) : plumbing;; cvsexportcommit) : export;; cvsimport) : import;; cvsserver) : daemon;; daemon) : daemon;; diff-files) : plumbing;; diff-index) : plumbing;; diff-tree) : plumbing;; fast-import) : import;; fsck-objects) : plumbing;; fetch-pack) : plumbing;; fmt-merge-msg) : plumbing;; for-each-ref) : plumbing;; hash-object) : plumbing;; http-*) : transport;; index-pack) : plumbing;; init-db) : deprecated;; local-fetch) : plumbing;; mailinfo) : plumbing;; mailsplit) : plumbing;; merge-*) : plumbing;; mktree) : plumbing;; mktag) : plumbing;; pack-objects) : plumbing;; pack-redundant) : plumbing;; pack-refs) : plumbing;; parse-remote) : plumbing;; patch-id) : plumbing;; peek-remote) : plumbing;; prune) : plumbing;; prune-packed) : plumbing;; quiltimport) : import;; read-tree) : plumbing;; receive-pack) : plumbing;; reflog) : plumbing;; repo-config) : deprecated;; rerere) : plumbing;; rev-list) : plumbing;; rev-parse) : plumbing;; runstatus) : plumbing;; sh-setup) : internal;; shell) : daemon;; send-pack) : plumbing;; show-index) : plumbing;; ssh-*) : transport;; stripspace) : plumbing;; svn) : import export;; symbolic-ref) : plumbing;; tar-tree) : deprecated;; unpack-file) : plumbing;; unpack-objects) : plumbing;; update-index) : plumbing;; update-ref) : plumbing;; update-server-info) : daemon;; upload-archive) : plumbing;; upload-pack) : plumbing;; write-tree) : plumbing;; verify-tag) : plumbing;; *) echo $i;; esac done } __git_commandlist= __git_commandlist="$(__git_commands 2>/dev/null)" __git_aliases () { local i IFS=$'\n' for i in $(git --git-dir="$(__gitdir)" config --list); do case "$i" in alias.*) i="${i#alias.}" echo "${i/=*/}" ;; esac done } __git_aliased_command () { local word cmdline=$(git --git-dir="$(__gitdir)" \ config --get "alias.$1") for word in $cmdline; do if [ "${word##-*}" ]; then echo $word return fi done } __git_whitespacelist="nowarn warn error error-all strip" _git_am () { local cur="${COMP_WORDS[COMP_CWORD]}" if [ -d .dotest ]; then __gitcomp "--skip --resolved" return fi case "$cur" in --whitespace=*) __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" return ;; --*) __gitcomp " --signoff --utf8 --binary --3way --interactive --whitespace= " return esac COMPREPLY=() } _git_apply () { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --whitespace=*) __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" return ;; --*) __gitcomp " --stat --numstat --summary --check --index --cached --index-info --reverse --reject --unidiff-zero --apply --no-add --exclude= --whitespace= --inaccurate-eof --verbose " return esac COMPREPLY=() } _git_add () { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) __gitcomp "--interactive --refresh" return esac COMPREPLY=() } _git_bisect () { local i c=1 command while [ $c -lt $COMP_CWORD ]; do i="${COMP_WORDS[c]}" case "$i" in start|bad|good|reset|visualize|replay|log) command="$i" break ;; esac c=$((++c)) done if [ $c -eq $COMP_CWORD -a -z "$command" ]; then __gitcomp "start bad good reset visualize replay log" return fi case "$command" in bad|good|reset) __gitcomp "$(__git_refs)" ;; *) COMPREPLY=() ;; esac } _git_branch () { __gitcomp "$(__git_refs)" } _git_bundle () { local mycword="$COMP_CWORD" case "${COMP_WORDS[0]}" in git) local cmd="${COMP_WORDS[2]}" mycword="$((mycword-1))" ;; git-bundle*) local cmd="${COMP_WORDS[1]}" ;; esac case "$mycword" in 1) __gitcomp "create list-heads verify unbundle" ;; 2) # looking for a file ;; *) case "$cmd" in create) __git_complete_revlist ;; esac ;; esac } _git_checkout () { __gitcomp "$(__git_refs)" } _git_cherry () { __gitcomp "$(__git_refs)" } _git_cherry_pick () { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) __gitcomp "--edit --no-commit" ;; *) __gitcomp "$(__git_refs)" ;; esac } _git_commit () { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) __gitcomp " --all --author= --signoff --verify --no-verify --edit --amend --include --only " return esac COMPREPLY=() } _git_describe () { __gitcomp "$(__git_refs)" } _git_diff () { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) __gitcomp "--cached --stat --numstat --shortstat --summary --patch-with-stat --name-only --name-status --color --no-color --color-words --no-renames --check --full-index --binary --abbrev --diff-filter --find-copies-harder --pickaxe-all --pickaxe-regex --text --ignore-space-at-eol --ignore-space-change --ignore-all-space --exit-code --quiet --ext-diff --no-ext-diff" return ;; esac __git_complete_file } _git_diff_tree () { __gitcomp "$(__git_refs)" } _git_fetch () { local cur="${COMP_WORDS[COMP_CWORD]}" case "${COMP_WORDS[0]},$COMP_CWORD" in git-fetch*,1) __gitcomp "$(__git_remotes)" ;; git,2) __gitcomp "$(__git_remotes)" ;; *) case "$cur" in *:*) __gitcomp "$(__git_refs)" "" "${cur#*:}" ;; *) local remote case "${COMP_WORDS[0]}" in git-fetch) remote="${COMP_WORDS[1]}" ;; git) remote="${COMP_WORDS[2]}" ;; esac __gitcomp "$(__git_refs2 "$remote")" ;; esac ;; esac } _git_format_patch () { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) __gitcomp " --stdout --attach --thread --output-directory --numbered --start-number --numbered-files --keep-subject --signoff --in-reply-to= --full-index --binary --not --all " return ;; esac __git_complete_revlist } _git_gc () { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) __gitcomp "--prune --aggressive" return ;; esac COMPREPLY=() } _git_ls_remote () { __gitcomp "$(__git_remotes)" } _git_ls_tree () { __git_complete_file } _git_log () { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --pretty=*) __gitcomp " oneline short medium full fuller email raw " "" "${cur##--pretty=}" return ;; --date=*) __gitcomp " relative iso8601 rfc2822 short local default " "" "${cur##--date=}" return ;; --*) __gitcomp " --max-count= --max-age= --since= --after= --min-age= --before= --until= --root --topo-order --date-order --reverse --no-merges --follow --abbrev-commit --abbrev= --relative-date --date= --author= --committer= --grep= --all-match --pretty= --name-status --name-only --raw --not --all --left-right --cherry-pick " return ;; esac __git_complete_revlist } _git_merge () { local cur="${COMP_WORDS[COMP_CWORD]}" case "${COMP_WORDS[COMP_CWORD-1]}" in -s|--strategy) __gitcomp "$(__git_merge_strategies)" return esac case "$cur" in --strategy=*) __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}" return ;; --*) __gitcomp " --no-commit --no-summary --squash --strategy " return esac __gitcomp "$(__git_refs)" } _git_merge_base () { __gitcomp "$(__git_refs)" } _git_name_rev () { __gitcomp "--tags --all --stdin" } _git_pull () { local cur="${COMP_WORDS[COMP_CWORD]}" case "${COMP_WORDS[0]},$COMP_CWORD" in git-pull*,1) __gitcomp "$(__git_remotes)" ;; git,2) __gitcomp "$(__git_remotes)" ;; *) local remote case "${COMP_WORDS[0]}" in git-pull) remote="${COMP_WORDS[1]}" ;; git) remote="${COMP_WORDS[2]}" ;; esac __gitcomp "$(__git_refs "$remote")" ;; esac } _git_push () { local cur="${COMP_WORDS[COMP_CWORD]}" case "${COMP_WORDS[0]},$COMP_CWORD" in git-push*,1) __gitcomp "$(__git_remotes)" ;; git,2) __gitcomp "$(__git_remotes)" ;; *) case "$cur" in *:*) local remote case "${COMP_WORDS[0]}" in git-push) remote="${COMP_WORDS[1]}" ;; git) remote="${COMP_WORDS[2]}" ;; esac __gitcomp "$(__git_refs "$remote")" "" "${cur#*:}" ;; +*) __gitcomp "$(__git_refs)" + "${cur#+}" ;; *) __gitcomp "$(__git_refs)" ;; esac ;; esac } _git_rebase () { local cur="${COMP_WORDS[COMP_CWORD]}" if [ -d .dotest ] || [ -d .git/.dotest-merge ]; then __gitcomp "--continue --skip --abort" return fi case "${COMP_WORDS[COMP_CWORD-1]}" in -s|--strategy) __gitcomp "$(__git_merge_strategies)" return esac case "$cur" in --strategy=*) __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}" return ;; --*) __gitcomp "--onto --merge --strategy" return esac __gitcomp "$(__git_refs)" } _git_config () { local cur="${COMP_WORDS[COMP_CWORD]}" local prv="${COMP_WORDS[COMP_CWORD-1]}" case "$prv" in branch.*.remote) __gitcomp "$(__git_remotes)" return ;; branch.*.merge) __gitcomp "$(__git_refs)" return ;; remote.*.fetch) local remote="${prv#remote.}" remote="${remote%.fetch}" __gitcomp "$(__git_refs_remotes "$remote")" return ;; remote.*.push) local remote="${prv#remote.}" remote="${remote%.push}" __gitcomp "$(git --git-dir="$(__gitdir)" \ for-each-ref --format='%(refname):%(refname)' \ refs/heads)" return ;; pull.twohead|pull.octopus) __gitcomp "$(__git_merge_strategies)" return ;; color.branch|color.diff|color.status) __gitcomp "always never auto" return ;; color.*.*) __gitcomp " black red green yellow blue magenta cyan white bold dim ul blink reverse " return ;; *.*) COMPREPLY=() return ;; esac case "$cur" in --*) __gitcomp " --global --system --file= --list --replace-all --get --get-all --get-regexp --add --unset --unset-all --remove-section --rename-section " return ;; branch.*.*) local pfx="${cur%.*}." cur="${cur##*.}" __gitcomp "remote merge" "$pfx" "$cur" return ;; branch.*) local pfx="${cur%.*}." cur="${cur#*.}" __gitcomp "$(__git_heads)" "$pfx" "$cur" "." return ;; remote.*.*) local pfx="${cur%.*}." cur="${cur##*.}" __gitcomp " url fetch push skipDefaultUpdate receivepack uploadpack tagopt " "$pfx" "$cur" return ;; remote.*) local pfx="${cur%.*}." cur="${cur#*.}" __gitcomp "$(__git_remotes)" "$pfx" "$cur" "." return ;; esac __gitcomp " apply.whitespace core.fileMode core.gitProxy core.ignoreStat core.preferSymlinkRefs core.logAllRefUpdates core.loosecompression core.repositoryFormatVersion core.sharedRepository core.warnAmbiguousRefs core.compression core.legacyHeaders core.packedGitWindowSize core.packedGitLimit clean.requireForce color.branch color.branch.current color.branch.local color.branch.remote color.branch.plain color.diff color.diff.plain color.diff.meta color.diff.frag color.diff.old color.diff.new color.diff.commit color.diff.whitespace color.pager color.status color.status.header color.status.added color.status.changed color.status.untracked diff.renameLimit diff.renames fetch.unpackLimit format.headers format.subjectprefix gitcvs.enabled gitcvs.logfile gitcvs.allbinary gitcvs.dbname gitcvs.dbdriver gitcvs.dbuser gitcvs.dvpass gc.packrefs gc.reflogexpire gc.reflogexpireunreachable gc.rerereresolved gc.rerereunresolved http.sslVerify http.sslCert http.sslKey http.sslCAInfo http.sslCAPath http.maxRequests http.lowSpeedLimit http.lowSpeedTime http.noEPSV i18n.commitEncoding i18n.logOutputEncoding log.showroot merge.tool merge.summary merge.verbosity pack.window pack.depth pack.windowMemory pack.compression pack.deltaCacheSize pack.deltaCacheLimit pull.octopus pull.twohead repack.useDeltaBaseOffset show.difftree showbranch.default tar.umask transfer.unpackLimit receive.unpackLimit receive.denyNonFastForwards user.name user.email user.signingkey whatchanged.difftree branch. remote. " } _git_remote () { local i c=1 command while [ $c -lt $COMP_CWORD ]; do i="${COMP_WORDS[c]}" case "$i" in add|rm|show|prune|update) command="$i"; break ;; esac c=$((++c)) done if [ $c -eq $COMP_CWORD -a -z "$command" ]; then __gitcomp "add rm show prune update" return fi case "$command" in rm|show|prune) __gitcomp "$(__git_remotes)" ;; update) local i c='' IFS=$'\n' for i in $(git --git-dir="$(__gitdir)" config --list); do case "$i" in remotes.*) i="${i#remotes.}" c="$c ${i/=*/}" ;; esac done __gitcomp "$c" ;; *) COMPREPLY=() ;; esac } _git_reset () { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) __gitcomp "--mixed --hard --soft" return ;; esac __gitcomp "$(__git_refs)" } _git_shortlog () { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) __gitcomp " --max-count= --max-age= --since= --after= --min-age= --before= --until= --no-merges --author= --committer= --grep= --all-match --not --all --numbered --summary " return ;; esac __git_complete_revlist } _git_show () { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --pretty=*) __gitcomp " oneline short medium full fuller email raw " "" "${cur##--pretty=}" return ;; --*) __gitcomp "--pretty=" return ;; esac __git_complete_file } _git_stash () { __gitcomp 'list show apply clear' } _git_submodule () { local i c=1 command while [ $c -lt $COMP_CWORD ]; do i="${COMP_WORDS[c]}" case "$i" in add|status|init|update) command="$i"; break ;; esac c=$((++c)) done if [ $c -eq $COMP_CWORD -a -z "$command" ]; then local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) __gitcomp "--quiet --cached" ;; *) __gitcomp "add status init update" ;; esac return fi } _git_tag () { local i c=1 f=0 while [ $c -lt $COMP_CWORD ]; do i="${COMP_WORDS[c]}" case "$i" in -d|-v) __gitcomp "$(__git_tags)" return ;; -f) f=1 ;; esac c=$((++c)) done case "${COMP_WORDS[COMP_CWORD-1]}" in -m|-F) COMPREPLY=() ;; -*|tag|git-tag) if [ $f = 1 ]; then __gitcomp "$(__git_tags)" else COMPREPLY=() fi ;; *) __gitcomp "$(__git_refs)" ;; esac } _git () { local i c=1 command __git_dir while [ $c -lt $COMP_CWORD ]; do i="${COMP_WORDS[c]}" case "$i" in --git-dir=*) __git_dir="${i#--git-dir=}" ;; --bare) __git_dir="." ;; --version|--help|-p|--paginate) ;; *) command="$i"; break ;; esac c=$((++c)) done if [ $c -eq $COMP_CWORD -a -z "$command" ]; then case "${COMP_WORDS[COMP_CWORD]}" in --*=*) COMPREPLY=() ;; --*) __gitcomp " --no-pager --git-dir= --bare --version --exec-path " ;; *) __gitcomp "$(__git_commands) $(__git_aliases)" ;; esac return fi local expansion=$(__git_aliased_command "$command") [ "$expansion" ] && command="$expansion" case "$command" in am) _git_am ;; add) _git_add ;; apply) _git_apply ;; bisect) _git_bisect ;; bundle) _git_bundle ;; branch) _git_branch ;; checkout) _git_checkout ;; cherry) _git_cherry ;; cherry-pick) _git_cherry_pick ;; commit) _git_commit ;; config) _git_config ;; describe) _git_describe ;; diff) _git_diff ;; fetch) _git_fetch ;; format-patch) _git_format_patch ;; gc) _git_gc ;; log) _git_log ;; ls-remote) _git_ls_remote ;; ls-tree) _git_ls_tree ;; merge) _git_merge;; merge-base) _git_merge_base ;; name-rev) _git_name_rev ;; pull) _git_pull ;; push) _git_push ;; rebase) _git_rebase ;; remote) _git_remote ;; reset) _git_reset ;; shortlog) _git_shortlog ;; show) _git_show ;; show-branch) _git_log ;; stash) _git_stash ;; submodule) _git_submodule ;; tag) _git_tag ;; whatchanged) _git_log ;; *) COMPREPLY=() ;; esac } _gitk () { local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) __gitcomp "--not --all" return ;; esac __git_complete_revlist } complete -o default -o nospace -F _git git complete -o default -o nospace -F _gitk gitk complete -o default -o nospace -F _git_am git-am complete -o default -o nospace -F _git_apply git-apply complete -o default -o nospace -F _git_bisect git-bisect complete -o default -o nospace -F _git_branch git-branch complete -o default -o nospace -F _git_bundle git-bundle complete -o default -o nospace -F _git_checkout git-checkout complete -o default -o nospace -F _git_cherry git-cherry complete -o default -o nospace -F _git_cherry_pick git-cherry-pick complete -o default -o nospace -F _git_commit git-commit complete -o default -o nospace -F _git_describe git-describe complete -o default -o nospace -F _git_diff git-diff complete -o default -o nospace -F _git_fetch git-fetch complete -o default -o nospace -F _git_format_patch git-format-patch complete -o default -o nospace -F _git_gc git-gc complete -o default -o nospace -F _git_log git-log complete -o default -o nospace -F _git_ls_remote git-ls-remote complete -o default -o nospace -F _git_ls_tree git-ls-tree complete -o default -o nospace -F _git_merge git-merge complete -o default -o nospace -F _git_merge_base git-merge-base complete -o default -o nospace -F _git_name_rev git-name-rev complete -o default -o nospace -F _git_pull git-pull complete -o default -o nospace -F _git_push git-push complete -o default -o nospace -F _git_rebase git-rebase complete -o default -o nospace -F _git_config git-config complete -o default -o nospace -F _git_remote git-remote complete -o default -o nospace -F _git_reset git-reset complete -o default -o nospace -F _git_shortlog git-shortlog complete -o default -o nospace -F _git_show git-show complete -o default -o nospace -F _git_stash git-stash complete -o default -o nospace -F _git_submodule git-submodule complete -o default -o nospace -F _git_log git-show-branch complete -o default -o nospace -F _git_tag git-tag complete -o default -o nospace -F _git_log git-whatchanged # The following are necessary only for Cygwin, and only are needed # when the user has tab-completed the executable name and consequently # included the '.exe' suffix. # if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then complete -o default -o nospace -F _git_add git-add.exe complete -o default -o nospace -F _git_apply git-apply.exe complete -o default -o nospace -F _git git.exe complete -o default -o nospace -F _git_branch git-branch.exe complete -o default -o nospace -F _git_bundle git-bundle.exe complete -o default -o nospace -F _git_cherry git-cherry.exe complete -o default -o nospace -F _git_describe git-describe.exe complete -o default -o nospace -F _git_diff git-diff.exe complete -o default -o nospace -F _git_format_patch git-format-patch.exe complete -o default -o nospace -F _git_log git-log.exe complete -o default -o nospace -F _git_ls_tree git-ls-tree.exe complete -o default -o nospace -F _git_merge_base git-merge-base.exe complete -o default -o nospace -F _git_name_rev git-name-rev.exe complete -o default -o nospace -F _git_push git-push.exe complete -o default -o nospace -F _git_config git-config complete -o default -o nospace -F _git_shortlog git-shortlog.exe complete -o default -o nospace -F _git_show git-show.exe complete -o default -o nospace -F _git_log git-show-branch.exe complete -o default -o nospace -F _git_tag git-tag.exe complete -o default -o nospace -F _git_log git-whatchanged.exe fi ================================================ FILE: git-compressallrepos ================================================ #!/bin/bash find . -path '*.git/config' -execdir git gc --aggressive \; ================================================ FILE: git-deletealltags ================================================ for t in `git tag` do git push origin :$t git tag -d $t done ================================================ FILE: git-draw ================================================ #!/bin/sh # # NAME # git-draw - draws nearly the full content of a tiny git repository as a graph # # SYNOPSIS # git-draw [OPTION]... # # PREREQUISITES # You don't need graphviz or imagemagick if you use git-draw with certain # options. # # - perl # - graphviz (http://www.graphviz.org/) # - imagemagick (http://www.imagemagick.org) # # If you have apt you can install these with: # # sudo apt-get install perl graphviz imagemagick # # DESCRIPTION # git-draw is composed of three main steps, where the 2nd and 3rd are just # for convenience and are not part of git-draw's core responsibility. # # 1) A .dot file describing the repository's content as a graph is created. # 2) dot (see graphviz) is called to produce an image out of that .dot file. # 3) display (see imagemagick) is called to display that image. # # Because git-draw currently is quite dumb, the current working directory # must be at the root of the working tree of your project, i.e. the # directory which contains the .git directory. # # The intention is to help learning Git's basic concepts (references, Git # objects, SHA-1 checksum over content as id). Virtually all information # concerning Git's basic concepts is contained in the drawing. Thus git-draw # is aimed at tiny toy Git repositories and at users with an engineer # background, i.e. users which are not scared off by terms like checksum, # references aka pointers and graphs. # # OPTIONS # -p, --print-only # Only prints the .dot file to STDOUT. Mutually exclusive with # --image-only. # # -i, --image-only # Only generates an image of the graph, and a .dot file beforehand. # Mutually exclusive with --print-only. # # AUTHOR # Written by Florian Kaufmann # # COPYRIGHT # Florian Kaufmann 2014. License GPLv3+: GNU GPL version 3 or later # . This is free software: you are free to # change and redistribute it. There is NO WARRANTY, to the extent permitted # by law. # # SEE ALSO # git(1) # $1 = exit code print_usage_and_exit() { cat < _" . `git rev-parse --short=4 $1` if /([a-f0-9]{40})/' done git fsck --cache --unreachable --dangling 2>/dev/null | perl -ne 'print " _" . substr(`git rev-parse --short=4 $1`,0,-1) . " [style=dotted]\n" if /^(?:dangling|unreachable)\b.*?([a-f0-9]{40})/' } print_dot_references() { ls_all_refs | perl -ne ' if (m@(\S+)\s+(\S+?)$@) { $me = $2; $other = $1; $dotid_me = "_" . (($tmp = $me) =~ s@([^a-zA-Z0-9_])@___@g,$tmp); $dotid_other = "_" . (($tmp = $other) =~ s@([^a-zA-Z0-9_])@___@g,$tmp); ($otherquoted = $other) =~ s/([^a-zA-Z0-9\n])/\\$1/g; ($mequoted = $me) =~ s/([^a-zA-Z0-9\n])/\\$1/g; $reftype = ""; $fillcolor = "gray"; $configmetadata = ""; if ($me =~ m@^refs/heads/@) { $reftype = ":local branch"; ($me_short = $me) =~ s@^refs/heads/@@; $remote = substr(`git config --get branch\\.$me_short\\.remote`,0,-1); $merge = substr(`git config --get branch\\.$me_short\\.merge`,0,-1); if ($remote && $merge) { if ($remote eq ".") { $dotid_merge = "_" . (($tmp = $merge) =~ s@([^a-zA-Z0-9_])@___@g,$tmp); } else { $dotid_merge_core = $merge; $dotid_merge_core =~ s@^refs/heads/@@; $dotid_merge_core =~ s@([^a-zA-Z0-9_])@___@g; $dotid_remote = (($tmp = $remote) =~ s@([^a-zA-Z0-9_])@___@g,$tmp); $dotid_merge = "_refs___remotes___${dotid_remote}___${dotid_merge_core}"; } print " $dotid_me -> $dotid_merge [style=dotted, color=gray, fontcolor=gray, " . "label=\"upstream branch\"]\n"; $tmp = "remote = $remote\nmerge = $merge\n"; $tmp =~ s/([^a-zA-Z0-9\n])/\\$1/g; # quote for dot $tmp =~ s/\n/\\l/g; # \l instead \n newline $configmetadata = "|$tmp" } } elsif ($me =~ m@^refs/remotes/@) { $reftype = ":remote tracking branch"; $fillcolor = "yellow"; } elsif ($me =~ m@^refs/tags/@) { $reftype = ":tag"; $fillcolor = "lightyellow"; } if ( ($other !~ m/^[a-f0-9]+$/) && 0!=system("git show-ref --verify --quiet -- $other") ) { print " $dotid_me [style=filled, fillcolor=red, " . "label=\"{{ref$reftype|$mequoted}|" . "$otherquoted (referee does not exist)\\l$configmetadata}\"]\n"; } else { if ($me eq "HEAD") { $fillcolor="gray30"; $fontcolorelement = "fontcolor=white, "; } print " $dotid_me [style=filled, fillcolor=$fillcolor, $fontcolorelement " . "label=\"{{ref$reftype|$mequoted}|$otherquoted\\l$configmetadata}\"]\n"; print " $dotid_me -> $dotid_other\n"; } }' } print_dot_ref_logs() { firstiter="non-empty-string" # i.e. true git show-ref --abbrev=4 | # The following code depends upon HEAD being the last in the list perl -pe 's@^.*?(\brefs/\S*)$@$1@; END { print "HEAD\n";}' | while read refname; do # work around the problem that 'git reflog show HEAD' results in an # error when HEAD contains refs/heads/master but refs/heads/master does # not exist, which is the case after 'git init'. if [ ! \( "$firstiter" -a \( "$refname" = HEAD \) \) ]; then # 8eb068f master@{11}: commit: tempo-ext: new version git reflog show $refname | perl -ne ' BEGIN { $refname = "'$refname'"; $dotid_reflog = "reflog_" . (($tmp = $refname) =~ s@([^a-zA-Z0-9_])@___@g,$tmp); } if (m/^([a-f0-9]+).*@\{\d+\}: (.*?)$/) { $id_any=$1; $msg=$2; } elsif (m/^([a-f0-9]+)/) { $id_any=$1; $msg=""; } $id_short = substr(`git rev-parse --short=4 $id_any`,0,-1); print " $dotid_reflog -> _$id_short [color=gray90]\n"; s/^[a-f0-9]+//; # strip sha1; $id_short will be used instead s/([^a-zA-Z0-9\n])/\\$1/g; # quote for dot s/(\r?\n)?$/\\l/; # \l instead \n newline, and ensure \l at # end of content $content = $content . $id_short . $_; END { $trailing = (substr($content,-2) eq "\\l") ? "" : "\\l"; print " $dotid_reflog [color=gray90, fontcolor=gray, " . "label=\"{{reflog|logs/$refname}|$content$trailing}\"]\n"; }' fi firstiter="" # empty stringt, i.e. false done } print_dot_index() { git ls-files --stage --abbrev=4 | perl -ne ' if (/^[0-9]+\s+([a-f0-9]+)/) { print " index -> _$1\n"; s/([^a-zA-Z0-9\r\n])/\\$1/g; # quote for dot s/(\r?\n)?$/\\l/; # \l instead \n newline, and ensure \l at # end of content $content = $content . $_; } END { $trailing = (substr($content,-2) eq "\\l") ? "" : "\\l"; print " index [style=filled, fillcolor=lightcyan, " . "label=\"{{index}|$content$trailing}\"]\n"; }' } print_dot() { echo "digraph structs {" echo " node [shape=record,fontsize=11];" echo " subgraph cluster_0 {" echo " color=gray80;" echo " label = \"legend\\l\";" echo " legend_node [label=\"{{type:subtype|id/name}|content\\l|metadata from config\\l}\"]" echo " }" print_dot_objects print_dot_references print_dot_ref_logs print_dot_index echo "}" } # process options dotfilename=git-draw.dot imgfilename=git-draw.png if [ $# = 0 ]; then : elif [ \( $# = 1 \) -a \( "$1" = "-p" -o "$1" = "--print-only" \) ] ; then print_only=1 elif [ \( $# = 1 \) -a \( "$1" = "-i" -o "$1" = "--image-only" \) ] ; then image_only=1 elif [ \( $# = 1 \) -a \( "$1" = "--help" \) ] ; then print_usage_and_exit 0 else echo "Invalid options" >&2 print_usage_and_exit 1 >&2 exit 1 fi # check preconditions if [ ! -d .git ]; then echo "Not a git repository" >&2 exit 1 fi if ! which perl >&2 >/dev/null; then cat >&2 <"$dotfilename" || exit 1 # build and image out of the .dot file if ! which dot >&2 >/dev/null; then cat >&2 < "$imgfilename" || exit 1 # display image if [ "$image_only" = 1 ] ; then exit 0 fi if ! which display >&2 >/dev/null; then cat >&2 </dev/null # Switch to the git-enabled project directory if [ "$1" = "-v" ]; then echo "TESTING:" $gitprojpath fi cd $gitprojpath # Are there any changed files in the status output? isdirty=$(git status -s | grep "^.*") if [ -n "$isdirty" ]; then # Should output be verbose? if [ "$1" = "-vv" ]; then echo "DIRTY:" $gitprojpath git status -s # Or should output be quiet? else echo "DIRTY:" $gitprojpath fi fi # Return to the starting directory, suppressing the output popd >/dev/null done # restore the input field separator IFS=$OLDIFS ================================================ FILE: git-findunpushed ================================================ #!/bin/bash ############################################################################## # Find any dirty git projects in the current working directory # and recursively beneath this directory # # USAGE: # finddirtygit # Quiet mode that outputs only the project that is dirty # finddirtygit -v # Verbose mode that outputs what folders are being tested # finddirtygit -vv # Very verbose mode that outputs what files are dirty ############################################################################## # Preserve the old input field separator OLDIFS=$IFS # Change the input field separator from a space to a null IFS=$'\n' # Find all directories that have a .git directory in them for gitprojpath in `find . -type d -name .git | sort | sed "s/\/\.git//"`; do # Save the current working directory before CDing for git's purpose pushd . >/dev/null # Switch to the git-enabled project directory if [ "$1" = "-v" ]; then echo "TESTING:" $gitprojpath fi cd $gitprojpath # Are there any changed files in the status output? isdirty=$(git wtf | grep "you should push") if [ -n "$isdirty" ]; then # Should output be verbose? if [ "$1" = "-vv" ]; then echo "DIRTY:" $gitprojpath git wtf echo # Or should output be quiet? else echo "DIRTY:" $gitprojpath fi fi # Return to the starting directory, suppressing the output popd >/dev/null done # restore the input field separator IFS=$OLDIFS ================================================ FILE: git-gc_recursive ================================================ #!/bin/bash find . -iname .git -type d | sed "s/\(.*\)/pushd \"\1\"; git gc; popd/" | sh ================================================ FILE: git-graphlive ================================================ #!/bin/bash numRegex='[0-9]+$' usrLen=$1 usrTime=$2 defLen=15 defTime=3 # Command line argument processing if [[ $usrLen =~ $numRegex && $usrTime =~ $numRegex ]]; then # A valid number of lines and refresh rate were passed in else # Invalid or no lines and refresh rate were provided # so instead, using defaults instead. usrLen=$defLen usrTime=$defTime fi # Infinite loop for displaying a portion of the graph # at specified refresh intervals. while : do clear git --no-pager log -$usrLen --graph --all --pretty=format:'%Cgreen%h%Creset -%C(yellow)%d%Creset %s' --abbrev-commit --date=relative sleep $usrTime done ================================================ FILE: git-plotrepo.rb ================================================ #!/usr/bin/env ruby # Usage: ruby plotrepo.rb /path/to/repository | dot -Tpng | display -antialias require 'grit' $commits = {} def commit_node_label(commit) return "#{commit.id.slice 0,5}\\n(#{commit.message.split("\n")[0]})" end def plot_tree (commit) if $commits.has_key? commit.id return else $commits[commit.id] = 1 commit.parents.each do |c| puts "\"#{commit_node_label commit}\" -> \"#{commit_node_label c}\";" plot_tree(c) end end end def plot_tags(repo) repo.tags.each do |tag| puts "\"#{tag.name}\" -> \"#{commit_node_label tag.commit}\";" puts "\"#{tag.name}\" [shape=box, style=filled, color = yellow];" end end def draw_head(repo) head = repo.head.name; puts "\"HEAD\" [shape=box, style=filled, color = green];" puts "\"HEAD\" -> \"#{head}\";" end def draw_branch_heads(repo) repo.branches.each do |b| puts "\"#{b.name}\" -> \"#{commit_node_label b.commit}\";" puts "\"#{b.name}\" [shape=polygon, sides=6, style=filled, color = red];" plot_tree(b.commit) end end puts "Digraph F {" puts 'ranksep=0.5; size = "17.5,7.5"; rankdir=RL;' repo = Grit::Repo.new(ARGV[0]); draw_branch_heads(repo) plot_tags(repo) draw_head(repo) puts "}" ================================================ FILE: git-publish-branch ================================================ #!/usr/bin/env ruby ## git-publish-branch: a simple script to ease the unnecessarily complex ## task of "publishing" a branch, i.e., taking a local branch, creating a ## reference to it on a remote repo, and setting up the local branch to ## track the remote one, all in one go. you can even delete that remote ## reference. ## ## Usage: git publish-branch [-d] [repository] ## ## '-d' signifies deletion. is the branch to publish, and ## [repository] defaults to "origin". The remote branch name will be the ## same as the local branch name. Don't make life unnecessarily complex ## for yourself. ## ## Note that unpublishing a branch doesn't delete the local branch. ## Safety first! ## ## git-publish-branch Copyright 2008 William Morgan . ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or (at ## your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You can find the GNU General Public License at: ## http://www.gnu.org/licenses/ def exec cmd puts cmd system cmd or abort unless $fake end head = `git symbolic-ref HEAD`.chomp.gsub(/refs\/heads\//, "") delete = ARGV.delete "-d" $fake = ARGV.delete "-n" branch = (ARGV.shift || head).gsub(/refs\/heads\//, "") remote = ARGV.shift || "origin" local_ref = `git show-ref heads/#{branch}` remote_ref = `git show-ref remotes/#{remote}/#{branch}` remote_config = `git config branch.#{branch}.merge` if delete ## we don't do any checking here because the remote branch might actually ## exist, whether we actually know about it or not. exec "git push #{remote} :refs/heads/#{branch}" unless local_ref.empty? exec "git config --unset branch.#{branch}.remote" exec "git config --unset branch.#{branch}.merge" end else abort "No local branch #{branch} exists!" if local_ref.empty? abort "A remote branch #{branch} on #{remote} already exists!" unless remote_ref.empty? abort "Local branch #{branch} is already a tracking branch!" unless remote_config.empty? exec "git push #{remote} #{branch}:refs/heads/#{branch}" exec "git config branch.#{branch}.remote #{remote}" exec "git config branch.#{branch}.merge refs/heads/#{branch}" end ================================================ FILE: git-rank-contributors ================================================ #!/usr/bin/env ruby ## git-rank-contributors: a simple script to trace through the logs and ## rank contributors by the total size of the diffs they're responsible for. ## A change counts twice as much as a plain addition or deletion. ## ## Output may or may not be suitable for inclusion in a CREDITS file. ## Probably not without some editing, because people often commit from more ## than one address. ## ## git-rank-contributors Copyright 2008 William Morgan . ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or (at ## your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You can find the GNU General Public License at: ## http://www.gnu.org/licenses/ class String def obfuscate; gsub(/@/, " at the ").gsub(/\.(\w+)(>|$)/, ' dot \1s\2') end def htmlize; gsub("&", "&").gsub("<", "<").gsub(">", ">") end end lines = {} verbose = ARGV.delete("-v") obfuscate = ARGV.delete("-o") htmlize = ARGV.delete("-h") author = nil state = :pre_author `git log -M -C -C -p --no-color`.each do |l| case when (state == :pre_author || state == :post_author) && l =~ /Author: (.*)$/ author = $1 state = :post_author lines[author] ||= 0 when state == :post_author && l =~ /^\+\+\+/ state = :in_diff when state == :in_diff && l =~ /^[\+\-]/ lines[author] += 1 when state == :in_diff && l =~ /^commit / state = :pre_author end end lines.sort_by { |a, c| -c }.each do |a, c| a = a.obfuscate if obfuscate a = a.htmlize if htmlize if verbose puts "#{a}: #{c} lines of diff" else puts a end end ================================================ FILE: git-rmignored ================================================ #!/bin/sh # Git Remove (from version control) any file that is covered by the ignore patterns and exists on the filesystem. Could be improved to further check the file exists on the git filesystem too. for eachthing in `git ls-files --others --ignored --exclude-standard`; do if [ -e "$eachthing" ]; then git rm $eachthing; fi; done ================================================ FILE: git-wtf ================================================ #!/usr/bin/env ruby HELP = < .git-wtfrc" and edit it. The config file is a YAML file that specifies the integration branches, any branches to ignore, and the max number of commits to display when --all-commits isn't used. git-wtf will look for a .git-wtfrc file starting in the current directory, and recursively up to the root. IMPORTANT NOTE: all local branches referenced in .git-wtfrc must be prefixed with heads/, e.g. "heads/master". Remote branches must be of the form remotes//. EOS COPYRIGHT = <. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You can find the GNU General Public License at: http://www.gnu.org/licenses/ EOS require 'yaml' CONFIG_FN = ".git-wtfrc" class Numeric; def pluralize s; "#{to_s} #{s}" + (self != 1 ? "s" : "") end end if ARGV.delete("--help") || ARGV.delete("-h") puts USAGE exit end ## poor man's trollop $long = ARGV.delete("--long") || ARGV.delete("-l") $short = ARGV.delete("--short") || ARGV.delete("-s") $all = ARGV.delete("--all") || ARGV.delete("-a") $all_commits = ARGV.delete("--all-commits") || ARGV.delete("-A") $dump_config = ARGV.delete("--dump-config") $key = ARGV.delete("--key") || ARGV.delete("-k") $show_relations = ARGV.delete("--relations") || ARGV.delete("-r") ARGV.each { |a| abort "Error: unknown argument #{a}." if a =~ /^--/ } ## search up the path for a file def find_file fn while true return fn if File.exist? fn fn2 = File.join("..", fn) return nil if File.expand_path(fn2) == File.expand_path(fn) fn = fn2 end end want_color = `git config color.wtf` want_color = `git config color.ui` if want_color.empty? $color = case want_color.chomp when "true"; true when "auto"; $stdout.tty? end def red s; $color ? "\033[31m#{s}\033[0m" : s end def green s; $color ? "\033[32m#{s}\033[0m" : s end def yellow s; $color ? "\033[33m#{s}\033[0m" : s end def cyan s; $color ? "\033[36m#{s}\033[0m" : s end def grey s; $color ? "\033[1;30m#{s}\033[0m" : s end def purple s; $color ? "\033[35m#{s}\033[0m" : s end ## the set of commits in 'to' that aren't in 'from'. ## if empty, 'to' has been merged into 'from'. def commits_between from, to if $long `git log --pretty=format:"- %s [#{yellow "%h"}] (#{purple "%ae"}; %ar)" #{from}..#{to}` else `git log --pretty=format:"- %s [#{yellow "%h"}]" #{from}..#{to}` end.split(/[\r\n]+/) end def show_commits commits, prefix=" " if commits.empty? puts "#{prefix} none" else max = $all_commits ? commits.size : $config["max_commits"] max -= 1 if max == commits.size - 1 # never show "and 1 more" commits[0 ... max].each { |c| puts "#{prefix}#{c}" } puts grey("#{prefix}... and #{commits.size - max} more (use -A to see all).") if commits.size > max end end def ahead_behind_string ahead, behind [ahead.empty? ? nil : "#{ahead.size.pluralize 'commit'} ahead", behind.empty? ? nil : "#{behind.size.pluralize 'commit'} behind"]. compact.join("; ") end def widget merged_in, remote_only=false, local_only=false, local_only_merge=false left, right = case when remote_only; %w({ }) when local_only; %w{( )} else %w([ ]) end middle = case when merged_in && local_only_merge; green("~") when merged_in; green("x") else " " end print left, middle, right end def show b have_both = b[:local_branch] && b[:remote_branch] pushc, pullc, oosync = if have_both [x = commits_between(b[:remote_branch], b[:local_branch]), y = commits_between(b[:local_branch], b[:remote_branch]), !x.empty? && !y.empty?] end if b[:local_branch] puts "Local branch: " + green(b[:local_branch].sub(/^heads\//, "")) if have_both if pushc.empty? puts "#{widget true} in sync with remote" else action = oosync ? "push after rebase / merge" : "push" puts "#{widget false} NOT in sync with remote (you should #{action})" show_commits pushc unless $short end end end if b[:remote_branch] puts "Remote branch: #{cyan b[:remote_branch]} (#{b[:remote_url]})" if have_both if pullc.empty? puts "#{widget true} in sync with local" else action = pushc.empty? ? "merge" : "rebase / merge" puts "#{widget false} NOT in sync with local (you should #{action})" show_commits pullc unless $short end end end puts "\n#{red "WARNING"}: local and remote branches have diverged. A merge will occur unless you rebase." if oosync end def show_relations b, all_branches ibs, fbs = all_branches.partition { |name, br| $config["integration-branches"].include?(br[:local_branch]) || $config["integration-branches"].include?(br[:remote_branch]) } if $config["integration-branches"].include? b[:local_branch] puts "\nFeature branches:" unless fbs.empty? fbs.each do |name, br| next if $config["ignore"].member?(br[:local_branch]) || $config["ignore"].member?(br[:remote_branch]) next if br[:ignore] local_only = br[:remote_branch].nil? remote_only = br[:local_branch].nil? name = if local_only purple br[:name] elsif remote_only cyan br[:name] else green br[:name] end ## for remote_only branches, we'll compute wrt the remote branch head. otherwise, we'll ## use the local branch head. head = remote_only ? br[:remote_branch] : br[:local_branch] remote_ahead = b[:remote_branch] ? commits_between(b[:remote_branch], head) : [] local_ahead = b[:local_branch] ? commits_between(b[:local_branch], head) : [] if local_ahead.empty? && remote_ahead.empty? puts "#{widget true, remote_only, local_only} #{name} #{local_only ? "(local-only) " : ""}is merged in" elsif local_ahead.empty? puts "#{widget true, remote_only, local_only, true} #{name} merged in (only locally)" else behind = commits_between head, (br[:local_branch] || br[:remote_branch]) ahead = remote_only ? remote_ahead : local_ahead puts "#{widget false, remote_only, local_only} #{name} #{local_only ? "(local-only) " : ""}is NOT merged in (#{ahead_behind_string ahead, behind})" show_commits ahead unless $short end end else puts "\nIntegration branches:" unless ibs.empty? # unlikely ibs.sort_by { |v, br| v }.each do |v, br| next if $config["ignore"].member?(br[:local_branch]) || $config["ignore"].member?(br[:remote_branch]) next if br[:ignore] local_only = br[:remote_branch].nil? remote_only = br[:local_branch].nil? name = remote_only ? cyan(br[:name]) : green(br[:name]) ahead = commits_between v, (b[:local_branch] || b[:remote_branch]) if ahead.empty? puts "#{widget true, local_only} merged into #{name}" else #behind = commits_between b[:local_branch], v puts "#{widget false, local_only} NOT merged into #{name} (#{ahead.size.pluralize 'commit'} ahead)" show_commits ahead unless $short end end end end #### EXECUTION STARTS HERE #### ## find config file and load it $config = { "integration-branches" => %w(heads/master heads/next heads/edge), "ignore" => [], "max_commits" => 5 }.merge begin fn = find_file CONFIG_FN if fn && (h = YAML::load_file(fn)) # yaml turns empty files into false h["integration-branches"] ||= h["versions"] # support old nomenclature h else {} end end if $dump_config puts $config.to_yaml exit end ## first, index registered remotes remotes = `git config --get-regexp ^remote\.\*\.url`.split(/[\r\n]+/).inject({}) do |hash, l| l =~ /^remote\.(.+?)\.url (.+)$/ or next hash hash[$1] ||= $2 hash end ## next, index followed branches branches = `git config --get-regexp ^branch\.`.split(/[\r\n]+/).inject({}) do |hash, l| case l when /branch\.(.*?)\.remote (.+)/ name, remote = $1, $2 hash[name] ||= {} hash[name].merge! :remote => remote, :remote_url => remotes[remote] when /branch\.(.*?)\.merge ((refs\/)?heads\/)?(.+)/ name, remote_branch = $1, $4 hash[name] ||= {} hash[name].merge! :remote_mergepoint => remote_branch end hash end ## finally, index all branches remote_branches = {} `git show-ref`.split(/[\r\n]+/).each do |l| sha1, ref = l.chomp.split " refs/" if ref =~ /^heads\/(.+)$/ # local branch name = $1 next if name == "HEAD" branches[name] ||= {} branches[name].merge! :name => name, :local_branch => ref elsif ref =~ /^remotes\/(.+?)\/(.+)$/ # remote branch remote, name = $1, $2 remote_branches["#{remote}/#{name}"] = true next if name == "HEAD" ignore = !($all || remote == "origin") branch = name if branches[name] && branches[name][:remote] == remote # nothing else name = "#{remote}/#{branch}" end branches[name] ||= {} branches[name].merge! :name => name, :remote => remote, :remote_branch => "#{remote}/#{branch}", :remote_url => remotes[remote], :ignore => ignore end end ## assemble remotes branches.each do |k, b| next unless b[:remote] && b[:remote_mergepoint] b[:remote_branch] = if b[:remote] == "." b[:remote_mergepoint] else t = "#{b[:remote]}/#{b[:remote_mergepoint]}" remote_branches[t] && t # only if it's still alive end end show_dirty = ARGV.empty? targets = if ARGV.empty? [`git symbolic-ref HEAD`.chomp.sub(/^refs\/heads\//, "")] else ARGV.map { |x| x.sub(/^heads\//, "") } end.map { |t| branches[t] or abort "Error: can't find branch #{t.inspect}." } targets.each do |t| show t show_relations t, branches if $show_relations || t[:remote_branch].nil? end modified = show_dirty && `git ls-files -m` != "" uncommitted = show_dirty && `git diff-index --cached HEAD` != "" if $key puts puts KEY end puts if modified || uncommitted puts "#{red "NOTE"}: working directory contains modified files." if modified puts "#{red "NOTE"}: staging area contains staged but uncommitted files." if uncommitted # the end! ================================================ FILE: git.nr ================================================ #Ensure we have the quantity specified on the CLI if [ -z "$1" ]; then ARG_ERR=ERR; fi if [ -n "$ARG_ERR" ]; then echo "Usage: git.nr " exit fi # Create a new git repo with one README commit and CD into it mkdir $1 cd $1 git init touch README git add README git commit -m"First commit" ================================================ FILE: github-gem-install ================================================ #!/bin/sh #prereq sudo gem install json_pure sudo gem install defunkt-github -s http://gems.github.com ================================================ FILE: gitnewrepo ================================================ #!/bin/bash git init $1 cd $1 touch README git add README git commit -m'First commit of empty README' ================================================ FILE: hg-cdpullandupdate ================================================ #!/bin/bash echo =================== START ==================== pushd $1 echo Mercurial pulling $1 hg pull && hg update popd echo ==================== END ===================== ================================================ FILE: history.cuttail ================================================ #!/bin/sh if [ -z "$1" ]; then ARG_ERR=ERR; fi if [ -n "$ARG_ERR" ]; then echo "Usage: " return 1 fi tail -$1 ~/.zsh_history | cut -c 16- | pbcopy& echo The $1 most recent lines of history have been put onto the pasteboard ================================================ FILE: historytailbash ================================================ #!/bin/sh #Ensure we have the quantity specified on the CLI if [ -z "$2" ]; then ARG_ERR=ERR; fi if [ -z "$1" ]; then ARG_ERR=ERR; fi if [ -n "$ARG_ERR" ]; then echo "Usage: " exit fi sleeptimesecs=$1 numberoflines=$2 # Tail history while [ 1 ]; do clear tail -$numberoflines ~/.bash_history sleep $sleeptimesecs done ================================================ FILE: historytailzsh ================================================ #!/bin/sh #Ensure we have the quantity specified on the CLI if [ -z "$2" ]; then ARG_ERR=ERR; fi if [ -z "$1" ]; then ARG_ERR=ERR; fi if [ -n "$ARG_ERR" ]; then echo "Usage: " exit fi sleeptimesecs=$1 numberoflines=$2 # Tail history while [ 1 ]; do clear tail -$numberoflines ~/.zsh_history | sed s/^.*\;// sleep $sleeptimesecs done ================================================ FILE: hub.zsh_completion ================================================ #compdef hub # Zsh will source this file when attempting to autoload the "_hub" function, # typically on the first attempt to complete the hub command. We define two new # setup helper routines (one for the zsh-distributed version, one for the # git-distributed, bash-based version). Then we redefine the "_hub" function to # call "_git" after some other interception. # # This is pretty fragile, if you think about it. Any number of implementation # changes in the "_git" scripts could cause problems down the road. It would be # better if the stock git completions were just a bit more permissive about how # it allowed third-party commands to be added. (( $+functions[__hub_setup_zsh_fns] )) || __hub_setup_zsh_fns () { (( $+functions[_git-alias] )) || _git-alias () { _arguments \ '-s[output shell script suitable for eval]' \ '1::shell:(zsh bash csh)' } (( $+functions[_git-browse] )) || _git-browse () { _arguments \ '-u[output the URL]' \ '2::subpage:(wiki commits issues)' } (( $+functions[_git-compare] )) || _git-compare () { _arguments \ '-u[output the URL]' \ ':[start...]end range:' } (( $+functions[_git-create] )) || _git-create () { _arguments \ '::name (REPOSITORY or ORGANIZATION/REPOSITORY):' \ '-p[make repository private]' \ '-d[description]:description' \ '-h[home page]:repository home page URL:_urls' } (( $+functions[_git-fork] )) || _git-fork () { _arguments \ '--no-remote[do not add a remote for the new fork]' } (( $+functions[_git-pull-request] )) || _git-pull-request () { _arguments \ '-f[force (skip check for local commits)]' \ '-b[base]:base ("branch", "owner\:branch", "owner/repo\:branch"):' \ '-h[head]:head ("branch", "owner\:branch", "owner/repo\:branch"):' \ - set1 \ '-m[message]' \ '-F[file]' \ - set2 \ '-i[issue]:issue number:' \ - set3 \ '::issue-url:_urls' } # stash the "real" command for later functions[_hub_orig_git_commands]=$functions[_git_commands] # Replace it with our own wrapper. declare -f _git_commands >& /dev/null && unfunction _git_commands _git_commands () { local ret=1 # call the original routine _call_function ret _hub_orig_git_commands # Effectively "append" our hub commands to the behavior of the original # _git_commands function. Using this wrapper function approach ensures # that we only offer the user the hub subcommands when the user is # actually trying to complete subcommands. hub_commands=( alias:'show shell instructions for wrapping git' pull-request:'open a pull request on GitHub' fork:'fork origin repo on GitHub' create:'create new repo on GitHub for the current project' browse:'browse the project on GitHub' compare:'open GitHub compare view' ci-status:'lookup commit in GitHub Status API' ) _describe -t hub-commands 'hub command' hub_commands && ret=0 return ret } } (( $+functions[__hub_setup_bash_fns] )) || __hub_setup_bash_fns () { # TODO more bash-style fns needed here to complete subcommand args. They take # the form "_git_CMD" where "CMD" is something like "pull-request". # Duplicate and rename the 'list_all_commands' function eval "$(declare -f __git_list_all_commands | \ sed 's/__git_list_all_commands/__git_list_all_commands_without_hub/')" # Wrap the 'list_all_commands' function with extra hub commands __git_list_all_commands() { cat <<-EOF alias pull-request fork create browse compare ci-status EOF __git_list_all_commands_without_hub } # Ensure cached commands are cleared __git_all_commands="" } # redefine _hub to a much smaller function in the steady state _hub () { # only attempt to intercept the normal "_git" helper functions once (( $+__hub_func_replacement_done )) || () { # At this stage in the shell's execution the "_git" function has not yet # been autoloaded, so the "_git_commands" or "__git_list_all_commands" # functions will not be defined. Call it now (with a bogus no-op service # to prevent premature completion) so that we can wrap them. if declare -f _git >& /dev/null ; then _hub_noop () { __hub_zsh_provided=1 } # zsh-provided will call this one __hub_noop_main () { __hub_git_provided=1 } # git-provided will call this one local service=hub_noop _git unfunction _hub_noop unfunction __hub_noop_main service=git fi if (( $__hub_zsh_provided )) ; then __hub_setup_zsh_fns elif (( $__hub_git_provided )) ; then __hub_setup_bash_fns fi __hub_func_replacement_done=1 } # Now perform the actual completion, allowing the "_git" function to call our # replacement "_git_commands" function as needed. Both versions expect # service=git or they will call nonexistent routines or end up in an infinite # loop. service=git declare -f _git >& /dev/null && _git } # make sure we actually attempt to complete on the first "tab" from the user _hub ================================================ FILE: imageconvert ================================================ #!/bin/sh sudo sips -s format png $1 --out $2 #This command assumes your image is the Picture folder. If it is not then you must change '~/Pictures/' to the correct folder location of your image. #NOTE***: #sips supports output to the following formats: jpeg, tiff, png, gif, jp2, pict, bmp, qtif, psd, sgi, and tga. ================================================ FILE: iphoto-reverttooriginals ================================================ #!/bin/sh mkdir ~/.Trash/iPhoto-Originals cd ~/"Pictures/iPhoto Library/Modified/" find . -type f -exec mv "../Originals/{}" ~/.Trash/iPhoto-Originals/ \; ================================================ FILE: isappinstalled ================================================ #!/bin/bash #Ensure we have one argument specified on the CLI if [ -z "$1" ]; then ARG_ERR=ERR; fi if [ -n "$ARG_ERR" ]; then echo "Checks if an app (passed as a parameter) is installed/reachable" echo " on this machine by using the 'hash' command." echo "Usage: isappinstalled " echo "Returns: 0 if is installed, 1 if not installed." exit fi hash $1 2>&- || { echo >&2 "I require $1 but it's not installed."; exit 1; } ================================================ FILE: iterm ================================================ #!/bin/sh # # Open a new iTerm session with the command given # as argument. # # - If there are no arguments, the new iTerm window will # be opened in the current directory, i.e. as if the command # would be "cd `pwd`". # - If the first argument is a directory, the new iTerm will # "cd" into that directory before executing the remaining # arguments as command. # - If there are arguments and the first one is not a directory, # the new window will be opened in the current directory and # then the arguments will be executed as command. # - The optional, leading "-x" flag will cause the new terminal # to be closed immediately after the executed command finishes. # # original script by Marc Liyanage # designed to work with Mac OSX Terminal.app # iTerm modifications by Damon Parker # # # Version 1.2 # 9/20/2005 damonp - make sure new session opens in current window, clear screen # 9/15/2005 damonp - modify for iTerm usage if [ -z $3 ]; then echo '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' echo 'Launch the iTerm application in a certain folder' echo 'USAGE:' echo 'iterm ' echo 'iterm ~/Documents/Temp TEMP gray' echo 'iterm ~/Documents/Temp TEMP white' echo 'iterm ~/Documents/Temp TEMP blue' echo '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' exit fi if [ "x-x" = x"$1" ]; then EXIT="; exit"; shift; fi if [[ -d "$1" ]]; then WD=`cd "$1"; pwd`; shift; else WD="'`pwd`'"; fi COMMAND="cd $WD" TITLE="$1" COLOR="$2" echo "Launching iTerm with COMMAND: $COMMAND TITLE: $TITLE COLOR: $COLOR $EXIT" osascript 2>/dev/null < \(.*\)$'` if expr "$link" : '/.*' > /dev/null; then SCRIPT="$link" else SCRIPT="$(dirname "$SCRIPT"$)/$link" fi done BIN_DIR="$(dirname "$SCRIPT")" if [ -r "$BIN_DIR/../src/leiningen/core.clj" ]; then # Running from source checkout LEIN_DIR="$(dirname "$BIN_DIR")" LEIN_LIBS="$(find -H $LEIN_DIR/lib -mindepth 2> /dev/null 1 -maxdepth 1 -print0 | tr \\0 \:)" CLASSPATH="$LEIN_LIBS:$CLASSPATH:$LEIN_DIR/src:$LEIN_DIR/resources:$LEIN_JAR" if [ "$LEIN_LIBS" = "" -a "$1" != "self-install" -a ! -r "$LEIN_JAR" ]; then echo "Leiningen is missing its dependencies. Please see \"Building\" in the README." exit 1 fi else # Not running from a checkout CLASSPATH="$LEIN_JAR:$CLASSPATH" if [ ! -r "$LEIN_JAR" -a "$1" != "self-install" ]; then "$0" self-install fi fi HTTP_CLIENT="wget --no-check-certificate -O" if type -p curl >/dev/null 2>&1; then HTTP_CLIENT="curl --insecure -f -L -o" fi JAVA_CMD=${JAVA_CMD:-"java"} # Support $JAVA_OPTS for backwards-compatibility. JVM_OPTS=${JVM_OPTS:-$JAVA_OPTS} # If you're packaging this for a package manager (.deb, homebrew, etc) # you need to remove the self-install and upgrade functionality. if [ "$1" = "self-install" ]; then echo "Downloading Leiningen now..." LEIN_DIR=`dirname "$LEIN_JAR"` mkdir -p "$LEIN_DIR" LEIN_URL="https://github.com/downloads/technomancy/leiningen/leiningen-$LEIN_VERSION-standalone.jar" $HTTP_CLIENT "$LEIN_JAR" "$LEIN_URL" if [ $? != 0 ]; then echo "Failed to download $LEIN_URL" if [ $SNAPSHOT = "YES" ]; then echo "See README.md for SNAPSHOT build instructions." fi rm $LEIN_JAR 2> /dev/null exit 1 fi elif [ "$1" = "upgrade" ]; then if [ $SNAPSHOT = "YES" ]; then echo "The upgrade task is only meant for stable releases." echo "See the \"Hacking\" section of the README." exit 1 fi if [ ! -w "$SCRIPT" ]; then echo "You do not have permission to upgrade the installation in $SCRIPT" exit 1 else echo "The script at $SCRIPT will be upgraded to the latest stable version." echo -n "Do you want to continue [Y/n]? " read RESP case "$RESP" in y|Y|"") echo echo "Upgrading..." LEIN_SCRIPT_URL="https://github.com/technomancy/leiningen/raw/stable/bin/lein" $HTTP_CLIENT "$SCRIPT" "$LEIN_SCRIPT_URL" \ && chmod +x "$SCRIPT" \ && echo && $SCRIPT self-install && echo && echo "Now running" `$SCRIPT version` exit $?;; *) echo "Aborted." exit 1;; esac fi else if [ "$OSTYPE" = "cygwin" ]; then # When running on Cygwin, use Windows-style paths for java CLOJURE_JAR=`cygpath -w "$CLOJURE_JAR"` ORIGINAL_PWD=`cygpath -w "$ORIGINAL_PWD"` CLASSPATH=`cygpath -wp "$CLASSPATH"` NULL_DEVICE=NUL fi if [ $DEBUG ]; then echo $CLASSPATH echo $CLOJURE_JAR fi JLINE="" if ([ "$1" = "repl" ] || [ "$1" = "interactive" ] || [ "$1" = "int" ]) && [ -z $INSIDE_EMACS ] && [ "$TERM" != "dumb" ]; then # Use rlwrap if it's available, otherwise fall back to JLine RLWRAP=`which rlwrap` if [ ! -x "$RLWRAP" ] || [ "$RLWRAP" = "" ]; then RLWRAP="" JLINE=jline.ConsoleRunner if [ "$OSTYPE" = "cygwin" ]; then JLINE="-Djline.terminal=jline.UnixTerminal jline.ConsoleRunner" CYGWIN_JLINE=y fi fi fi # The -Xbootclasspath argument is optional here: if the jar # doesn't exist everything will still work, it will just have a # slower JVM boot. # TODO: add more to the boot classpath test $CYGWIN_JLINE && stty -icanon min 1 -echo exec $RLWRAP $JAVA_CMD -Xbootclasspath/a:"$CLOJURE_JAR" -client $JVM_OPTS \ -Dleiningen.original.pwd="$ORIGINAL_PWD" \ -cp "$CLASSPATH" $JLINE clojure.main -e "(use 'leiningen.core)(-main)" \ $NULL_DEVICE $@ test $CYGWIN_JLINE && stty icanon echo fi ================================================ FILE: loopthis ================================================ #!/bin/sh #Ensure we have the quantity specified on the CLI if [ -z "$2" ]; then ARG_ERR=ERR; fi if [ -z "$1" ]; then ARG_ERR=ERR; fi if [ -n "$ARG_ERR" ]; then echo "Usage: " exit fi sleeptimesecs=$1 commandtorun=$2 while [ 1 ]; do clear $commandtorun sleep $sleeptimesecs done ================================================ FILE: macosx-rescan-services-menu ================================================ #!/bin/bash /System/Library/CoreServices/pbs ================================================ FILE: macports-cleanup ================================================ #!/bin/sh # Remove the caches sudo port clean --all installed # Remove any inactive packages sudo port -f uninstall inactive ================================================ FILE: macports-update ================================================ #!/bin/sh # Update Macports sudo port selfupdate # Update outdated packages sudo port upgrade outdated ================================================ FILE: macprefs ================================================ #!/bin/sh # Turn on the debug (details about hidden disks) menus in Disk Utility defaults write com.apple.DiskUtility DUDebugMenuEnabled 1 ================================================ FILE: markdown-andopen ================================================ #!/bin/bash INPUTFILE="$1" OUTPUTFILE="$1".html echo Writing markdown file to \"$OUTPUTFILE\" markdown.pl "$INPUTFILE" > "$OUTPUTFILE" open "$OUTPUTFILE" ================================================ FILE: markdown-here ================================================ #!/bin/bash #Ensure we have the quantity specified on the CLI if [ -z "$1" ]; then ARG_ERR=ERR; fi if [ -n "$ARG_ERR" ]; then echo "Usage: " exit fi INPUTFILE="$1" OUTPUTFILE=`echo "$INPUTFILE" | sed "s/\.md/\.html/" | sed "s/\.markdown/\.html/"` echo Writing \"$INPUTFILE\" file to \"$OUTPUTFILE\" multimarkdown -o "$OUTPUTFILE" "$INPUTFILE" ================================================ FILE: markdown.pl ================================================ #!/opt/local/bin/perl #You should sudo port install p5-text-markdown to get the modules necessary to run this script #Argument 1 is the MDML input file. #It outputs the markdown-converted-to-html to the console. Redirect to a file as desired. use Text::Markdown 'markdown'; open( TEXTFILE, "<$ARGV[ 0 ]" ); print markdown( join( '', ) ); close( TEXTFILE ); ================================================ FILE: mdlstaglist ================================================ #!/bin/zsh while read N; do echo "$N"; mdls "$N" | grep "kOMUser" -H -A 1; done < <(find . -iname '*' -d 1) ================================================ FILE: mvim ================================================ #!/bin/sh # # This shell script passes all its arguments to the binary inside the # MacVim.app application bundle. If you make links to this script as view, # gvim, etc., then it will peek at the name used to call it and set options # appropriately. # # Based on a script by Wout Mertens and suggestions from Laurent Bihanic. This # version is the fault of Benji Fisher, 16 May 2005 (with modifications by Nico # Weber and Bjorn Winckler, Aug 13 2007). # First, check "All the Usual Suspects" for the location of the Vim.app bundle. # You can short-circuit this by setting the VIM_APP_DIR environment variable # or by un-commenting and editing the following line: # VIM_APP_DIR=/Applications if [ -z "$VIM_APP_DIR" ] then myDir="`dirname "$0"`" myAppDir="$myDir/../Applications" for i in ~/Applications ~/Applications/vim $myDir $myDir/vim $myAppDir $myAppDir/vim /Applications /Applications/vim /Applications/Utilities /Applications/Utilities/vim; do if [ -x "$i/MacVim.app" ]; then VIM_APP_DIR="$i" break fi done fi if [ -z "$VIM_APP_DIR" ] then echo "Sorry, cannot find MacVim.app. Try setting the VIM_APP_DIR environment variable to the directory containing MacVim.app." exit 1 fi binary="$VIM_APP_DIR/MacVim.app/Contents/MacOS/Vim" # Next, peek at the name used to invoke this script, and set options # accordingly. name="`basename "$0"`" gui= opts= # GUI mode, implies forking case "$name" in m*|g*|rm*|rg*) gui=true ;; esac # Restricted mode case "$name" in r*) opts="$opts -Z";; esac # vimdiff, view, and ex mode case "$name" in *vimdiff) opts="$opts -dO" ;; *view) opts="$opts -R" ;; *ex) opts="$opts -e" ;; esac # Last step: fire up vim. # The program should fork by default when started in GUI mode, but it does # not; we work around this when this script is invoked as "gvim" or "rgview" # etc., but not when it is invoked as "vim -g". if [ "$gui" ]; then # Note: this isn't perfect, because any error output goes to the # terminal instead of the console log. # But if you use open instead, you will need to fully qualify the # path names for any filenames you specify, which is hard. exec "$binary" -g $opts ${1:+"$@"} else exec "$binary" $opts ${1:+"$@"} fi ================================================ FILE: mysql-start ================================================ mysql.server start ================================================ FILE: mysql-stop ================================================ mysql.server stop ================================================ FILE: openmetaallfileshere ================================================ #!/bin/zsh while read N; do openmeta -a $1 -p "$N"; done < <(find . -iname '*.*' -d 1 -type f) ================================================ FILE: openmetaallfoldershere ================================================ #!/bin/zsh while read N; do openmeta -a $1 -p "$N"; done < <(find . -iname '*' -d 1 -type d) ================================================ FILE: openmetalisttags ================================================ #!/bin/zsh while read N; do openmeta -p "$N"; done < <(find . -iname '*' -d 1) ================================================ FILE: orgtomarkdown ================================================ #!/bin/sh # Convert OrgMode to Markdown export MARKDOWNNAME="`echo "$1" | sed 's/$/.markdown/'`" export HTMLNAME="`echo "$1" | sed 's/$/.html/'`" # Syntax of OrgMode # * for first level bullet -> H1 # ** for second level bullet -> first level markdown bullet # == for codeblock becomes ` #| tr -d '^ :[:alpha:]:$' \ #| tr -d '^ :[:alpha:]:[:blank:][:alnum:]$' \ # Convert OrgMode to Markdown cat "$1" \ | sed "s/#\+BEGIN_SRC/
/"  \
         | sed "s/#\+END_SRC/<\/code><\/pre>/"  \
         | sed "s/   :PROPERTIES://"  \
         | sed "s/   :Effort:.*//"  \
         | sed "s/   :END://"  \
         | sed "s/ =/ \`/"  \
         | sed "s/= /\` /"  \
         | sed "s/=\./\`./"  \
         | sed "s/^=/\`/"  \
         | sed "s/=$/\`/"  \
         | sed "s/^\* /# /"  \
         | sed "s/^\*\* /## /"  \
         | sed "s/^\*\*\* /### /" \
         | sed "s/^\*\*\*\* /\#### /" \
         | sed "s/^\*\*\*\*\* /\* /" > "$MARKDOWNNAME"

# Convert from Markdown to HTML
cat "$MARKDOWNNAME" | multimarkdown > "$HTMLNAME"


================================================
FILE: orgtomarkdowndots
================================================
#!/bin/sh

# Convert OrgMode to Markdown
export MARKDOWNNAME="`echo "$1" | sed 's/$/.markdown/'`"
export HTMLNAME="`echo "$1" | sed 's/$/.html/'`"

# Syntax of OrgMode
# * for first level bullet -> H1
# ** for second level bullet -> first level markdown bullet
# == for codeblock becomes `


#| tr -d '^   :[:alpha:]:$'  \
#| tr -d '^   :[:alpha:]:[:blank:][:alnum:]$'  \

# Convert OrgMode to Markdown
cat "$1" \
         | sed "s/#\+BEGIN_SRC/
/"  \
         | sed "s/#\+END_SRC/<\/code><\/pre>/"  \
         | sed "s/   :PROPERTIES://"  \
         | sed "s/   :Effort:.*//"  \
         | sed "s/   :END://"  \
         | sed "s/ =/ \`/"  \
         | sed "s/= /\` /"  \
         | sed "s/=\./\`./"  \
         | sed "s/^=/\`/"  \
         | sed "s/=$/\`/"  \
         | sed "s/^\* /# /"  \
         | sed "s/^\*\* /## /"  \
         | sed "s/^\*\*\* /\* /" \
         | sed "s/^\*\*\*\* /\    \* /" \
         | sed "s/^\*\*\*\*\* /\        * /" > "$MARKDOWNNAME"

# Convert from Markdown to HTML
cat "$MARKDOWNNAME" | multimarkdown > "$HTMLNAME"


================================================
FILE: p4diff
================================================
#!/bin/sh
[ $# -eq 7 ] && /usr/local/bin/p4merge "$2" "$5"


================================================
FILE: p4merge
================================================
#!/bin/sh
/Applications/p4merge.app/Contents/MacOS/p4merge $*


================================================
FILE: pinboard-backup
================================================
#!/bin/sh
curl https://matthew.mccullough:PASSWORDHERE@pinboard.in/export/ -o pinboard-`date "+%Y-%m-%d"`.html

================================================
FILE: postgresql-start
================================================
#!/bin/bash

pushd /Library/PostgreSQL/8.4/bin/
sudo -u postgres /Library/PostgreSQL/8.4/bin/pg_ctl start -D /Library/PostgreSQL/8.4/data/
popd

================================================
FILE: postgresql-stop
================================================
#!/bin/bash

sudo -u postgres pg_ctl stop -D /Library/PostgreSQL/8.4/data/

================================================
FILE: prepmigrate-brew
================================================
#!/bin/sh
brew list


================================================
FILE: prepmigrate-gems
================================================
#!/bin/sh
gem query --local


================================================
FILE: prepmigrate-port
================================================
#!/bin/sh
port list installed


================================================
FILE: ql
================================================
#!/bin/bash

qlmanage -p "$@" >& /dev/null &


================================================
FILE: ramdisk
================================================
#!/bin/bash

if [ -n "$3" ]; then ARG_ERR=ERR; fi
if [ -z "$1" ]; then ARG_ERR=ERR; fi
if [ -n "$ARG_ERR" ];
then
    echo "usage: ramdisk  [device name]"
    exit
fi
MB_SIZE=$1
let "MB_SIZE *= 2048"
echo Creating ${MB_SIZE} 512-blocks ramdisk
CREATED_RAMDISK=`hdid -nomount ram://${MB_SIZE}`
echo New block device: ${CREATED_RAMDISK}
if [ -n "$2" ];
then
    DISK_NAME=$2
else
    DISK_NAME=`basename ${CREATED_RAMDISK}`
fi
echo Creating volume with label: ${DISK_NAME}
newfs_hfs -v ${DISK_NAME} /dev/r$CREATED_RAMDISK
echo Mounting in /Volumes/${DISK_NAME}
diskutil mount ${CREATED_RAMDISK}

================================================
FILE: removedropboxconflicts
================================================
#!/bin/sh

find . -iname '*conflicted copy*' -print

echo "\n"
read -p "Press [Enter] to move these files to the trash or Ctrl C to abort..."

echo "\n\nStarting removal:"
find . -iname '*conflicted copy*' -print -exec rm "{}" \;


================================================
FILE: replace-word-in-filename
================================================
#!/bin/bash

if [ -n "$4" ]; then ARG_ERR=ERR; fi
if [ -z "$3" ]; then ARG_ERR=ERR; fi
if [ -z "$2" ]; then ARG_ERR=ERR; fi
if [ -z "$1" ]; then ARG_ERR=ERR; fi
if [ -n "$ARG_ERR" ];
then
    echo "Usage:   "
    exit
fi
for i in $1; do j=`echo $i | sed 's/$2/$3/g'`; mv "$i" "$j"; done

================================================
FILE: resty
================================================
#!/bin/bash

#
# resty - A tiny command line REST interface for bash.
#
# Fork me on github:
#   http://github.com/micha/resty
#
# Author:
#   Micha Niskin 
#   Copyright 2009, no rights reserved.
#

export _resty_host=""
export _resty_path=""

function resty() {
  local confdir="${HOME}/.resty"
  local host="${confdir}/host"
  local cookies="$confdir/c"
  local method="$1";          [[ $# > 0 ]] && shift
  local h2t=$((which lynx >/dev/null && echo lynx -stdin -dump) \
                || which html2text || which cat)
  local editor=$(which "$EDITOR" || which vim || echo "vi")
  local domain path opt dat res ret out err verbose raw i d tmpf args2

  [ -d "$cookies" ] || (mkdir -p "$cookies"; echo "http://localhost*" > "$host")
  [ -n "$1" ] && [ "${1#/}" != "$1" ] \
    && path=$(echo "$1"|sed 's/%/%25/g;s/\[/%5B/g;s/\]/%5D/g;s/|/%7C/g;s/\$/%24/g;s/&/%26/g;s/+/%2B/g;s/,/%2C/g;s/:/%3A/g;s/;/%3B/g;s/=/%3D/g;s/?/%3F/g;s/@/%40/g;s/ /%20/g;s/#/%23/g;s/{/%7B/g;s/}/%7D/g;s/\\/%5C/g;s/\^/%5E/g;s/~/%7E/g;s/`/%60/g') && shift

  for i in "$@"; do
    ([ "$i" == "--verbose" ] || echo "$i" | grep -q '^-[a-zA-Z]*v[a-zA-Z]*$') \
      && verbose="yes"
  done

  [ -z "$_resty_host" ] && _resty_host=$(cat "$host" 2>/dev/null)
  [ -z "$method" ] && echo "$_resty_host" && return
  [ -n "$path" ] && _resty_path=$path
  domain=$(echo -n "$_resty_host" \
    |perl -ane '/^https?:\/\/([^\/\*]+)/; print $1')
  path="${_resty_host//\*/$_resty_path}"

  case "$method" in
    GET|DELETE|POST|PUT)
      dat=$( ( [ "${method#P}" != "$method" ] \
        && ( ( [ -n "$1" ] && [ "${1#-}" == "$1" ] && echo "$1") \
        || echo "@-") ) || echo)
      if [ "${method#P}" != "$method" ] && [ "$1" == "-V" ]; then
        tmpf=$(mktemp /tmp/resty.XXXXXX)
        cat > $tmpf
        (exec < /dev/tty; "$editor" $tmpf)
        dat=$(cat $tmpf)
        rm -f $tmpf
      fi
      [ -n "$dat" ] && [ "$dat" != "@-" ] && shift
      [ "$1" == "-Z" ] && raw="yes" && shift
      [ -n "$dat" ] && opt="--data-binary"
      eval "args2=( $(cat "$confdir/$domain" 2>/dev/null |sed 's/^ *//' |grep ^$method |cut -b $((${#method}+2))-) )"
      res=$((((curl -sLv $opt "$dat" -X $method \
              -b "$cookies/$domain" -c "$cookies/$domain" \
              "${args2[@]}" "$@" "$path" \
        |sed 's/^/OUT /' && echo) 3>&2 2>&1 1>&3) \
        |sed 's/^/ERR /' && echo) 2>&1)
      out=$(echo "$res" |sed '/^OUT /s/^....//p; d')
      err=$(echo "$res" |sed '/^ERR /s/^....//p; d')
      ret=$(echo "$err" |sed \
        '/^.*HTTP\/1\.[01] [0-9][0-9][0-9]/s/.*\([0-9]\)[0-9][0-9].*/\1/p; d' \
        | tail -n1)
      [ -n "$err" -a -n "$verbose" ] && echo "$err" 1>&2
      echo "$err" | grep -qi '^< \s*Content-Type:  *text/html' \
        && [ -z "$raw" ] && d=$h2t || d=cat
      if [ "$ret" != "2" ]; then
        [ -n "$out" ] && echo "$out" | $d 1>&2
        return $ret
      else
        [ -n "$out" ] && echo "$out" | $d
      fi
      ;;
    http://*|https://*)
      echo "$method" |grep -q '\*' || method="${method}*"
      (echo "$method" |tee "$host") |cat 1>&2 && _resty_host="$method"
      ;;
    *)
      resty "http://$method"
      ;;
  esac
}

function GET() {
  resty GET "$@"
}

function POST() {
  resty POST "$@"
}

function PUT() {
  resty PUT "$@"
}

function DELETE() {
  resty DELETE "$@"
}


================================================
FILE: rilconvert
================================================
#!/bin/bash
# (c) Vinzenz Vietzke 
# 
# ugly hack for importing readitlater to springpad:
# convert readitlater export files to delicious import format

#Ensure we have the quantity specified on the CLI
if [ -z "$2" ]; then ARG_ERR=ERR; fi
if [ -z "$1" ]; then ARG_ERR=ERR; fi
if [ -n "$ARG_ERR" ];
then
    echo "usage: rilconvert.sh input-filename.html output-filename.html"
    exit
fi


echo -e "

Bookmarks

Bookmarks

" > $2 cat $1 | grep "/DT\>/g | sed -e s/time_added/ADD_DATE/g | sed -e s/tags/TAGS/g \ | sed -e s/'a href'/'A HREF'/g | sed -e s/TAGS/PRIVAT=\"0\"\ TAGS/g >> $2 echo -e "

" >> $2 ================================================ FILE: scmupdateallprojects ================================================ #!/bin/bash # DESCRIPTION # Recursively walk through directories looking for names ending in # _svn, _git, _gitsvn, or _hg # Depending on the folder type, issue the correct command to update the # codebase from its appropriate repository # OPTIONS # If DEPTH=1, then search the current level only. # If DEPTH>1, look in subfolders to depth N DEPTH=1 find . -depth $DEPTH -type d -regex .*_git -exec gitcdandpull.bsh {} \; find . -depth $DEPTH -type d -regex .*_gitsvn -exec gitcdandsvnrebase.bsh {} \; find . -depth $DEPTH -type d -regex .*_hg -exec hgcdandpullandupdate.bsh {} \; find . -depth $DEPTH -type d -regex .*_svn -exec svncdandupdate.bsh {} \; ================================================ FILE: setmaven2 ================================================ #!/bin/bash unlink /Applications/Dev/apache-maven ln -s /Applications/Dev/apache-maven-2.2.1 /Applications/Dev/apache-maven ================================================ FILE: setmaven3 ================================================ #!/bin/bash unlink /Applications/Dev/apache-maven ln -s /Applications/Dev/apache-maven-3.0.4 /Applications/Dev/apache-maven ================================================ FILE: setmavenpoly ================================================ #!/bin/bash unlink /Applications/Dev/apache-maven ln -s /Applications/Dev/pmaven /Applications/Dev/apache-maven ================================================ FILE: svncdandupdate ================================================ #!/bin/bash echo =================== START ==================== pushd $1 echo SVN updating $1 svn update popd echo ==================== END ===================== ================================================ FILE: tabstospacesfor ================================================ #!/bin/sh #for eachthing in "$1"; do for eachthing in `find . -iname \"$1\"`; do echo Backing up: "$eachthing" to "$eachthing.orig" cp $eachthing $eachthing.orig echo Converting: tab2space --unix "$eachthing" "$eachthing" tab2space --unix "$eachthing" "$eachthing" done ================================================ FILE: terminal ================================================ #!/bin/bash if [ -z $1 ]; then echo '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' echo 'Launch a terminal window tab and CD to the specified location' echo 'USAGE:' echo 'terminal.sh ' echo 'Param1 = path to CD to' echo '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' exit fi #================================================= # bash - find path to currently running script # which is necessary because we need to find our # adjacent terminal.scpt file #================================================= abspath="$(cd "${0%/*}" 2>/dev/null; echo "$PWD"/"${0##*/}")" # to get the path only - not the script name - add path_only=`dirname "$abspath"` #Pass in the folder you want to CD to echo Opening a terminal tab to \'$1\' osascript "$path_only/terminal.scpt" "$1" ================================================ FILE: timemachine-findonlyononeside ================================================ #!/bin/bash # Change the working directory to the Latest folder on the Time Machine disk and report it pushd /Volumes/EXT-ZEUS-TM/Backups.backupdb/*/Latest/*/ export BACKUPVOLUME="$(pwd -P)" echo "Current folder on backup disk: $BACKUPVOLUME" popd # Diff the current directory (the backup volume's Latest folder) against / (the root of the main disk) # Redirect error output to system out and tee all output to a log file on the desktop # sudo diff -qr "$BACKUPVOLUME" / 2>&1 | grep "Only in" | tee ~/Desktop/timemachine-diff.log sudo diff -qr "$BACKUPVOLUME" / 2>&1 | grep "Only in" ================================================ FILE: timemachine-verify ================================================ #!/bin/bash # Change the working directory to the Latest folder on the Time Machine disk and report it cd /Volumes/EXT-ZEUS-TM/Backups.backupdb/*/Latest/*/ echo "Current folder on backup disk: $(pwd -P)" # Diff the current directory (the backup volume's Latest folder) against / (the root of the main disk) # Redirect error output to system out and tee all output to a log file on the desktop sudo diff -qr . / 2>&1 | tee ~/Desktop/timemachine-diff.log ================================================ FILE: treelive ================================================ #!/bin/bash #Ensure we have the quantity specified on the CLI if [ -z "$1" ]; then ARG_ERR=ERR; fi if [ -n "$ARG_ERR" ]; then echo "Usage: treelive " echo "Usage: treelive " exit fi DEPTH=$1 while : do clear tree -L $* sleep 2 done ================================================ FILE: unzipall ================================================ #!/bin/bash for eachzip in `find . -iname '*.zip'`; do unzip $eachzip; done ================================================ FILE: vacuummail ================================================ #!/bin/bash osascript -e 'tell application "Mail" to quit' sleep 1 before=`ls -lah ~/Library/Mail/V2/MailData | grep -E 'Envelope Index$' | awk {'print $5'}` # do the vacuum /usr/bin/sqlite3 ~/Library/Mail/V2/MailData/Envelope\ Index vacuum after=`ls -lah ~/Library/Mail/V2/MailData | grep -E 'Envelope Index$' | awk {'print $5'}` echo "Mail index before: $before" echo "Mail index after: $after" echo "Enjoy the new speed!" osascript -e 'tell application "Mail" to activate' sleep 1 osascript -e 'tell application "System Events" to set visible of application process "Mail" to false' ================================================ FILE: visualvm ================================================ #!/bin/bash /Applications/Dev/visualvm/bin/visualvm --jdkhome /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/ ================================================ FILE: vmware-start ================================================ #!/bin/bash echo Starting VMWare Fusion services... sudo '/Library/Application Support/VMware Fusion/boot.sh' --start ================================================ FILE: welcome ================================================ #!/bin/sh echo '-------------------------------------------------' echo 'Welcome to class on:' `date` echo "I'm Matthew McCullough, your instructor " echo '-------------------------------------------------' echo ================================================ FILE: wireshark-auth ================================================ #!/bin/bash sudo chown $USERNAME /dev/bpf* ================================================ FILE: zshverboseoff ================================================ #!/bin/zsh ZSHVERBOSE="false" export ZSHVERBOSE prompt_wunjo_setup