├── .gitignore ├── LICENSE ├── README.md ├── ReComment.scpt ├── ackgradle ├── bamboo ├── battery ├── beep-timer-ignite ├── BeepTimerIgnite$Position.class ├── BeepTimerIgnite$_main_closure1.class ├── BeepTimerIgnite.class ├── BeepTimerIgnite.groovy └── ping.wav ├── 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 ├── subl ├── svncdandupdate ├── tabstospacesfor ├── terminal ├── terminal.scpt ├── timemachine-findonlyononeside ├── timemachine-verify ├── treelive ├── unzipall ├── vacuummail ├── visualvm ├── vmware-start ├── welcome ├── wireshark-auth ├── z.sh └── zshverboseoff /.gitignore: -------------------------------------------------------------------------------- 1 | pinboard-backup-matthew.sh 2 | pinboard-backup-matthew 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | # License 2 | 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. 3 | 4 | ------------------------ 5 | 6 | # Attribution 3.0 Unported (CC BY 3.0) 7 | 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). 8 | 9 | 10 | ## You are free: 11 | 12 | * to Share — to copy, distribute and transmit the work 13 | * to Remix — to adapt the work 14 | to make commercial use of the work 15 | 16 | 17 | ## Under the following conditions: 18 | 19 | * 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). 20 | 21 | ## With the understanding that: 22 | 23 | * Waiver — Any of the above conditions can be waived if you get permission from the copyright holder. 24 | * 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. 25 | * Other Rights — In no way are any of the following rights affected by the license: 26 | * Your fair dealing or fair use rights, or other applicable copyright exceptions and limitations; 27 | * The author's moral rights; 28 | * Rights other persons may have either in the work itself or in how the work is used, such as publicity or privacy rights. 29 | 30 | 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. 31 | 32 | -------------------------------- 33 | 34 | # Attribution 3.0 Unported (CC BY 3.0) 35 | 36 | http://creativecommons.org/licenses/by/3.0/legalcode 37 | 38 | 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. 39 | 40 | License 41 | 42 | 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. 43 | 44 | 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. 45 | 46 | 1. Definitions 47 | 48 | "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. 49 | "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. 50 | "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. 51 | "Licensor" means the individual, individuals, entity or entities that offer(s) the Work under the terms of this License. 52 | "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. 53 | "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. 54 | "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. 55 | "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. 56 | "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. 57 | 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. 58 | 59 | 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: 60 | 61 | to Reproduce the Work, to incorporate the Work into one or more Collections, and to Reproduce the Work as incorporated in the Collections; 62 | 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."; 63 | to Distribute and Publicly Perform the Work including as incorporated in Collections; and, 64 | to Distribute and Publicly Perform Adaptations. 65 | 66 | For the avoidance of doubt: 67 | 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; 68 | 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, 69 | 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. 70 | 71 | 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. 72 | 73 | 4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions: 74 | 75 | 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. 76 | 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. 77 | 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. 78 | 79 | 5. Representations, Warranties and Disclaimer 80 | 81 | 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. 82 | 83 | 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. 84 | 85 | 7. Termination 86 | 87 | 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. 88 | 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. 89 | 8. Miscellaneous 90 | 91 | 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. 92 | 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. 93 | 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. 94 | 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. 95 | 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. 96 | 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. 97 | 98 | Creative Commons Notice 99 | 100 | 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. 101 | 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. 102 | 103 | Creative Commons may be contacted at http://creativecommons.org/. 104 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Matthew's Shell Scripts 2 | 3 | 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. 4 | 5 | Please fork, fix, enhance, and send pull requests. 6 | 7 | 8 | # MIT License 9 | 10 | Copyright (c) 2010, Matthew McCullough, Ambient Ideas, LLC 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining a copy 13 | of this software and associated documentation files (the "Software"), to deal 14 | in the Software without restriction, including without limitation the rights 15 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | copies of the Software, and to permit persons to whom the Software is 17 | furnished to do so, subject to the following conditions: 18 | 19 | The above copyright notice and this permission notice shall be included in 20 | all copies or substantial portions of the Software. 21 | 22 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 28 | THE SOFTWARE. -------------------------------------------------------------------------------- /ReComment.scpt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthewmccullough/scripts/40b246165445f44d253c8100969fffdcdbe3f9a0/ReComment.scpt -------------------------------------------------------------------------------- /ackgradle: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo Searching for \"$1\" in gradle files. 3 | ack -a "$1" **/*.gradle 4 | -------------------------------------------------------------------------------- /bamboo: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pushd /Applications/Dev/Bamboo/ 4 | bamboo.sh $1 5 | popd 6 | 7 | echo REMINDER: Bamboo runs on port 8085 -------------------------------------------------------------------------------- /battery: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ioreg -l | grep -E '(Max|Current)Capacity' | cut -d= -f2 | perl -e'@b=; printf"%d%%\n",100*$b[1]/$b[0]' 3 | -------------------------------------------------------------------------------- /beep-timer-ignite/BeepTimerIgnite$Position.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthewmccullough/scripts/40b246165445f44d253c8100969fffdcdbe3f9a0/beep-timer-ignite/BeepTimerIgnite$Position.class -------------------------------------------------------------------------------- /beep-timer-ignite/BeepTimerIgnite$_main_closure1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthewmccullough/scripts/40b246165445f44d253c8100969fffdcdbe3f9a0/beep-timer-ignite/BeepTimerIgnite$_main_closure1.class -------------------------------------------------------------------------------- /beep-timer-ignite/BeepTimerIgnite.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthewmccullough/scripts/40b246165445f44d253c8100969fffdcdbe3f9a0/beep-timer-ignite/BeepTimerIgnite.class -------------------------------------------------------------------------------- /beep-timer-ignite/BeepTimerIgnite.groovy: -------------------------------------------------------------------------------- 1 | import java.io.File; 2 | import java.io.IOException; 3 | import javax.sound.sampled.AudioFormat; 4 | import javax.sound.sampled.AudioInputStream; 5 | import javax.sound.sampled.AudioSystem; 6 | import javax.sound.sampled.DataLine; 7 | import javax.sound.sampled.FloatControl; 8 | import javax.sound.sampled.LineUnavailableException; 9 | import javax.sound.sampled.SourceDataLine; 10 | import javax.sound.sampled.UnsupportedAudioFileException; 11 | 12 | public class BeepTimerIgnite extends Thread { 13 | 14 | public static void main(String[] args) { 15 | 20.times { 16 | sleep(15000) 17 | //println "Beep!\007\007\007\r\n"; 18 | new BeepTimerIgnite("ping.wav") 19 | } 20 | } 21 | 22 | private String filename; 23 | 24 | private Position curPosition; 25 | 26 | private final int EXTERNAL_BUFFER_SIZE = 524288; // 128Kb 27 | 28 | enum Position { 29 | LEFT, RIGHT, NORMAL 30 | }; 31 | 32 | public BeepTimerIgnite(String wavfile) { 33 | filename = wavfile; 34 | curPosition = Position.NORMAL; 35 | } 36 | 37 | public BeepTimerIgnite(String wavfile, Position p) { 38 | filename = wavfile; 39 | curPosition = p; 40 | } 41 | 42 | public void run() { 43 | 44 | File soundFile = new File(filename); 45 | if (!soundFile.exists()) { 46 | System.err.println("Wave file not found: " + filename); 47 | return; 48 | } 49 | 50 | AudioInputStream audioInputStream = null; 51 | try { 52 | audioInputStream = AudioSystem.getAudioInputStream(soundFile); 53 | } catch (UnsupportedAudioFileException e1) { 54 | e1.printStackTrace(); 55 | return; 56 | } catch (IOException e1) { 57 | e1.printStackTrace(); 58 | return; 59 | } 60 | 61 | AudioFormat format = audioInputStream.getFormat(); 62 | SourceDataLine auline = null; 63 | DataLine.Info info = new DataLine.Info(SourceDataLine.class, format); 64 | 65 | try { 66 | auline = (SourceDataLine) AudioSystem.getLine(info); 67 | auline.open(format); 68 | } catch (LineUnavailableException e) { 69 | e.printStackTrace(); 70 | return; 71 | } catch (Exception e) { 72 | e.printStackTrace(); 73 | return; 74 | } 75 | 76 | if (auline.isControlSupported(FloatControl.Type.PAN)) { 77 | FloatControl pan = (FloatControl) auline 78 | .getControl(FloatControl.Type.PAN); 79 | if (curPosition == Position.RIGHT) 80 | pan.setValue(1.0f); 81 | else if (curPosition == Position.LEFT) 82 | pan.setValue(-1.0f); 83 | } 84 | 85 | auline.start(); 86 | int nBytesRead = 0; 87 | byte[] abData = new byte[EXTERNAL_BUFFER_SIZE]; 88 | 89 | try { 90 | while (nBytesRead != -1) { 91 | nBytesRead = audioInputStream.read(abData, 0, abData.length); 92 | if (nBytesRead >= 0) 93 | auline.write(abData, 0, nBytesRead); 94 | } 95 | } catch (IOException e) { 96 | e.printStackTrace(); 97 | return; 98 | } finally { 99 | auline.drain(); 100 | auline.close(); 101 | } 102 | 103 | } 104 | } -------------------------------------------------------------------------------- /beep-timer-ignite/ping.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthewmccullough/scripts/40b246165445f44d253c8100969fffdcdbe3f9a0/beep-timer-ignite/ping.wav -------------------------------------------------------------------------------- /chksha1: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | newfilehash=$(openssl sha1 $1) 4 | existingsha1=$(cat $2) 5 | if [ "${existingsha1}" = "${newfilehash}" ]; then echo "Key is valid."; else echo "Key is _not_ valid!!!"; fi -------------------------------------------------------------------------------- /colornetstat: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # colorize netstat output 3 | color_red=`echo "33[0;31m"` 4 | color_green=`echo "33[0;32m"` 5 | color_yellow=`echo "33[0;33m"` 6 | color_blue=`echo "33[0;34m"` 7 | color_purple=`echo "33[0;35m"` 8 | color_cyan=`echo "33[1;36m"` 9 | no_color=`echo "33[0m"` 10 | 11 | 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}/" 12 | 13 | -------------------------------------------------------------------------------- /crashplan-start: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | sudo launchctl load /Library/LaunchDaemons/com.crashplan.engine.plist 3 | -------------------------------------------------------------------------------- /crashplan-stop: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | sudo launchctl unload /Library/LaunchDaemons/com.crashplan.engine.plist 3 | -------------------------------------------------------------------------------- /doforever: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #Ensure we have the quantity specified on the CLI 4 | if [ -z "$2" ]; then ARG_ERR=ERR; fi 5 | if [ -z "$1" ]; then ARG_ERR=ERR; fi 6 | if [ -n "$ARG_ERR" ]; 7 | then 8 | echo "Usage: " 9 | exit 10 | fi 11 | 12 | delay=$1 13 | commandtorun=$2 14 | 15 | while true; 16 | do $commandtorun 17 | sleep $delay 18 | done 19 | 20 | # The same thing can be written as a one-liner 21 | # while true; do echo ./genoutput && sleep 15; done 22 | -------------------------------------------------------------------------------- /ejectall: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Eject all disks 2 and above. 4 | # 0 and 1 are typically Macintosh HD and the Recovery Disk 5 | diskutil list | grep '/dev/disk[2-9]' | sed 's/\/dev\//diskutil eject /' | sh 6 | 7 | -------------------------------------------------------------------------------- /ejectalldisks.scpt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthewmccullough/scripts/40b246165445f44d253c8100969fffdcdbe3f9a0/ejectalldisks.scpt -------------------------------------------------------------------------------- /find-eclipse-workspaces: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #One Approach is to CD to the folder and PWD it 4 | #set -v off 5 | #find . -type d -name .metadata | sed "s/.metadata//" | sed "s/^/pushd \"/" | sed "s/$/\"; echo \$PWD; popd/" | sh 6 | 7 | # Hints obtained from: 8 | # http://stackoverflow.com/questions/4935278/concatenate-a-string-to-the-end-of-every-output-line-in-bash-csh 9 | 10 | #A second approach is to capture $PWD and replace the ./ in the path with it 11 | find . -type d -name .metadata | sed "s/.metadata//" | sed "s/^\.//" | sed "s/\/$//" | while read line; do echo $PWD$line; done 12 | -------------------------------------------------------------------------------- /findjarcontaining: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #Example Usage: findjars com/ambientideas/groovy 4 | 5 | CLASSNAMETOFIND="$1" 6 | 7 | echo "Searching all JARs recursively..." 8 | for eachjar in `find . -iname "*.jar"` 9 | do 10 | #echo "Searching in $eachjar ..." 11 | jar tvf $eachjar | grep $CLASSNAMETOFIND > /dev/null 12 | if [ $? == 0 ] 13 | then 14 | echo "******* Located \"$CLASSNAMETOFIND\" in $eachjar *******" 15 | fi 16 | done -------------------------------------------------------------------------------- /fixbrewperms: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sudo chown -R $USER /usr/local 3 | -------------------------------------------------------------------------------- /generaterandomchanges: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #Ensure we have the quantity specified on the CLI 4 | if [ -z "$3" ]; then ARG_ERR=ERR; fi 5 | if [ -z "$2" ]; then ARG_ERR=ERR; fi 6 | if [ -z "$1" ]; then ARG_ERR=ERR; fi 7 | if [ -n "$ARG_ERR" ]; 8 | then 9 | echo "Usage: " 10 | exit 11 | fi 12 | 13 | count=$1 14 | filenamebase=$2 15 | filenameextension=$3 16 | for (( filenumber = 1; filenumber <= $count ; filenumber++ )); do 17 | echo "Some new random text: $RANDOM" >> $filenamebase$filenumber.$filenameextension 18 | git add $filenamebase$filenumber.$filenameextension 19 | git commit -m"A random change of $RANDOM to $filenamebase$filenumber.$filenameextension" 20 | done 21 | -------------------------------------------------------------------------------- /generaterandomfiles: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #Ensure we have the quantity specified on the CLI 4 | if [ -z "$3" ]; then ARG_ERR=ERR; fi 5 | if [ -z "$2" ]; then ARG_ERR=ERR; fi 6 | if [ -z "$1" ]; then ARG_ERR=ERR; fi 7 | if [ -n "$ARG_ERR" ]; 8 | then 9 | echo "Usage: " 10 | exit 11 | fi 12 | 13 | count=$1 14 | filenamebase=$2 15 | filenameextension=$3 16 | for (( filenumber = 1; filenumber <= $count ; filenumber++ )); do echo "Some random text: $RANDOM" > $filenamebase$filenumber.$filenameextension; done -------------------------------------------------------------------------------- /git-cdandpull: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo =================== START ==================== 3 | pushd $1 4 | echo Git pulling $1 from origin to master 5 | git pull origin master 6 | popd 7 | echo ==================== END ===================== -------------------------------------------------------------------------------- /git-cdandsvnrebase: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo =================== START ==================== 3 | pushd $1 4 | echo Git svn rebasing $1 5 | git svn rebase 6 | popd 7 | echo ==================== END ===================== -------------------------------------------------------------------------------- /git-completion: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # bash completion support for core Git. 5 | # 6 | # Copyright (C) 2006,2007 Shawn O. Pearce 7 | # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). 8 | # Distributed under the GNU General Public License, version 2.0. 9 | # 10 | # The contained completion routines provide support for completing: 11 | # 12 | # *) local and remote branch names 13 | # *) local and remote tag names 14 | # *) .git/remotes file names 15 | # *) git 'subcommands' 16 | # *) tree paths within 'ref:path/to/file' expressions 17 | # *) common --long-options 18 | # 19 | # To use these routines: 20 | # 21 | # 1) Copy this file to somewhere (e.g. ~/.git-completion.sh). 22 | # 2) Added the following line to your .bashrc: 23 | # source ~/.git-completion.sh 24 | # 25 | # 3) You may want to make sure the git executable is available 26 | # in your PATH before this script is sourced, as some caching 27 | # is performed while the script loads. If git isn't found 28 | # at source time then all lookups will be done on demand, 29 | # which may be slightly slower. 30 | # 31 | # 4) Consider changing your PS1 to also show the current branch: 32 | # PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ ' 33 | # 34 | # The argument to __git_ps1 will be displayed only if you 35 | # are currently in a git repository. The %s token will be 36 | # the name of the current branch. 37 | # 38 | # To submit patches: 39 | # 40 | # *) Read Documentation/SubmittingPatches 41 | # *) Send all patches to the current maintainer: 42 | # 43 | # "Shawn O. Pearce" 44 | # 45 | # *) Always CC the Git mailing list: 46 | # 47 | # git@vger.kernel.org 48 | # 49 | 50 | __gitdir () 51 | { 52 | if [ -z "$1" ]; then 53 | if [ -n "$__git_dir" ]; then 54 | echo "$__git_dir" 55 | elif [ -d .git ]; then 56 | echo .git 57 | else 58 | git rev-parse --git-dir 2>/dev/null 59 | fi 60 | elif [ -d "$1/.git" ]; then 61 | echo "$1/.git" 62 | else 63 | echo "$1" 64 | fi 65 | } 66 | 67 | __git_ps1 () 68 | { 69 | local b="$(git symbolic-ref HEAD 2>/dev/null)" 70 | if [ -n "$b" ]; then 71 | if [ -n "$1" ]; then 72 | printf "$1" "${b##refs/heads/}" 73 | else 74 | printf " (%s)" "${b##refs/heads/}" 75 | fi 76 | fi 77 | } 78 | 79 | __gitcomp () 80 | { 81 | local all c s=$'\n' IFS=' '$'\t'$'\n' 82 | local cur="${COMP_WORDS[COMP_CWORD]}" 83 | if [ $# -gt 2 ]; then 84 | cur="$3" 85 | fi 86 | for c in $1; do 87 | case "$c$4" in 88 | --*=*) all="$all$c$4$s" ;; 89 | *.) all="$all$c$4$s" ;; 90 | *) all="$all$c$4 $s" ;; 91 | esac 92 | done 93 | IFS=$s 94 | COMPREPLY=($(compgen -P "$2" -W "$all" -- "$cur")) 95 | return 96 | } 97 | 98 | __git_heads () 99 | { 100 | local cmd i is_hash=y dir="$(__gitdir "$1")" 101 | if [ -d "$dir" ]; then 102 | for i in $(git --git-dir="$dir" \ 103 | for-each-ref --format='%(refname)' \ 104 | refs/heads ); do 105 | echo "${i#refs/heads/}" 106 | done 107 | return 108 | fi 109 | for i in $(git-ls-remote "$1" 2>/dev/null); do 110 | case "$is_hash,$i" in 111 | y,*) is_hash=n ;; 112 | n,*^{}) is_hash=y ;; 113 | n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;; 114 | n,*) is_hash=y; echo "$i" ;; 115 | esac 116 | done 117 | } 118 | 119 | __git_tags () 120 | { 121 | local cmd i is_hash=y dir="$(__gitdir "$1")" 122 | if [ -d "$dir" ]; then 123 | for i in $(git --git-dir="$dir" \ 124 | for-each-ref --format='%(refname)' \ 125 | refs/tags ); do 126 | echo "${i#refs/tags/}" 127 | done 128 | return 129 | fi 130 | for i in $(git-ls-remote "$1" 2>/dev/null); do 131 | case "$is_hash,$i" in 132 | y,*) is_hash=n ;; 133 | n,*^{}) is_hash=y ;; 134 | n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;; 135 | n,*) is_hash=y; echo "$i" ;; 136 | esac 137 | done 138 | } 139 | 140 | __git_refs () 141 | { 142 | local cmd i is_hash=y dir="$(__gitdir "$1")" 143 | if [ -d "$dir" ]; then 144 | if [ -e "$dir/HEAD" ]; then echo HEAD; fi 145 | for i in $(git --git-dir="$dir" \ 146 | for-each-ref --format='%(refname)' \ 147 | refs/tags refs/heads refs/remotes); do 148 | case "$i" in 149 | refs/tags/*) echo "${i#refs/tags/}" ;; 150 | refs/heads/*) echo "${i#refs/heads/}" ;; 151 | refs/remotes/*) echo "${i#refs/remotes/}" ;; 152 | *) echo "$i" ;; 153 | esac 154 | done 155 | return 156 | fi 157 | for i in $(git-ls-remote "$dir" 2>/dev/null); do 158 | case "$is_hash,$i" in 159 | y,*) is_hash=n ;; 160 | n,*^{}) is_hash=y ;; 161 | n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;; 162 | n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;; 163 | n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;; 164 | n,*) is_hash=y; echo "$i" ;; 165 | esac 166 | done 167 | } 168 | 169 | __git_refs2 () 170 | { 171 | local i 172 | for i in $(__git_refs "$1"); do 173 | echo "$i:$i" 174 | done 175 | } 176 | 177 | __git_refs_remotes () 178 | { 179 | local cmd i is_hash=y 180 | for i in $(git-ls-remote "$1" 2>/dev/null); do 181 | case "$is_hash,$i" in 182 | n,refs/heads/*) 183 | is_hash=y 184 | echo "$i:refs/remotes/$1/${i#refs/heads/}" 185 | ;; 186 | y,*) is_hash=n ;; 187 | n,*^{}) is_hash=y ;; 188 | n,refs/tags/*) is_hash=y;; 189 | n,*) is_hash=y; ;; 190 | esac 191 | done 192 | } 193 | 194 | __git_remotes () 195 | { 196 | local i ngoff IFS=$'\n' d="$(__gitdir)" 197 | shopt -q nullglob || ngoff=1 198 | shopt -s nullglob 199 | for i in "$d/remotes"/*; do 200 | echo ${i#$d/remotes/} 201 | done 202 | [ "$ngoff" ] && shopt -u nullglob 203 | for i in $(git --git-dir="$d" config --list); do 204 | case "$i" in 205 | remote.*.url=*) 206 | i="${i#remote.}" 207 | echo "${i/.url=*/}" 208 | ;; 209 | esac 210 | done 211 | } 212 | 213 | __git_merge_strategies () 214 | { 215 | if [ -n "$__git_merge_strategylist" ]; then 216 | echo "$__git_merge_strategylist" 217 | return 218 | fi 219 | sed -n "/^all_strategies='/{ 220 | s/^all_strategies='// 221 | s/'// 222 | p 223 | q 224 | }" "$(git --exec-path)/git-merge" 225 | } 226 | __git_merge_strategylist= 227 | __git_merge_strategylist="$(__git_merge_strategies 2>/dev/null)" 228 | 229 | __git_complete_file () 230 | { 231 | local pfx ls ref cur="${COMP_WORDS[COMP_CWORD]}" 232 | case "$cur" in 233 | ?*:*) 234 | ref="${cur%%:*}" 235 | cur="${cur#*:}" 236 | case "$cur" in 237 | ?*/*) 238 | pfx="${cur%/*}" 239 | cur="${cur##*/}" 240 | ls="$ref:$pfx" 241 | pfx="$pfx/" 242 | ;; 243 | *) 244 | ls="$ref" 245 | ;; 246 | esac 247 | COMPREPLY=($(compgen -P "$pfx" \ 248 | -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \ 249 | | sed '/^100... blob /s,^.* ,, 250 | /^040000 tree /{ 251 | s,^.* ,, 252 | s,$,/, 253 | } 254 | s/^.* //')" \ 255 | -- "$cur")) 256 | ;; 257 | *) 258 | __gitcomp "$(__git_refs)" 259 | ;; 260 | esac 261 | } 262 | 263 | __git_complete_revlist () 264 | { 265 | local pfx cur="${COMP_WORDS[COMP_CWORD]}" 266 | case "$cur" in 267 | *...*) 268 | pfx="${cur%...*}..." 269 | cur="${cur#*...}" 270 | __gitcomp "$(__git_refs)" "$pfx" "$cur" 271 | ;; 272 | *..*) 273 | pfx="${cur%..*}.." 274 | cur="${cur#*..}" 275 | __gitcomp "$(__git_refs)" "$pfx" "$cur" 276 | ;; 277 | *.) 278 | __gitcomp "$cur." 279 | ;; 280 | *) 281 | __gitcomp "$(__git_refs)" 282 | ;; 283 | esac 284 | } 285 | 286 | __git_commands () 287 | { 288 | if [ -n "$__git_commandlist" ]; then 289 | echo "$__git_commandlist" 290 | return 291 | fi 292 | local i IFS=" "$'\n' 293 | for i in $(git help -a|egrep '^ ') 294 | do 295 | case $i in 296 | *--*) : helper pattern;; 297 | applymbox) : ask gittus;; 298 | applypatch) : ask gittus;; 299 | archimport) : import;; 300 | cat-file) : plumbing;; 301 | check-attr) : plumbing;; 302 | check-ref-format) : plumbing;; 303 | commit-tree) : plumbing;; 304 | cvsexportcommit) : export;; 305 | cvsimport) : import;; 306 | cvsserver) : daemon;; 307 | daemon) : daemon;; 308 | diff-files) : plumbing;; 309 | diff-index) : plumbing;; 310 | diff-tree) : plumbing;; 311 | fast-import) : import;; 312 | fsck-objects) : plumbing;; 313 | fetch-pack) : plumbing;; 314 | fmt-merge-msg) : plumbing;; 315 | for-each-ref) : plumbing;; 316 | hash-object) : plumbing;; 317 | http-*) : transport;; 318 | index-pack) : plumbing;; 319 | init-db) : deprecated;; 320 | local-fetch) : plumbing;; 321 | mailinfo) : plumbing;; 322 | mailsplit) : plumbing;; 323 | merge-*) : plumbing;; 324 | mktree) : plumbing;; 325 | mktag) : plumbing;; 326 | pack-objects) : plumbing;; 327 | pack-redundant) : plumbing;; 328 | pack-refs) : plumbing;; 329 | parse-remote) : plumbing;; 330 | patch-id) : plumbing;; 331 | peek-remote) : plumbing;; 332 | prune) : plumbing;; 333 | prune-packed) : plumbing;; 334 | quiltimport) : import;; 335 | read-tree) : plumbing;; 336 | receive-pack) : plumbing;; 337 | reflog) : plumbing;; 338 | repo-config) : deprecated;; 339 | rerere) : plumbing;; 340 | rev-list) : plumbing;; 341 | rev-parse) : plumbing;; 342 | runstatus) : plumbing;; 343 | sh-setup) : internal;; 344 | shell) : daemon;; 345 | send-pack) : plumbing;; 346 | show-index) : plumbing;; 347 | ssh-*) : transport;; 348 | stripspace) : plumbing;; 349 | svn) : import export;; 350 | symbolic-ref) : plumbing;; 351 | tar-tree) : deprecated;; 352 | unpack-file) : plumbing;; 353 | unpack-objects) : plumbing;; 354 | update-index) : plumbing;; 355 | update-ref) : plumbing;; 356 | update-server-info) : daemon;; 357 | upload-archive) : plumbing;; 358 | upload-pack) : plumbing;; 359 | write-tree) : plumbing;; 360 | verify-tag) : plumbing;; 361 | *) echo $i;; 362 | esac 363 | done 364 | } 365 | __git_commandlist= 366 | __git_commandlist="$(__git_commands 2>/dev/null)" 367 | 368 | __git_aliases () 369 | { 370 | local i IFS=$'\n' 371 | for i in $(git --git-dir="$(__gitdir)" config --list); do 372 | case "$i" in 373 | alias.*) 374 | i="${i#alias.}" 375 | echo "${i/=*/}" 376 | ;; 377 | esac 378 | done 379 | } 380 | 381 | __git_aliased_command () 382 | { 383 | local word cmdline=$(git --git-dir="$(__gitdir)" \ 384 | config --get "alias.$1") 385 | for word in $cmdline; do 386 | if [ "${word##-*}" ]; then 387 | echo $word 388 | return 389 | fi 390 | done 391 | } 392 | 393 | __git_whitespacelist="nowarn warn error error-all strip" 394 | 395 | _git_am () 396 | { 397 | local cur="${COMP_WORDS[COMP_CWORD]}" 398 | if [ -d .dotest ]; then 399 | __gitcomp "--skip --resolved" 400 | return 401 | fi 402 | case "$cur" in 403 | --whitespace=*) 404 | __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" 405 | return 406 | ;; 407 | --*) 408 | __gitcomp " 409 | --signoff --utf8 --binary --3way --interactive 410 | --whitespace= 411 | " 412 | return 413 | esac 414 | COMPREPLY=() 415 | } 416 | 417 | _git_apply () 418 | { 419 | local cur="${COMP_WORDS[COMP_CWORD]}" 420 | case "$cur" in 421 | --whitespace=*) 422 | __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" 423 | return 424 | ;; 425 | --*) 426 | __gitcomp " 427 | --stat --numstat --summary --check --index 428 | --cached --index-info --reverse --reject --unidiff-zero 429 | --apply --no-add --exclude= 430 | --whitespace= --inaccurate-eof --verbose 431 | " 432 | return 433 | esac 434 | COMPREPLY=() 435 | } 436 | 437 | _git_add () 438 | { 439 | local cur="${COMP_WORDS[COMP_CWORD]}" 440 | case "$cur" in 441 | --*) 442 | __gitcomp "--interactive --refresh" 443 | return 444 | esac 445 | COMPREPLY=() 446 | } 447 | 448 | _git_bisect () 449 | { 450 | local i c=1 command 451 | while [ $c -lt $COMP_CWORD ]; do 452 | i="${COMP_WORDS[c]}" 453 | case "$i" in 454 | start|bad|good|reset|visualize|replay|log) 455 | command="$i" 456 | break 457 | ;; 458 | esac 459 | c=$((++c)) 460 | done 461 | 462 | if [ $c -eq $COMP_CWORD -a -z "$command" ]; then 463 | __gitcomp "start bad good reset visualize replay log" 464 | return 465 | fi 466 | 467 | case "$command" in 468 | bad|good|reset) 469 | __gitcomp "$(__git_refs)" 470 | ;; 471 | *) 472 | COMPREPLY=() 473 | ;; 474 | esac 475 | } 476 | 477 | _git_branch () 478 | { 479 | __gitcomp "$(__git_refs)" 480 | } 481 | 482 | _git_bundle () 483 | { 484 | local mycword="$COMP_CWORD" 485 | case "${COMP_WORDS[0]}" in 486 | git) 487 | local cmd="${COMP_WORDS[2]}" 488 | mycword="$((mycword-1))" 489 | ;; 490 | git-bundle*) 491 | local cmd="${COMP_WORDS[1]}" 492 | ;; 493 | esac 494 | case "$mycword" in 495 | 1) 496 | __gitcomp "create list-heads verify unbundle" 497 | ;; 498 | 2) 499 | # looking for a file 500 | ;; 501 | *) 502 | case "$cmd" in 503 | create) 504 | __git_complete_revlist 505 | ;; 506 | esac 507 | ;; 508 | esac 509 | } 510 | 511 | _git_checkout () 512 | { 513 | __gitcomp "$(__git_refs)" 514 | } 515 | 516 | _git_cherry () 517 | { 518 | __gitcomp "$(__git_refs)" 519 | } 520 | 521 | _git_cherry_pick () 522 | { 523 | local cur="${COMP_WORDS[COMP_CWORD]}" 524 | case "$cur" in 525 | --*) 526 | __gitcomp "--edit --no-commit" 527 | ;; 528 | *) 529 | __gitcomp "$(__git_refs)" 530 | ;; 531 | esac 532 | } 533 | 534 | _git_commit () 535 | { 536 | local cur="${COMP_WORDS[COMP_CWORD]}" 537 | case "$cur" in 538 | --*) 539 | __gitcomp " 540 | --all --author= --signoff --verify --no-verify 541 | --edit --amend --include --only 542 | " 543 | return 544 | esac 545 | COMPREPLY=() 546 | } 547 | 548 | _git_describe () 549 | { 550 | __gitcomp "$(__git_refs)" 551 | } 552 | 553 | _git_diff () 554 | { 555 | local cur="${COMP_WORDS[COMP_CWORD]}" 556 | case "$cur" in 557 | --*) 558 | __gitcomp "--cached --stat --numstat --shortstat --summary 559 | --patch-with-stat --name-only --name-status --color 560 | --no-color --color-words --no-renames --check 561 | --full-index --binary --abbrev --diff-filter 562 | --find-copies-harder --pickaxe-all --pickaxe-regex 563 | --text --ignore-space-at-eol --ignore-space-change 564 | --ignore-all-space --exit-code --quiet --ext-diff 565 | --no-ext-diff" 566 | return 567 | ;; 568 | esac 569 | __git_complete_file 570 | } 571 | 572 | _git_diff_tree () 573 | { 574 | __gitcomp "$(__git_refs)" 575 | } 576 | 577 | _git_fetch () 578 | { 579 | local cur="${COMP_WORDS[COMP_CWORD]}" 580 | 581 | case "${COMP_WORDS[0]},$COMP_CWORD" in 582 | git-fetch*,1) 583 | __gitcomp "$(__git_remotes)" 584 | ;; 585 | git,2) 586 | __gitcomp "$(__git_remotes)" 587 | ;; 588 | *) 589 | case "$cur" in 590 | *:*) 591 | __gitcomp "$(__git_refs)" "" "${cur#*:}" 592 | ;; 593 | *) 594 | local remote 595 | case "${COMP_WORDS[0]}" in 596 | git-fetch) remote="${COMP_WORDS[1]}" ;; 597 | git) remote="${COMP_WORDS[2]}" ;; 598 | esac 599 | __gitcomp "$(__git_refs2 "$remote")" 600 | ;; 601 | esac 602 | ;; 603 | esac 604 | } 605 | 606 | _git_format_patch () 607 | { 608 | local cur="${COMP_WORDS[COMP_CWORD]}" 609 | case "$cur" in 610 | --*) 611 | __gitcomp " 612 | --stdout --attach --thread 613 | --output-directory 614 | --numbered --start-number 615 | --numbered-files 616 | --keep-subject 617 | --signoff 618 | --in-reply-to= 619 | --full-index --binary 620 | --not --all 621 | " 622 | return 623 | ;; 624 | esac 625 | __git_complete_revlist 626 | } 627 | 628 | _git_gc () 629 | { 630 | local cur="${COMP_WORDS[COMP_CWORD]}" 631 | case "$cur" in 632 | --*) 633 | __gitcomp "--prune --aggressive" 634 | return 635 | ;; 636 | esac 637 | COMPREPLY=() 638 | } 639 | 640 | _git_ls_remote () 641 | { 642 | __gitcomp "$(__git_remotes)" 643 | } 644 | 645 | _git_ls_tree () 646 | { 647 | __git_complete_file 648 | } 649 | 650 | _git_log () 651 | { 652 | local cur="${COMP_WORDS[COMP_CWORD]}" 653 | case "$cur" in 654 | --pretty=*) 655 | __gitcomp " 656 | oneline short medium full fuller email raw 657 | " "" "${cur##--pretty=}" 658 | return 659 | ;; 660 | --date=*) 661 | __gitcomp " 662 | relative iso8601 rfc2822 short local default 663 | " "" "${cur##--date=}" 664 | return 665 | ;; 666 | --*) 667 | __gitcomp " 668 | --max-count= --max-age= --since= --after= 669 | --min-age= --before= --until= 670 | --root --topo-order --date-order --reverse 671 | --no-merges --follow 672 | --abbrev-commit --abbrev= 673 | --relative-date --date= 674 | --author= --committer= --grep= 675 | --all-match 676 | --pretty= --name-status --name-only --raw 677 | --not --all 678 | --left-right --cherry-pick 679 | " 680 | return 681 | ;; 682 | esac 683 | __git_complete_revlist 684 | } 685 | 686 | _git_merge () 687 | { 688 | local cur="${COMP_WORDS[COMP_CWORD]}" 689 | case "${COMP_WORDS[COMP_CWORD-1]}" in 690 | -s|--strategy) 691 | __gitcomp "$(__git_merge_strategies)" 692 | return 693 | esac 694 | case "$cur" in 695 | --strategy=*) 696 | __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}" 697 | return 698 | ;; 699 | --*) 700 | __gitcomp " 701 | --no-commit --no-summary --squash --strategy 702 | " 703 | return 704 | esac 705 | __gitcomp "$(__git_refs)" 706 | } 707 | 708 | _git_merge_base () 709 | { 710 | __gitcomp "$(__git_refs)" 711 | } 712 | 713 | _git_name_rev () 714 | { 715 | __gitcomp "--tags --all --stdin" 716 | } 717 | 718 | _git_pull () 719 | { 720 | local cur="${COMP_WORDS[COMP_CWORD]}" 721 | 722 | case "${COMP_WORDS[0]},$COMP_CWORD" in 723 | git-pull*,1) 724 | __gitcomp "$(__git_remotes)" 725 | ;; 726 | git,2) 727 | __gitcomp "$(__git_remotes)" 728 | ;; 729 | *) 730 | local remote 731 | case "${COMP_WORDS[0]}" in 732 | git-pull) remote="${COMP_WORDS[1]}" ;; 733 | git) remote="${COMP_WORDS[2]}" ;; 734 | esac 735 | __gitcomp "$(__git_refs "$remote")" 736 | ;; 737 | esac 738 | } 739 | 740 | _git_push () 741 | { 742 | local cur="${COMP_WORDS[COMP_CWORD]}" 743 | 744 | case "${COMP_WORDS[0]},$COMP_CWORD" in 745 | git-push*,1) 746 | __gitcomp "$(__git_remotes)" 747 | ;; 748 | git,2) 749 | __gitcomp "$(__git_remotes)" 750 | ;; 751 | *) 752 | case "$cur" in 753 | *:*) 754 | local remote 755 | case "${COMP_WORDS[0]}" in 756 | git-push) remote="${COMP_WORDS[1]}" ;; 757 | git) remote="${COMP_WORDS[2]}" ;; 758 | esac 759 | __gitcomp "$(__git_refs "$remote")" "" "${cur#*:}" 760 | ;; 761 | +*) 762 | __gitcomp "$(__git_refs)" + "${cur#+}" 763 | ;; 764 | *) 765 | __gitcomp "$(__git_refs)" 766 | ;; 767 | esac 768 | ;; 769 | esac 770 | } 771 | 772 | _git_rebase () 773 | { 774 | local cur="${COMP_WORDS[COMP_CWORD]}" 775 | if [ -d .dotest ] || [ -d .git/.dotest-merge ]; then 776 | __gitcomp "--continue --skip --abort" 777 | return 778 | fi 779 | case "${COMP_WORDS[COMP_CWORD-1]}" in 780 | -s|--strategy) 781 | __gitcomp "$(__git_merge_strategies)" 782 | return 783 | esac 784 | case "$cur" in 785 | --strategy=*) 786 | __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}" 787 | return 788 | ;; 789 | --*) 790 | __gitcomp "--onto --merge --strategy" 791 | return 792 | esac 793 | __gitcomp "$(__git_refs)" 794 | } 795 | 796 | _git_config () 797 | { 798 | local cur="${COMP_WORDS[COMP_CWORD]}" 799 | local prv="${COMP_WORDS[COMP_CWORD-1]}" 800 | case "$prv" in 801 | branch.*.remote) 802 | __gitcomp "$(__git_remotes)" 803 | return 804 | ;; 805 | branch.*.merge) 806 | __gitcomp "$(__git_refs)" 807 | return 808 | ;; 809 | remote.*.fetch) 810 | local remote="${prv#remote.}" 811 | remote="${remote%.fetch}" 812 | __gitcomp "$(__git_refs_remotes "$remote")" 813 | return 814 | ;; 815 | remote.*.push) 816 | local remote="${prv#remote.}" 817 | remote="${remote%.push}" 818 | __gitcomp "$(git --git-dir="$(__gitdir)" \ 819 | for-each-ref --format='%(refname):%(refname)' \ 820 | refs/heads)" 821 | return 822 | ;; 823 | pull.twohead|pull.octopus) 824 | __gitcomp "$(__git_merge_strategies)" 825 | return 826 | ;; 827 | color.branch|color.diff|color.status) 828 | __gitcomp "always never auto" 829 | return 830 | ;; 831 | color.*.*) 832 | __gitcomp " 833 | black red green yellow blue magenta cyan white 834 | bold dim ul blink reverse 835 | " 836 | return 837 | ;; 838 | *.*) 839 | COMPREPLY=() 840 | return 841 | ;; 842 | esac 843 | case "$cur" in 844 | --*) 845 | __gitcomp " 846 | --global --system --file= 847 | --list --replace-all 848 | --get --get-all --get-regexp 849 | --add --unset --unset-all 850 | --remove-section --rename-section 851 | " 852 | return 853 | ;; 854 | branch.*.*) 855 | local pfx="${cur%.*}." 856 | cur="${cur##*.}" 857 | __gitcomp "remote merge" "$pfx" "$cur" 858 | return 859 | ;; 860 | branch.*) 861 | local pfx="${cur%.*}." 862 | cur="${cur#*.}" 863 | __gitcomp "$(__git_heads)" "$pfx" "$cur" "." 864 | return 865 | ;; 866 | remote.*.*) 867 | local pfx="${cur%.*}." 868 | cur="${cur##*.}" 869 | __gitcomp " 870 | url fetch push skipDefaultUpdate 871 | receivepack uploadpack tagopt 872 | " "$pfx" "$cur" 873 | return 874 | ;; 875 | remote.*) 876 | local pfx="${cur%.*}." 877 | cur="${cur#*.}" 878 | __gitcomp "$(__git_remotes)" "$pfx" "$cur" "." 879 | return 880 | ;; 881 | esac 882 | __gitcomp " 883 | apply.whitespace 884 | core.fileMode 885 | core.gitProxy 886 | core.ignoreStat 887 | core.preferSymlinkRefs 888 | core.logAllRefUpdates 889 | core.loosecompression 890 | core.repositoryFormatVersion 891 | core.sharedRepository 892 | core.warnAmbiguousRefs 893 | core.compression 894 | core.legacyHeaders 895 | core.packedGitWindowSize 896 | core.packedGitLimit 897 | clean.requireForce 898 | color.branch 899 | color.branch.current 900 | color.branch.local 901 | color.branch.remote 902 | color.branch.plain 903 | color.diff 904 | color.diff.plain 905 | color.diff.meta 906 | color.diff.frag 907 | color.diff.old 908 | color.diff.new 909 | color.diff.commit 910 | color.diff.whitespace 911 | color.pager 912 | color.status 913 | color.status.header 914 | color.status.added 915 | color.status.changed 916 | color.status.untracked 917 | diff.renameLimit 918 | diff.renames 919 | fetch.unpackLimit 920 | format.headers 921 | format.subjectprefix 922 | gitcvs.enabled 923 | gitcvs.logfile 924 | gitcvs.allbinary 925 | gitcvs.dbname gitcvs.dbdriver gitcvs.dbuser gitcvs.dvpass 926 | gc.packrefs 927 | gc.reflogexpire 928 | gc.reflogexpireunreachable 929 | gc.rerereresolved 930 | gc.rerereunresolved 931 | http.sslVerify 932 | http.sslCert 933 | http.sslKey 934 | http.sslCAInfo 935 | http.sslCAPath 936 | http.maxRequests 937 | http.lowSpeedLimit 938 | http.lowSpeedTime 939 | http.noEPSV 940 | i18n.commitEncoding 941 | i18n.logOutputEncoding 942 | log.showroot 943 | merge.tool 944 | merge.summary 945 | merge.verbosity 946 | pack.window 947 | pack.depth 948 | pack.windowMemory 949 | pack.compression 950 | pack.deltaCacheSize 951 | pack.deltaCacheLimit 952 | pull.octopus 953 | pull.twohead 954 | repack.useDeltaBaseOffset 955 | show.difftree 956 | showbranch.default 957 | tar.umask 958 | transfer.unpackLimit 959 | receive.unpackLimit 960 | receive.denyNonFastForwards 961 | user.name 962 | user.email 963 | user.signingkey 964 | whatchanged.difftree 965 | branch. remote. 966 | " 967 | } 968 | 969 | _git_remote () 970 | { 971 | local i c=1 command 972 | while [ $c -lt $COMP_CWORD ]; do 973 | i="${COMP_WORDS[c]}" 974 | case "$i" in 975 | add|rm|show|prune|update) command="$i"; break ;; 976 | esac 977 | c=$((++c)) 978 | done 979 | 980 | if [ $c -eq $COMP_CWORD -a -z "$command" ]; then 981 | __gitcomp "add rm show prune update" 982 | return 983 | fi 984 | 985 | case "$command" in 986 | rm|show|prune) 987 | __gitcomp "$(__git_remotes)" 988 | ;; 989 | update) 990 | local i c='' IFS=$'\n' 991 | for i in $(git --git-dir="$(__gitdir)" config --list); do 992 | case "$i" in 993 | remotes.*) 994 | i="${i#remotes.}" 995 | c="$c ${i/=*/}" 996 | ;; 997 | esac 998 | done 999 | __gitcomp "$c" 1000 | ;; 1001 | *) 1002 | COMPREPLY=() 1003 | ;; 1004 | esac 1005 | } 1006 | 1007 | _git_reset () 1008 | { 1009 | local cur="${COMP_WORDS[COMP_CWORD]}" 1010 | case "$cur" in 1011 | --*) 1012 | __gitcomp "--mixed --hard --soft" 1013 | return 1014 | ;; 1015 | esac 1016 | __gitcomp "$(__git_refs)" 1017 | } 1018 | 1019 | _git_shortlog () 1020 | { 1021 | local cur="${COMP_WORDS[COMP_CWORD]}" 1022 | case "$cur" in 1023 | --*) 1024 | __gitcomp " 1025 | --max-count= --max-age= --since= --after= 1026 | --min-age= --before= --until= 1027 | --no-merges 1028 | --author= --committer= --grep= 1029 | --all-match 1030 | --not --all 1031 | --numbered --summary 1032 | " 1033 | return 1034 | ;; 1035 | esac 1036 | __git_complete_revlist 1037 | } 1038 | 1039 | _git_show () 1040 | { 1041 | local cur="${COMP_WORDS[COMP_CWORD]}" 1042 | case "$cur" in 1043 | --pretty=*) 1044 | __gitcomp " 1045 | oneline short medium full fuller email raw 1046 | " "" "${cur##--pretty=}" 1047 | return 1048 | ;; 1049 | --*) 1050 | __gitcomp "--pretty=" 1051 | return 1052 | ;; 1053 | esac 1054 | __git_complete_file 1055 | } 1056 | 1057 | _git_stash () 1058 | { 1059 | __gitcomp 'list show apply clear' 1060 | } 1061 | 1062 | _git_submodule () 1063 | { 1064 | local i c=1 command 1065 | while [ $c -lt $COMP_CWORD ]; do 1066 | i="${COMP_WORDS[c]}" 1067 | case "$i" in 1068 | add|status|init|update) command="$i"; break ;; 1069 | esac 1070 | c=$((++c)) 1071 | done 1072 | 1073 | if [ $c -eq $COMP_CWORD -a -z "$command" ]; then 1074 | local cur="${COMP_WORDS[COMP_CWORD]}" 1075 | case "$cur" in 1076 | --*) 1077 | __gitcomp "--quiet --cached" 1078 | ;; 1079 | *) 1080 | __gitcomp "add status init update" 1081 | ;; 1082 | esac 1083 | return 1084 | fi 1085 | } 1086 | 1087 | _git_tag () 1088 | { 1089 | local i c=1 f=0 1090 | while [ $c -lt $COMP_CWORD ]; do 1091 | i="${COMP_WORDS[c]}" 1092 | case "$i" in 1093 | -d|-v) 1094 | __gitcomp "$(__git_tags)" 1095 | return 1096 | ;; 1097 | -f) 1098 | f=1 1099 | ;; 1100 | esac 1101 | c=$((++c)) 1102 | done 1103 | 1104 | case "${COMP_WORDS[COMP_CWORD-1]}" in 1105 | -m|-F) 1106 | COMPREPLY=() 1107 | ;; 1108 | -*|tag|git-tag) 1109 | if [ $f = 1 ]; then 1110 | __gitcomp "$(__git_tags)" 1111 | else 1112 | COMPREPLY=() 1113 | fi 1114 | ;; 1115 | *) 1116 | __gitcomp "$(__git_refs)" 1117 | ;; 1118 | esac 1119 | } 1120 | 1121 | _git () 1122 | { 1123 | local i c=1 command __git_dir 1124 | 1125 | while [ $c -lt $COMP_CWORD ]; do 1126 | i="${COMP_WORDS[c]}" 1127 | case "$i" in 1128 | --git-dir=*) __git_dir="${i#--git-dir=}" ;; 1129 | --bare) __git_dir="." ;; 1130 | --version|--help|-p|--paginate) ;; 1131 | *) command="$i"; break ;; 1132 | esac 1133 | c=$((++c)) 1134 | done 1135 | 1136 | if [ $c -eq $COMP_CWORD -a -z "$command" ]; then 1137 | case "${COMP_WORDS[COMP_CWORD]}" in 1138 | --*=*) COMPREPLY=() ;; 1139 | --*) __gitcomp " 1140 | --no-pager 1141 | --git-dir= 1142 | --bare 1143 | --version 1144 | --exec-path 1145 | " 1146 | ;; 1147 | *) __gitcomp "$(__git_commands) $(__git_aliases)" ;; 1148 | esac 1149 | return 1150 | fi 1151 | 1152 | local expansion=$(__git_aliased_command "$command") 1153 | [ "$expansion" ] && command="$expansion" 1154 | 1155 | case "$command" in 1156 | am) _git_am ;; 1157 | add) _git_add ;; 1158 | apply) _git_apply ;; 1159 | bisect) _git_bisect ;; 1160 | bundle) _git_bundle ;; 1161 | branch) _git_branch ;; 1162 | checkout) _git_checkout ;; 1163 | cherry) _git_cherry ;; 1164 | cherry-pick) _git_cherry_pick ;; 1165 | commit) _git_commit ;; 1166 | config) _git_config ;; 1167 | describe) _git_describe ;; 1168 | diff) _git_diff ;; 1169 | fetch) _git_fetch ;; 1170 | format-patch) _git_format_patch ;; 1171 | gc) _git_gc ;; 1172 | log) _git_log ;; 1173 | ls-remote) _git_ls_remote ;; 1174 | ls-tree) _git_ls_tree ;; 1175 | merge) _git_merge;; 1176 | merge-base) _git_merge_base ;; 1177 | name-rev) _git_name_rev ;; 1178 | pull) _git_pull ;; 1179 | push) _git_push ;; 1180 | rebase) _git_rebase ;; 1181 | remote) _git_remote ;; 1182 | reset) _git_reset ;; 1183 | shortlog) _git_shortlog ;; 1184 | show) _git_show ;; 1185 | show-branch) _git_log ;; 1186 | stash) _git_stash ;; 1187 | submodule) _git_submodule ;; 1188 | tag) _git_tag ;; 1189 | whatchanged) _git_log ;; 1190 | *) COMPREPLY=() ;; 1191 | esac 1192 | } 1193 | 1194 | _gitk () 1195 | { 1196 | local cur="${COMP_WORDS[COMP_CWORD]}" 1197 | case "$cur" in 1198 | --*) 1199 | __gitcomp "--not --all" 1200 | return 1201 | ;; 1202 | esac 1203 | __git_complete_revlist 1204 | } 1205 | 1206 | complete -o default -o nospace -F _git git 1207 | complete -o default -o nospace -F _gitk gitk 1208 | complete -o default -o nospace -F _git_am git-am 1209 | complete -o default -o nospace -F _git_apply git-apply 1210 | complete -o default -o nospace -F _git_bisect git-bisect 1211 | complete -o default -o nospace -F _git_branch git-branch 1212 | complete -o default -o nospace -F _git_bundle git-bundle 1213 | complete -o default -o nospace -F _git_checkout git-checkout 1214 | complete -o default -o nospace -F _git_cherry git-cherry 1215 | complete -o default -o nospace -F _git_cherry_pick git-cherry-pick 1216 | complete -o default -o nospace -F _git_commit git-commit 1217 | complete -o default -o nospace -F _git_describe git-describe 1218 | complete -o default -o nospace -F _git_diff git-diff 1219 | complete -o default -o nospace -F _git_fetch git-fetch 1220 | complete -o default -o nospace -F _git_format_patch git-format-patch 1221 | complete -o default -o nospace -F _git_gc git-gc 1222 | complete -o default -o nospace -F _git_log git-log 1223 | complete -o default -o nospace -F _git_ls_remote git-ls-remote 1224 | complete -o default -o nospace -F _git_ls_tree git-ls-tree 1225 | complete -o default -o nospace -F _git_merge git-merge 1226 | complete -o default -o nospace -F _git_merge_base git-merge-base 1227 | complete -o default -o nospace -F _git_name_rev git-name-rev 1228 | complete -o default -o nospace -F _git_pull git-pull 1229 | complete -o default -o nospace -F _git_push git-push 1230 | complete -o default -o nospace -F _git_rebase git-rebase 1231 | complete -o default -o nospace -F _git_config git-config 1232 | complete -o default -o nospace -F _git_remote git-remote 1233 | complete -o default -o nospace -F _git_reset git-reset 1234 | complete -o default -o nospace -F _git_shortlog git-shortlog 1235 | complete -o default -o nospace -F _git_show git-show 1236 | complete -o default -o nospace -F _git_stash git-stash 1237 | complete -o default -o nospace -F _git_submodule git-submodule 1238 | complete -o default -o nospace -F _git_log git-show-branch 1239 | complete -o default -o nospace -F _git_tag git-tag 1240 | complete -o default -o nospace -F _git_log git-whatchanged 1241 | 1242 | # The following are necessary only for Cygwin, and only are needed 1243 | # when the user has tab-completed the executable name and consequently 1244 | # included the '.exe' suffix. 1245 | # 1246 | if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then 1247 | complete -o default -o nospace -F _git_add git-add.exe 1248 | complete -o default -o nospace -F _git_apply git-apply.exe 1249 | complete -o default -o nospace -F _git git.exe 1250 | complete -o default -o nospace -F _git_branch git-branch.exe 1251 | complete -o default -o nospace -F _git_bundle git-bundle.exe 1252 | complete -o default -o nospace -F _git_cherry git-cherry.exe 1253 | complete -o default -o nospace -F _git_describe git-describe.exe 1254 | complete -o default -o nospace -F _git_diff git-diff.exe 1255 | complete -o default -o nospace -F _git_format_patch git-format-patch.exe 1256 | complete -o default -o nospace -F _git_log git-log.exe 1257 | complete -o default -o nospace -F _git_ls_tree git-ls-tree.exe 1258 | complete -o default -o nospace -F _git_merge_base git-merge-base.exe 1259 | complete -o default -o nospace -F _git_name_rev git-name-rev.exe 1260 | complete -o default -o nospace -F _git_push git-push.exe 1261 | complete -o default -o nospace -F _git_config git-config 1262 | complete -o default -o nospace -F _git_shortlog git-shortlog.exe 1263 | complete -o default -o nospace -F _git_show git-show.exe 1264 | complete -o default -o nospace -F _git_log git-show-branch.exe 1265 | complete -o default -o nospace -F _git_tag git-tag.exe 1266 | complete -o default -o nospace -F _git_log git-whatchanged.exe 1267 | fi 1268 | -------------------------------------------------------------------------------- /git-compressallrepos: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | find . -path '*.git/config' -execdir git gc --aggressive \; -------------------------------------------------------------------------------- /git-deletealltags: -------------------------------------------------------------------------------- 1 | for t in `git tag` 2 | do 3 | git push origin :$t 4 | git tag -d $t 5 | done -------------------------------------------------------------------------------- /git-draw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # NAME 4 | # git-draw - draws nearly the full content of a tiny git repository as a graph 5 | # 6 | # SYNOPSIS 7 | # git-draw [OPTION]... 8 | # 9 | # PREREQUISITES 10 | # You don't need graphviz or imagemagick if you use git-draw with certain 11 | # options. 12 | # 13 | # - perl 14 | # - graphviz (http://www.graphviz.org/) 15 | # - imagemagick (http://www.imagemagick.org) 16 | # 17 | # If you have apt you can install these with: 18 | # 19 | # sudo apt-get install perl graphviz imagemagick 20 | # 21 | # DESCRIPTION 22 | # git-draw is composed of three main steps, where the 2nd and 3rd are just 23 | # for convenience and are not part of git-draw's core responsibility. 24 | # 25 | # 1) A .dot file describing the repository's content as a graph is created. 26 | # 2) dot (see graphviz) is called to produce an image out of that .dot file. 27 | # 3) display (see imagemagick) is called to display that image. 28 | # 29 | # Because git-draw currently is quite dumb, the current working directory 30 | # must be at the root of the working tree of your project, i.e. the 31 | # directory which contains the .git directory. 32 | # 33 | # The intention is to help learning Git's basic concepts (references, Git 34 | # objects, SHA-1 checksum over content as id). Virtually all information 35 | # concerning Git's basic concepts is contained in the drawing. Thus git-draw 36 | # is aimed at tiny toy Git repositories and at users with an engineer 37 | # background, i.e. users which are not scared off by terms like checksum, 38 | # references aka pointers and graphs. 39 | # 40 | # OPTIONS 41 | # -p, --print-only 42 | # Only prints the .dot file to STDOUT. Mutually exclusive with 43 | # --image-only. 44 | # 45 | # -i, --image-only 46 | # Only generates an image of the graph, and a .dot file beforehand. 47 | # Mutually exclusive with --print-only. 48 | # 49 | # AUTHOR 50 | # Written by Florian Kaufmann 51 | # 52 | # COPYRIGHT 53 | # Florian Kaufmann 2014. License GPLv3+: GNU GPL version 3 or later 54 | # . This is free software: you are free to 55 | # change and redistribute it. There is NO WARRANTY, to the extent permitted 56 | # by law. 57 | # 58 | # SEE ALSO 59 | # git(1) 60 | 61 | # $1 = exit code 62 | print_usage_and_exit() { 63 | cat < _" . 167 | `git rev-parse --short=4 $1` if /([a-f0-9]{40})/' 168 | done 169 | 170 | git fsck --cache --unreachable --dangling 2>/dev/null | 171 | perl -ne 'print " _" . substr(`git rev-parse --short=4 $1`,0,-1) . 172 | " [style=dotted]\n" if /^(?:dangling|unreachable)\b.*?([a-f0-9]{40})/' 173 | } 174 | 175 | print_dot_references() { 176 | ls_all_refs | 177 | perl -ne ' 178 | if (m@(\S+)\s+(\S+?)$@) { 179 | $me = $2; 180 | $other = $1; 181 | $dotid_me = "_" . (($tmp = $me) =~ s@([^a-zA-Z0-9_])@___@g,$tmp); 182 | $dotid_other = "_" . (($tmp = $other) =~ s@([^a-zA-Z0-9_])@___@g,$tmp); 183 | ($otherquoted = $other) =~ s/([^a-zA-Z0-9\n])/\\$1/g; 184 | ($mequoted = $me) =~ s/([^a-zA-Z0-9\n])/\\$1/g; 185 | $reftype = ""; 186 | $fillcolor = "gray"; 187 | $configmetadata = ""; 188 | if ($me =~ m@^refs/heads/@) { 189 | $reftype = ":local branch"; 190 | ($me_short = $me) =~ s@^refs/heads/@@; 191 | $remote = substr(`git config --get branch\\.$me_short\\.remote`,0,-1); 192 | $merge = substr(`git config --get branch\\.$me_short\\.merge`,0,-1); 193 | if ($remote && $merge) { 194 | if ($remote eq ".") { 195 | $dotid_merge = "_" . (($tmp = $merge) =~ s@([^a-zA-Z0-9_])@___@g,$tmp); 196 | } else { 197 | $dotid_merge_core = $merge; 198 | $dotid_merge_core =~ s@^refs/heads/@@; 199 | $dotid_merge_core =~ s@([^a-zA-Z0-9_])@___@g; 200 | $dotid_remote = (($tmp = $remote) =~ s@([^a-zA-Z0-9_])@___@g,$tmp); 201 | $dotid_merge = "_refs___remotes___${dotid_remote}___${dotid_merge_core}"; 202 | } 203 | print " $dotid_me -> $dotid_merge [style=dotted, color=gray, fontcolor=gray, " . 204 | "label=\"upstream branch\"]\n"; 205 | $tmp = "remote = $remote\nmerge = $merge\n"; 206 | $tmp =~ s/([^a-zA-Z0-9\n])/\\$1/g; # quote for dot 207 | $tmp =~ s/\n/\\l/g; # \l instead \n newline 208 | $configmetadata = "|$tmp" 209 | } 210 | } 211 | elsif ($me =~ m@^refs/remotes/@) { 212 | $reftype = ":remote tracking branch"; 213 | $fillcolor = "yellow"; 214 | } 215 | elsif ($me =~ m@^refs/tags/@) { 216 | $reftype = ":tag"; 217 | $fillcolor = "lightyellow"; 218 | } 219 | if ( ($other !~ m/^[a-f0-9]+$/) && 220 | 0!=system("git show-ref --verify --quiet -- $other") ) { 221 | print " $dotid_me [style=filled, fillcolor=red, " . 222 | "label=\"{{ref$reftype|$mequoted}|" . 223 | "$otherquoted (referee does not exist)\\l$configmetadata}\"]\n"; 224 | } else { 225 | if ($me eq "HEAD") { 226 | $fillcolor="gray30"; 227 | $fontcolorelement = "fontcolor=white, "; 228 | } 229 | print " $dotid_me [style=filled, fillcolor=$fillcolor, $fontcolorelement " . 230 | "label=\"{{ref$reftype|$mequoted}|$otherquoted\\l$configmetadata}\"]\n"; 231 | print " $dotid_me -> $dotid_other\n"; 232 | } 233 | }' 234 | } 235 | 236 | print_dot_ref_logs() { 237 | firstiter="non-empty-string" # i.e. true 238 | git show-ref --abbrev=4 | 239 | # The following code depends upon HEAD being the last in the list 240 | perl -pe 's@^.*?(\brefs/\S*)$@$1@; END { print "HEAD\n";}' | 241 | while read refname; do 242 | # work around the problem that 'git reflog show HEAD' results in an 243 | # error when HEAD contains refs/heads/master but refs/heads/master does 244 | # not exist, which is the case after 'git init'. 245 | if [ ! \( "$firstiter" -a \( "$refname" = HEAD \) \) ]; then 246 | # 8eb068f master@{11}: commit: tempo-ext: new version 247 | git reflog show $refname | perl -ne ' 248 | BEGIN { 249 | $refname = "'$refname'"; 250 | $dotid_reflog = "reflog_" . (($tmp = $refname) =~ s@([^a-zA-Z0-9_])@___@g,$tmp); 251 | } 252 | 253 | if (m/^([a-f0-9]+).*@\{\d+\}: (.*?)$/) { $id_any=$1; $msg=$2; } 254 | elsif (m/^([a-f0-9]+)/) { $id_any=$1; $msg=""; } 255 | $id_short = substr(`git rev-parse --short=4 $id_any`,0,-1); 256 | print " $dotid_reflog -> _$id_short [color=gray90]\n"; 257 | 258 | s/^[a-f0-9]+//; # strip sha1; $id_short will be used instead 259 | s/([^a-zA-Z0-9\n])/\\$1/g; # quote for dot 260 | s/(\r?\n)?$/\\l/; # \l instead \n newline, and ensure \l at 261 | # end of content 262 | $content = $content . $id_short . $_; 263 | 264 | END { 265 | $trailing = (substr($content,-2) eq "\\l") ? "" : "\\l"; 266 | print " $dotid_reflog [color=gray90, fontcolor=gray, " . 267 | "label=\"{{reflog|logs/$refname}|$content$trailing}\"]\n"; 268 | }' 269 | fi 270 | firstiter="" # empty stringt, i.e. false 271 | done 272 | } 273 | 274 | print_dot_index() { 275 | git ls-files --stage --abbrev=4 | perl -ne ' 276 | if (/^[0-9]+\s+([a-f0-9]+)/) { 277 | print " index -> _$1\n"; 278 | 279 | s/([^a-zA-Z0-9\r\n])/\\$1/g; # quote for dot 280 | s/(\r?\n)?$/\\l/; # \l instead \n newline, and ensure \l at 281 | # end of content 282 | $content = $content . $_; 283 | } 284 | END { 285 | $trailing = (substr($content,-2) eq "\\l") ? "" : "\\l"; 286 | print " index [style=filled, fillcolor=lightcyan, " . 287 | "label=\"{{index}|$content$trailing}\"]\n"; 288 | }' 289 | } 290 | 291 | print_dot() { 292 | echo "digraph structs {" 293 | echo " node [shape=record,fontsize=11];" 294 | echo " subgraph cluster_0 {" 295 | echo " color=gray80;" 296 | echo " label = \"legend\\l\";" 297 | echo " legend_node [label=\"{{type:subtype|id/name}|content\\l|metadata from config\\l}\"]" 298 | echo " }" 299 | 300 | print_dot_objects 301 | print_dot_references 302 | print_dot_ref_logs 303 | print_dot_index 304 | echo "}" 305 | } 306 | 307 | # process options 308 | dotfilename=git-draw.dot 309 | imgfilename=git-draw.png 310 | if [ $# = 0 ]; then 311 | : 312 | elif [ \( $# = 1 \) -a \( "$1" = "-p" -o "$1" = "--print-only" \) ] ; then 313 | print_only=1 314 | elif [ \( $# = 1 \) -a \( "$1" = "-i" -o "$1" = "--image-only" \) ] ; then 315 | image_only=1 316 | elif [ \( $# = 1 \) -a \( "$1" = "--help" \) ] ; then 317 | print_usage_and_exit 0 318 | else 319 | echo "Invalid options" >&2 320 | print_usage_and_exit 1 >&2 321 | exit 1 322 | fi 323 | 324 | # check preconditions 325 | if [ ! -d .git ]; then 326 | echo "Not a git repository" >&2 327 | exit 1 328 | fi 329 | if ! which perl >&2 >/dev/null; then 330 | cat >&2 <"$dotfilename" || exit 1 343 | 344 | # build and image out of the .dot file 345 | if ! which dot >&2 >/dev/null; then 346 | cat >&2 < "$imgfilename" || exit 1 354 | 355 | # display image 356 | if [ "$image_only" = 1 ] ; then 357 | exit 0 358 | fi 359 | if ! which display >&2 >/dev/null; then 360 | cat >&2 </dev/null 25 | 26 | # Switch to the git-enabled project directory 27 | if [ "$1" = "-v" ]; then 28 | echo "TESTING:" $gitprojpath 29 | fi 30 | cd $gitprojpath 31 | 32 | # Are there any changed files in the status output? 33 | isdirty=$(git status -s | grep "^.*") 34 | if [ -n "$isdirty" ]; then 35 | # Should output be verbose? 36 | if [ "$1" = "-vv" ]; then 37 | echo "DIRTY:" $gitprojpath 38 | git status -s 39 | # Or should output be quiet? 40 | else 41 | echo "DIRTY:" $gitprojpath 42 | fi 43 | fi 44 | # Return to the starting directory, suppressing the output 45 | popd >/dev/null 46 | done 47 | 48 | # restore the input field separator 49 | IFS=$OLDIFS 50 | -------------------------------------------------------------------------------- /git-findunpushed: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ############################################################################## 4 | # Find any dirty git projects in the current working directory 5 | # and recursively beneath this directory 6 | # 7 | # USAGE: 8 | # finddirtygit 9 | # Quiet mode that outputs only the project that is dirty 10 | # finddirtygit -v 11 | # Verbose mode that outputs what folders are being tested 12 | # finddirtygit -vv 13 | # Very verbose mode that outputs what files are dirty 14 | ############################################################################## 15 | 16 | # Preserve the old input field separator 17 | OLDIFS=$IFS 18 | # Change the input field separator from a space to a null 19 | IFS=$'\n' 20 | 21 | # Find all directories that have a .git directory in them 22 | for gitprojpath in `find . -type d -name .git | sort | sed "s/\/\.git//"`; do 23 | # Save the current working directory before CDing for git's purpose 24 | pushd . >/dev/null 25 | 26 | # Switch to the git-enabled project directory 27 | if [ "$1" = "-v" ]; then 28 | echo "TESTING:" $gitprojpath 29 | fi 30 | cd $gitprojpath 31 | 32 | # Are there any changed files in the status output? 33 | isdirty=$(git wtf | grep "you should push") 34 | if [ -n "$isdirty" ]; then 35 | # Should output be verbose? 36 | if [ "$1" = "-vv" ]; then 37 | echo "DIRTY:" $gitprojpath 38 | git wtf 39 | echo 40 | # Or should output be quiet? 41 | else 42 | echo "DIRTY:" $gitprojpath 43 | fi 44 | fi 45 | # Return to the starting directory, suppressing the output 46 | popd >/dev/null 47 | done 48 | 49 | # restore the input field separator 50 | IFS=$OLDIFS 51 | 52 | -------------------------------------------------------------------------------- /git-gc_recursive: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | find . -iname .git -type d | sed "s/\(.*\)/pushd \"\1\"; git gc; popd/" | sh -------------------------------------------------------------------------------- /git-graphlive: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | numRegex='[0-9]+$' 3 | usrLen=$1 4 | usrTime=$2 5 | defLen=15 6 | defTime=3 7 | 8 | # Command line argument processing 9 | if [[ $usrLen =~ $numRegex && $usrTime =~ $numRegex ]]; then 10 | # A valid number of lines and refresh rate were passed in 11 | else 12 | # Invalid or no lines and refresh rate were provided 13 | # so instead, using defaults instead. 14 | usrLen=$defLen 15 | usrTime=$defTime 16 | fi 17 | 18 | # Infinite loop for displaying a portion of the graph 19 | # at specified refresh intervals. 20 | while : 21 | do 22 | clear 23 | git --no-pager log -$usrLen --graph --all --pretty=format:'%Cgreen%h%Creset -%C(yellow)%d%Creset %s' --abbrev-commit --date=relative 24 | sleep $usrTime 25 | done 26 | 27 | -------------------------------------------------------------------------------- /git-plotrepo.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | # Usage: ruby plotrepo.rb /path/to/repository | dot -Tpng | display -antialias 4 | 5 | require 'grit' 6 | 7 | $commits = {} 8 | 9 | def commit_node_label(commit) 10 | return "#{commit.id.slice 0,5}\\n(#{commit.message.split("\n")[0]})" 11 | end 12 | 13 | def plot_tree (commit) 14 | if $commits.has_key? commit.id 15 | return 16 | else 17 | $commits[commit.id] = 1 18 | 19 | commit.parents.each do |c| 20 | puts "\"#{commit_node_label commit}\" -> \"#{commit_node_label c}\";" 21 | plot_tree(c) 22 | end 23 | end 24 | end 25 | 26 | def plot_tags(repo) 27 | repo.tags.each do |tag| 28 | puts "\"#{tag.name}\" -> \"#{commit_node_label tag.commit}\";" 29 | puts "\"#{tag.name}\" [shape=box, style=filled, color = yellow];" 30 | end 31 | end 32 | 33 | def draw_head(repo) 34 | head = repo.head.name; 35 | puts "\"HEAD\" [shape=box, style=filled, color = green];" 36 | puts "\"HEAD\" -> \"#{head}\";" 37 | end 38 | 39 | def draw_branch_heads(repo) 40 | repo.branches.each do |b| 41 | puts "\"#{b.name}\" -> \"#{commit_node_label b.commit}\";" 42 | puts "\"#{b.name}\" [shape=polygon, sides=6, style=filled, color = red];" 43 | plot_tree(b.commit) 44 | end 45 | end 46 | 47 | puts "Digraph F {" 48 | puts 'ranksep=0.5; size = "17.5,7.5"; rankdir=RL;' 49 | repo = Grit::Repo.new(ARGV[0]); 50 | draw_branch_heads(repo) 51 | plot_tags(repo) 52 | draw_head(repo) 53 | puts "}" 54 | 55 | -------------------------------------------------------------------------------- /git-publish-branch: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | ## git-publish-branch: a simple script to ease the unnecessarily complex 4 | ## task of "publishing" a branch, i.e., taking a local branch, creating a 5 | ## reference to it on a remote repo, and setting up the local branch to 6 | ## track the remote one, all in one go. you can even delete that remote 7 | ## reference. 8 | ## 9 | ## Usage: git publish-branch [-d] [repository] 10 | ## 11 | ## '-d' signifies deletion. is the branch to publish, and 12 | ## [repository] defaults to "origin". The remote branch name will be the 13 | ## same as the local branch name. Don't make life unnecessarily complex 14 | ## for yourself. 15 | ## 16 | ## Note that unpublishing a branch doesn't delete the local branch. 17 | ## Safety first! 18 | ## 19 | ## git-publish-branch Copyright 2008 William Morgan . 20 | ## This program is free software: you can redistribute it and/or modify 21 | ## it under the terms of the GNU General Public License as published by 22 | ## the Free Software Foundation, either version 3 of the License, or (at 23 | ## your option) any later version. 24 | ## 25 | ## This program is distributed in the hope that it will be useful, 26 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 27 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 28 | ## GNU General Public License for more details. 29 | ## 30 | ## You can find the GNU General Public License at: 31 | ## http://www.gnu.org/licenses/ 32 | 33 | def exec cmd 34 | puts cmd 35 | system cmd or abort unless $fake 36 | end 37 | 38 | 39 | head = `git symbolic-ref HEAD`.chomp.gsub(/refs\/heads\//, "") 40 | delete = ARGV.delete "-d" 41 | $fake = ARGV.delete "-n" 42 | branch = (ARGV.shift || head).gsub(/refs\/heads\//, "") 43 | remote = ARGV.shift || "origin" 44 | local_ref = `git show-ref heads/#{branch}` 45 | remote_ref = `git show-ref remotes/#{remote}/#{branch}` 46 | remote_config = `git config branch.#{branch}.merge` 47 | 48 | if delete 49 | ## we don't do any checking here because the remote branch might actually 50 | ## exist, whether we actually know about it or not. 51 | exec "git push #{remote} :refs/heads/#{branch}" 52 | 53 | unless local_ref.empty? 54 | exec "git config --unset branch.#{branch}.remote" 55 | exec "git config --unset branch.#{branch}.merge" 56 | end 57 | else 58 | abort "No local branch #{branch} exists!" if local_ref.empty? 59 | abort "A remote branch #{branch} on #{remote} already exists!" unless remote_ref.empty? 60 | abort "Local branch #{branch} is already a tracking branch!" unless remote_config.empty? 61 | 62 | exec "git push #{remote} #{branch}:refs/heads/#{branch}" 63 | exec "git config branch.#{branch}.remote #{remote}" 64 | exec "git config branch.#{branch}.merge refs/heads/#{branch}" 65 | end 66 | 67 | -------------------------------------------------------------------------------- /git-rank-contributors: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | ## git-rank-contributors: a simple script to trace through the logs and 4 | ## rank contributors by the total size of the diffs they're responsible for. 5 | ## A change counts twice as much as a plain addition or deletion. 6 | ## 7 | ## Output may or may not be suitable for inclusion in a CREDITS file. 8 | ## Probably not without some editing, because people often commit from more 9 | ## than one address. 10 | ## 11 | ## git-rank-contributors Copyright 2008 William Morgan . 12 | ## This program is free software: you can redistribute it and/or modify 13 | ## it under the terms of the GNU General Public License as published by 14 | ## the Free Software Foundation, either version 3 of the License, or (at 15 | ## your option) any later version. 16 | ## 17 | ## This program is distributed in the hope that it will be useful, 18 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | ## GNU General Public License for more details. 21 | ## 22 | ## You can find the GNU General Public License at: 23 | ## http://www.gnu.org/licenses/ 24 | 25 | class String 26 | def obfuscate; gsub(/@/, " at the ").gsub(/\.(\w+)(>|$)/, ' dot \1s\2') end 27 | def htmlize; gsub("&", "&").gsub("<", "<").gsub(">", ">") end 28 | end 29 | 30 | lines = {} 31 | verbose = ARGV.delete("-v") 32 | obfuscate = ARGV.delete("-o") 33 | htmlize = ARGV.delete("-h") 34 | 35 | author = nil 36 | state = :pre_author 37 | `git log -M -C -C -p --no-color`.each do |l| 38 | case 39 | when (state == :pre_author || state == :post_author) && l =~ /Author: (.*)$/ 40 | author = $1 41 | state = :post_author 42 | lines[author] ||= 0 43 | when state == :post_author && l =~ /^\+\+\+/ 44 | state = :in_diff 45 | when state == :in_diff && l =~ /^[\+\-]/ 46 | lines[author] += 1 47 | when state == :in_diff && l =~ /^commit / 48 | state = :pre_author 49 | end 50 | end 51 | 52 | lines.sort_by { |a, c| -c }.each do |a, c| 53 | a = a.obfuscate if obfuscate 54 | a = a.htmlize if htmlize 55 | if verbose 56 | puts "#{a}: #{c} lines of diff" 57 | else 58 | puts a 59 | end 60 | end 61 | -------------------------------------------------------------------------------- /git-rmignored: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 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. 4 | 5 | for eachthing in `git ls-files --others --ignored --exclude-standard`; do if [ -e "$eachthing" ]; then git rm $eachthing; fi; done 6 | -------------------------------------------------------------------------------- /git-wtf: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | HELP = < 54 | .git-wtfrc" and edit it. The config file is a YAML file that specifies the 55 | integration branches, any branches to ignore, and the max number of commits to 56 | display when --all-commits isn't used. git-wtf will look for a .git-wtfrc file 57 | starting in the current directory, and recursively up to the root. 58 | 59 | IMPORTANT NOTE: all local branches referenced in .git-wtfrc must be prefixed 60 | with heads/, e.g. "heads/master". Remote branches must be of the form 61 | remotes//. 62 | EOS 63 | 64 | COPYRIGHT = <. 66 | This program is free software: you can redistribute it and/or modify it 67 | under the terms of the GNU General Public License as published by the Free 68 | Software Foundation, either version 3 of the License, or (at your option) 69 | any later version. 70 | 71 | This program is distributed in the hope that it will be useful, but WITHOUT 72 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 73 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 74 | more details. 75 | 76 | You can find the GNU General Public License at: http://www.gnu.org/licenses/ 77 | EOS 78 | 79 | require 'yaml' 80 | CONFIG_FN = ".git-wtfrc" 81 | 82 | class Numeric; def pluralize s; "#{to_s} #{s}" + (self != 1 ? "s" : "") end end 83 | 84 | if ARGV.delete("--help") || ARGV.delete("-h") 85 | puts USAGE 86 | exit 87 | end 88 | 89 | ## poor man's trollop 90 | $long = ARGV.delete("--long") || ARGV.delete("-l") 91 | $short = ARGV.delete("--short") || ARGV.delete("-s") 92 | $all = ARGV.delete("--all") || ARGV.delete("-a") 93 | $all_commits = ARGV.delete("--all-commits") || ARGV.delete("-A") 94 | $dump_config = ARGV.delete("--dump-config") 95 | $key = ARGV.delete("--key") || ARGV.delete("-k") 96 | $show_relations = ARGV.delete("--relations") || ARGV.delete("-r") 97 | ARGV.each { |a| abort "Error: unknown argument #{a}." if a =~ /^--/ } 98 | 99 | ## search up the path for a file 100 | def find_file fn 101 | while true 102 | return fn if File.exist? fn 103 | fn2 = File.join("..", fn) 104 | return nil if File.expand_path(fn2) == File.expand_path(fn) 105 | fn = fn2 106 | end 107 | end 108 | 109 | want_color = `git config color.wtf` 110 | want_color = `git config color.ui` if want_color.empty? 111 | $color = case want_color.chomp 112 | when "true"; true 113 | when "auto"; $stdout.tty? 114 | end 115 | 116 | def red s; $color ? "\033[31m#{s}\033[0m" : s end 117 | def green s; $color ? "\033[32m#{s}\033[0m" : s end 118 | def yellow s; $color ? "\033[33m#{s}\033[0m" : s end 119 | def cyan s; $color ? "\033[36m#{s}\033[0m" : s end 120 | def grey s; $color ? "\033[1;30m#{s}\033[0m" : s end 121 | def purple s; $color ? "\033[35m#{s}\033[0m" : s end 122 | 123 | ## the set of commits in 'to' that aren't in 'from'. 124 | ## if empty, 'to' has been merged into 'from'. 125 | def commits_between from, to 126 | if $long 127 | `git log --pretty=format:"- %s [#{yellow "%h"}] (#{purple "%ae"}; %ar)" #{from}..#{to}` 128 | else 129 | `git log --pretty=format:"- %s [#{yellow "%h"}]" #{from}..#{to}` 130 | end.split(/[\r\n]+/) 131 | end 132 | 133 | def show_commits commits, prefix=" " 134 | if commits.empty? 135 | puts "#{prefix} none" 136 | else 137 | max = $all_commits ? commits.size : $config["max_commits"] 138 | max -= 1 if max == commits.size - 1 # never show "and 1 more" 139 | commits[0 ... max].each { |c| puts "#{prefix}#{c}" } 140 | puts grey("#{prefix}... and #{commits.size - max} more (use -A to see all).") if commits.size > max 141 | end 142 | end 143 | 144 | def ahead_behind_string ahead, behind 145 | [ahead.empty? ? nil : "#{ahead.size.pluralize 'commit'} ahead", 146 | behind.empty? ? nil : "#{behind.size.pluralize 'commit'} behind"]. 147 | compact.join("; ") 148 | end 149 | 150 | def widget merged_in, remote_only=false, local_only=false, local_only_merge=false 151 | left, right = case 152 | when remote_only; %w({ }) 153 | when local_only; %w{( )} 154 | else %w([ ]) 155 | end 156 | middle = case 157 | when merged_in && local_only_merge; green("~") 158 | when merged_in; green("x") 159 | else " " 160 | end 161 | print left, middle, right 162 | end 163 | 164 | def show b 165 | have_both = b[:local_branch] && b[:remote_branch] 166 | 167 | pushc, pullc, oosync = if have_both 168 | [x = commits_between(b[:remote_branch], b[:local_branch]), 169 | y = commits_between(b[:local_branch], b[:remote_branch]), 170 | !x.empty? && !y.empty?] 171 | end 172 | 173 | if b[:local_branch] 174 | puts "Local branch: " + green(b[:local_branch].sub(/^heads\//, "")) 175 | 176 | if have_both 177 | if pushc.empty? 178 | puts "#{widget true} in sync with remote" 179 | else 180 | action = oosync ? "push after rebase / merge" : "push" 181 | puts "#{widget false} NOT in sync with remote (you should #{action})" 182 | show_commits pushc unless $short 183 | end 184 | end 185 | end 186 | 187 | if b[:remote_branch] 188 | puts "Remote branch: #{cyan b[:remote_branch]} (#{b[:remote_url]})" 189 | 190 | if have_both 191 | if pullc.empty? 192 | puts "#{widget true} in sync with local" 193 | else 194 | action = pushc.empty? ? "merge" : "rebase / merge" 195 | puts "#{widget false} NOT in sync with local (you should #{action})" 196 | show_commits pullc unless $short 197 | end 198 | end 199 | end 200 | 201 | puts "\n#{red "WARNING"}: local and remote branches have diverged. A merge will occur unless you rebase." if oosync 202 | end 203 | 204 | def show_relations b, all_branches 205 | ibs, fbs = all_branches.partition { |name, br| $config["integration-branches"].include?(br[:local_branch]) || $config["integration-branches"].include?(br[:remote_branch]) } 206 | if $config["integration-branches"].include? b[:local_branch] 207 | puts "\nFeature branches:" unless fbs.empty? 208 | fbs.each do |name, br| 209 | next if $config["ignore"].member?(br[:local_branch]) || $config["ignore"].member?(br[:remote_branch]) 210 | next if br[:ignore] 211 | local_only = br[:remote_branch].nil? 212 | remote_only = br[:local_branch].nil? 213 | name = if local_only 214 | purple br[:name] 215 | elsif remote_only 216 | cyan br[:name] 217 | else 218 | green br[:name] 219 | end 220 | 221 | ## for remote_only branches, we'll compute wrt the remote branch head. otherwise, we'll 222 | ## use the local branch head. 223 | head = remote_only ? br[:remote_branch] : br[:local_branch] 224 | 225 | remote_ahead = b[:remote_branch] ? commits_between(b[:remote_branch], head) : [] 226 | local_ahead = b[:local_branch] ? commits_between(b[:local_branch], head) : [] 227 | 228 | if local_ahead.empty? && remote_ahead.empty? 229 | puts "#{widget true, remote_only, local_only} #{name} #{local_only ? "(local-only) " : ""}is merged in" 230 | elsif local_ahead.empty? 231 | puts "#{widget true, remote_only, local_only, true} #{name} merged in (only locally)" 232 | else 233 | behind = commits_between head, (br[:local_branch] || br[:remote_branch]) 234 | ahead = remote_only ? remote_ahead : local_ahead 235 | puts "#{widget false, remote_only, local_only} #{name} #{local_only ? "(local-only) " : ""}is NOT merged in (#{ahead_behind_string ahead, behind})" 236 | show_commits ahead unless $short 237 | end 238 | end 239 | else 240 | puts "\nIntegration branches:" unless ibs.empty? # unlikely 241 | ibs.sort_by { |v, br| v }.each do |v, br| 242 | next if $config["ignore"].member?(br[:local_branch]) || $config["ignore"].member?(br[:remote_branch]) 243 | next if br[:ignore] 244 | local_only = br[:remote_branch].nil? 245 | remote_only = br[:local_branch].nil? 246 | name = remote_only ? cyan(br[:name]) : green(br[:name]) 247 | 248 | ahead = commits_between v, (b[:local_branch] || b[:remote_branch]) 249 | if ahead.empty? 250 | puts "#{widget true, local_only} merged into #{name}" 251 | else 252 | #behind = commits_between b[:local_branch], v 253 | puts "#{widget false, local_only} NOT merged into #{name} (#{ahead.size.pluralize 'commit'} ahead)" 254 | show_commits ahead unless $short 255 | end 256 | end 257 | end 258 | end 259 | 260 | #### EXECUTION STARTS HERE #### 261 | 262 | ## find config file and load it 263 | $config = { "integration-branches" => %w(heads/master heads/next heads/edge), "ignore" => [], "max_commits" => 5 }.merge begin 264 | fn = find_file CONFIG_FN 265 | if fn && (h = YAML::load_file(fn)) # yaml turns empty files into false 266 | h["integration-branches"] ||= h["versions"] # support old nomenclature 267 | h 268 | else 269 | {} 270 | end 271 | end 272 | 273 | if $dump_config 274 | puts $config.to_yaml 275 | exit 276 | end 277 | 278 | ## first, index registered remotes 279 | remotes = `git config --get-regexp ^remote\.\*\.url`.split(/[\r\n]+/).inject({}) do |hash, l| 280 | l =~ /^remote\.(.+?)\.url (.+)$/ or next hash 281 | hash[$1] ||= $2 282 | hash 283 | end 284 | 285 | ## next, index followed branches 286 | branches = `git config --get-regexp ^branch\.`.split(/[\r\n]+/).inject({}) do |hash, l| 287 | case l 288 | when /branch\.(.*?)\.remote (.+)/ 289 | name, remote = $1, $2 290 | 291 | hash[name] ||= {} 292 | hash[name].merge! :remote => remote, :remote_url => remotes[remote] 293 | when /branch\.(.*?)\.merge ((refs\/)?heads\/)?(.+)/ 294 | name, remote_branch = $1, $4 295 | hash[name] ||= {} 296 | hash[name].merge! :remote_mergepoint => remote_branch 297 | end 298 | hash 299 | end 300 | 301 | ## finally, index all branches 302 | remote_branches = {} 303 | `git show-ref`.split(/[\r\n]+/).each do |l| 304 | sha1, ref = l.chomp.split " refs/" 305 | 306 | if ref =~ /^heads\/(.+)$/ # local branch 307 | name = $1 308 | next if name == "HEAD" 309 | branches[name] ||= {} 310 | branches[name].merge! :name => name, :local_branch => ref 311 | elsif ref =~ /^remotes\/(.+?)\/(.+)$/ # remote branch 312 | remote, name = $1, $2 313 | remote_branches["#{remote}/#{name}"] = true 314 | next if name == "HEAD" 315 | ignore = !($all || remote == "origin") 316 | 317 | branch = name 318 | if branches[name] && branches[name][:remote] == remote 319 | # nothing 320 | else 321 | name = "#{remote}/#{branch}" 322 | end 323 | 324 | branches[name] ||= {} 325 | branches[name].merge! :name => name, :remote => remote, :remote_branch => "#{remote}/#{branch}", :remote_url => remotes[remote], :ignore => ignore 326 | end 327 | end 328 | 329 | ## assemble remotes 330 | branches.each do |k, b| 331 | next unless b[:remote] && b[:remote_mergepoint] 332 | b[:remote_branch] = if b[:remote] == "." 333 | b[:remote_mergepoint] 334 | else 335 | t = "#{b[:remote]}/#{b[:remote_mergepoint]}" 336 | remote_branches[t] && t # only if it's still alive 337 | end 338 | end 339 | 340 | show_dirty = ARGV.empty? 341 | targets = if ARGV.empty? 342 | [`git symbolic-ref HEAD`.chomp.sub(/^refs\/heads\//, "")] 343 | else 344 | ARGV.map { |x| x.sub(/^heads\//, "") } 345 | end.map { |t| branches[t] or abort "Error: can't find branch #{t.inspect}." } 346 | 347 | targets.each do |t| 348 | show t 349 | show_relations t, branches if $show_relations || t[:remote_branch].nil? 350 | end 351 | 352 | modified = show_dirty && `git ls-files -m` != "" 353 | uncommitted = show_dirty && `git diff-index --cached HEAD` != "" 354 | 355 | if $key 356 | puts 357 | puts KEY 358 | end 359 | 360 | puts if modified || uncommitted 361 | puts "#{red "NOTE"}: working directory contains modified files." if modified 362 | puts "#{red "NOTE"}: staging area contains staged but uncommitted files." if uncommitted 363 | 364 | # the end! 365 | -------------------------------------------------------------------------------- /git.nr: -------------------------------------------------------------------------------- 1 | #Ensure we have the quantity specified on the CLI 2 | if [ -z "$1" ]; then ARG_ERR=ERR; fi 3 | if [ -n "$ARG_ERR" ]; 4 | then 5 | echo "Usage: git.nr " 6 | exit 7 | fi 8 | 9 | # Create a new git repo with one README commit and CD into it 10 | mkdir $1 11 | cd $1 12 | git init 13 | touch README 14 | git add README 15 | git commit -m"First commit" 16 | -------------------------------------------------------------------------------- /github-gem-install: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #prereq 4 | sudo gem install json_pure 5 | 6 | sudo gem install defunkt-github -s http://gems.github.com -------------------------------------------------------------------------------- /gitnewrepo: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | git init $1 3 | cd $1 4 | touch README 5 | git add README 6 | git commit -m'First commit of empty README' -------------------------------------------------------------------------------- /hg-cdpullandupdate: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo =================== START ==================== 3 | pushd $1 4 | echo Mercurial pulling $1 5 | hg pull && hg update 6 | popd 7 | echo ==================== END ===================== -------------------------------------------------------------------------------- /history.cuttail: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -z "$1" ]; then ARG_ERR=ERR; fi 4 | if [ -n "$ARG_ERR" ]; 5 | then 6 | echo "Usage: " 7 | return 1 8 | fi 9 | 10 | tail -$1 ~/.zsh_history | cut -c 16- | pbcopy& 11 | 12 | echo The $1 most recent lines of history have been put onto the pasteboard 13 | 14 | -------------------------------------------------------------------------------- /historytailbash: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #Ensure we have the quantity specified on the CLI 4 | if [ -z "$2" ]; then ARG_ERR=ERR; fi 5 | if [ -z "$1" ]; then ARG_ERR=ERR; fi 6 | if [ -n "$ARG_ERR" ]; 7 | then 8 | echo "Usage: " 9 | exit 10 | fi 11 | 12 | sleeptimesecs=$1 13 | numberoflines=$2 14 | 15 | # Tail history 16 | while [ 1 ]; do 17 | clear 18 | tail -$numberoflines ~/.bash_history 19 | sleep $sleeptimesecs 20 | done 21 | -------------------------------------------------------------------------------- /historytailzsh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #Ensure we have the quantity specified on the CLI 4 | if [ -z "$2" ]; then ARG_ERR=ERR; fi 5 | if [ -z "$1" ]; then ARG_ERR=ERR; fi 6 | if [ -n "$ARG_ERR" ]; 7 | then 8 | echo "Usage: " 9 | exit 10 | fi 11 | 12 | sleeptimesecs=$1 13 | numberoflines=$2 14 | 15 | # Tail history 16 | while [ 1 ]; do 17 | clear 18 | tail -$numberoflines ~/.zsh_history | sed s/^.*\;// 19 | sleep $sleeptimesecs 20 | done 21 | -------------------------------------------------------------------------------- /hub.zsh_completion: -------------------------------------------------------------------------------- 1 | #compdef hub 2 | 3 | # Zsh will source this file when attempting to autoload the "_hub" function, 4 | # typically on the first attempt to complete the hub command. We define two new 5 | # setup helper routines (one for the zsh-distributed version, one for the 6 | # git-distributed, bash-based version). Then we redefine the "_hub" function to 7 | # call "_git" after some other interception. 8 | # 9 | # This is pretty fragile, if you think about it. Any number of implementation 10 | # changes in the "_git" scripts could cause problems down the road. It would be 11 | # better if the stock git completions were just a bit more permissive about how 12 | # it allowed third-party commands to be added. 13 | 14 | (( $+functions[__hub_setup_zsh_fns] )) || 15 | __hub_setup_zsh_fns () { 16 | (( $+functions[_git-alias] )) || 17 | _git-alias () { 18 | _arguments \ 19 | '-s[output shell script suitable for eval]' \ 20 | '1::shell:(zsh bash csh)' 21 | } 22 | 23 | (( $+functions[_git-browse] )) || 24 | _git-browse () { 25 | _arguments \ 26 | '-u[output the URL]' \ 27 | '2::subpage:(wiki commits issues)' 28 | } 29 | 30 | (( $+functions[_git-compare] )) || 31 | _git-compare () { 32 | _arguments \ 33 | '-u[output the URL]' \ 34 | ':[start...]end range:' 35 | } 36 | 37 | (( $+functions[_git-create] )) || 38 | _git-create () { 39 | _arguments \ 40 | '::name (REPOSITORY or ORGANIZATION/REPOSITORY):' \ 41 | '-p[make repository private]' \ 42 | '-d[description]:description' \ 43 | '-h[home page]:repository home page URL:_urls' 44 | } 45 | 46 | (( $+functions[_git-fork] )) || 47 | _git-fork () { 48 | _arguments \ 49 | '--no-remote[do not add a remote for the new fork]' 50 | } 51 | 52 | (( $+functions[_git-pull-request] )) || 53 | _git-pull-request () { 54 | _arguments \ 55 | '-f[force (skip check for local commits)]' \ 56 | '-b[base]:base ("branch", "owner\:branch", "owner/repo\:branch"):' \ 57 | '-h[head]:head ("branch", "owner\:branch", "owner/repo\:branch"):' \ 58 | - set1 \ 59 | '-m[message]' \ 60 | '-F[file]' \ 61 | - set2 \ 62 | '-i[issue]:issue number:' \ 63 | - set3 \ 64 | '::issue-url:_urls' 65 | } 66 | 67 | # stash the "real" command for later 68 | functions[_hub_orig_git_commands]=$functions[_git_commands] 69 | 70 | # Replace it with our own wrapper. 71 | declare -f _git_commands >& /dev/null && unfunction _git_commands 72 | _git_commands () { 73 | local ret=1 74 | # call the original routine 75 | _call_function ret _hub_orig_git_commands 76 | 77 | # Effectively "append" our hub commands to the behavior of the original 78 | # _git_commands function. Using this wrapper function approach ensures 79 | # that we only offer the user the hub subcommands when the user is 80 | # actually trying to complete subcommands. 81 | hub_commands=( 82 | alias:'show shell instructions for wrapping git' 83 | pull-request:'open a pull request on GitHub' 84 | fork:'fork origin repo on GitHub' 85 | create:'create new repo on GitHub for the current project' 86 | browse:'browse the project on GitHub' 87 | compare:'open GitHub compare view' 88 | ci-status:'lookup commit in GitHub Status API' 89 | ) 90 | _describe -t hub-commands 'hub command' hub_commands && ret=0 91 | 92 | return ret 93 | } 94 | } 95 | 96 | (( $+functions[__hub_setup_bash_fns] )) || 97 | __hub_setup_bash_fns () { 98 | # TODO more bash-style fns needed here to complete subcommand args. They take 99 | # the form "_git_CMD" where "CMD" is something like "pull-request". 100 | 101 | # Duplicate and rename the 'list_all_commands' function 102 | eval "$(declare -f __git_list_all_commands | \ 103 | sed 's/__git_list_all_commands/__git_list_all_commands_without_hub/')" 104 | 105 | # Wrap the 'list_all_commands' function with extra hub commands 106 | __git_list_all_commands() { 107 | cat <<-EOF 108 | alias 109 | pull-request 110 | fork 111 | create 112 | browse 113 | compare 114 | ci-status 115 | EOF 116 | __git_list_all_commands_without_hub 117 | } 118 | 119 | # Ensure cached commands are cleared 120 | __git_all_commands="" 121 | } 122 | 123 | # redefine _hub to a much smaller function in the steady state 124 | _hub () { 125 | # only attempt to intercept the normal "_git" helper functions once 126 | (( $+__hub_func_replacement_done )) || 127 | () { 128 | # At this stage in the shell's execution the "_git" function has not yet 129 | # been autoloaded, so the "_git_commands" or "__git_list_all_commands" 130 | # functions will not be defined. Call it now (with a bogus no-op service 131 | # to prevent premature completion) so that we can wrap them. 132 | if declare -f _git >& /dev/null ; then 133 | _hub_noop () { __hub_zsh_provided=1 } # zsh-provided will call this one 134 | __hub_noop_main () { __hub_git_provided=1 } # git-provided will call this one 135 | local service=hub_noop 136 | _git 137 | unfunction _hub_noop 138 | unfunction __hub_noop_main 139 | service=git 140 | fi 141 | 142 | if (( $__hub_zsh_provided )) ; then 143 | __hub_setup_zsh_fns 144 | elif (( $__hub_git_provided )) ; then 145 | __hub_setup_bash_fns 146 | fi 147 | 148 | __hub_func_replacement_done=1 149 | } 150 | 151 | # Now perform the actual completion, allowing the "_git" function to call our 152 | # replacement "_git_commands" function as needed. Both versions expect 153 | # service=git or they will call nonexistent routines or end up in an infinite 154 | # loop. 155 | service=git 156 | declare -f _git >& /dev/null && _git 157 | } 158 | 159 | # make sure we actually attempt to complete on the first "tab" from the user 160 | _hub 161 | -------------------------------------------------------------------------------- /imageconvert: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | sudo sips -s format png $1 --out $2 4 | 5 | #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. 6 | 7 | #NOTE***: 8 | #sips supports output to the following formats: jpeg, tiff, png, gif, jp2, pict, bmp, qtif, psd, sgi, and tga. -------------------------------------------------------------------------------- /iphoto-reverttooriginals: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | mkdir ~/.Trash/iPhoto-Originals 3 | cd ~/"Pictures/iPhoto Library/Modified/" 4 | find . -type f -exec mv "../Originals/{}" ~/.Trash/iPhoto-Originals/ \; -------------------------------------------------------------------------------- /isappinstalled: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #Ensure we have one argument specified on the CLI 4 | if [ -z "$1" ]; then ARG_ERR=ERR; fi 5 | if [ -n "$ARG_ERR" ]; 6 | then 7 | echo "Checks if an app (passed as a parameter) is installed/reachable" 8 | echo " on this machine by using the 'hash' command." 9 | echo "Usage: isappinstalled " 10 | echo "Returns: 0 if is installed, 1 if not installed." 11 | exit 12 | fi 13 | 14 | 15 | hash $1 2>&- || { echo >&2 "I require $1 but it's not installed."; exit 1; } 16 | -------------------------------------------------------------------------------- /iterm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Open a new iTerm session with the command given 5 | # as argument. 6 | # 7 | # - If there are no arguments, the new iTerm window will 8 | # be opened in the current directory, i.e. as if the command 9 | # would be "cd `pwd`". 10 | # - If the first argument is a directory, the new iTerm will 11 | # "cd" into that directory before executing the remaining 12 | # arguments as command. 13 | # - If there are arguments and the first one is not a directory, 14 | # the new window will be opened in the current directory and 15 | # then the arguments will be executed as command. 16 | # - The optional, leading "-x" flag will cause the new terminal 17 | # to be closed immediately after the executed command finishes. 18 | # 19 | # original script by Marc Liyanage 20 | # designed to work with Mac OSX Terminal.app 21 | # iTerm modifications by Damon Parker 22 | # 23 | # 24 | # Version 1.2 25 | # 9/20/2005 damonp - make sure new session opens in current window, clear screen 26 | # 9/15/2005 damonp - modify for iTerm usage 27 | 28 | if [ -z $3 ]; then 29 | echo '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' 30 | echo 'Launch the iTerm application in a certain folder' 31 | echo 'USAGE:' 32 | echo 'iterm ' 33 | echo 'iterm ~/Documents/Temp TEMP gray' 34 | echo 'iterm ~/Documents/Temp TEMP white' 35 | echo 'iterm ~/Documents/Temp TEMP blue' 36 | echo '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' 37 | exit 38 | fi 39 | 40 | if [ "x-x" = x"$1" ]; then 41 | EXIT="; exit"; shift; 42 | fi 43 | 44 | if [[ -d "$1" ]]; then 45 | WD=`cd "$1"; pwd`; shift; 46 | else 47 | WD="'`pwd`'"; 48 | fi 49 | 50 | COMMAND="cd $WD" 51 | TITLE="$1" 52 | COLOR="$2" 53 | 54 | echo "Launching iTerm with COMMAND: $COMMAND TITLE: $TITLE COLOR: $COLOR $EXIT" 55 | 56 | osascript 2>/dev/null < \(.*\)$'` 55 | if expr "$link" : '/.*' > /dev/null; then 56 | SCRIPT="$link" 57 | else 58 | SCRIPT="$(dirname "$SCRIPT"$)/$link" 59 | fi 60 | done 61 | 62 | BIN_DIR="$(dirname "$SCRIPT")" 63 | 64 | if [ -r "$BIN_DIR/../src/leiningen/core.clj" ]; then 65 | # Running from source checkout 66 | LEIN_DIR="$(dirname "$BIN_DIR")" 67 | LEIN_LIBS="$(find -H $LEIN_DIR/lib -mindepth 2> /dev/null 1 -maxdepth 1 -print0 | tr \\0 \:)" 68 | CLASSPATH="$LEIN_LIBS:$CLASSPATH:$LEIN_DIR/src:$LEIN_DIR/resources:$LEIN_JAR" 69 | 70 | if [ "$LEIN_LIBS" = "" -a "$1" != "self-install" -a ! -r "$LEIN_JAR" ]; then 71 | echo "Leiningen is missing its dependencies. Please see \"Building\" in the README." 72 | exit 1 73 | fi 74 | else 75 | # Not running from a checkout 76 | CLASSPATH="$LEIN_JAR:$CLASSPATH" 77 | 78 | if [ ! -r "$LEIN_JAR" -a "$1" != "self-install" ]; then 79 | "$0" self-install 80 | fi 81 | fi 82 | 83 | HTTP_CLIENT="wget --no-check-certificate -O" 84 | if type -p curl >/dev/null 2>&1; then 85 | HTTP_CLIENT="curl --insecure -f -L -o" 86 | fi 87 | 88 | JAVA_CMD=${JAVA_CMD:-"java"} 89 | 90 | # Support $JAVA_OPTS for backwards-compatibility. 91 | JVM_OPTS=${JVM_OPTS:-$JAVA_OPTS} 92 | 93 | # If you're packaging this for a package manager (.deb, homebrew, etc) 94 | # you need to remove the self-install and upgrade functionality. 95 | if [ "$1" = "self-install" ]; then 96 | echo "Downloading Leiningen now..." 97 | LEIN_DIR=`dirname "$LEIN_JAR"` 98 | mkdir -p "$LEIN_DIR" 99 | LEIN_URL="https://github.com/downloads/technomancy/leiningen/leiningen-$LEIN_VERSION-standalone.jar" 100 | $HTTP_CLIENT "$LEIN_JAR" "$LEIN_URL" 101 | if [ $? != 0 ]; then 102 | echo "Failed to download $LEIN_URL" 103 | if [ $SNAPSHOT = "YES" ]; then 104 | echo "See README.md for SNAPSHOT build instructions." 105 | fi 106 | rm $LEIN_JAR 2> /dev/null 107 | exit 1 108 | fi 109 | elif [ "$1" = "upgrade" ]; then 110 | if [ $SNAPSHOT = "YES" ]; then 111 | echo "The upgrade task is only meant for stable releases." 112 | echo "See the \"Hacking\" section of the README." 113 | exit 1 114 | fi 115 | if [ ! -w "$SCRIPT" ]; then 116 | echo "You do not have permission to upgrade the installation in $SCRIPT" 117 | exit 1 118 | else 119 | echo "The script at $SCRIPT will be upgraded to the latest stable version." 120 | echo -n "Do you want to continue [Y/n]? " 121 | read RESP 122 | case "$RESP" in 123 | y|Y|"") 124 | echo 125 | echo "Upgrading..." 126 | LEIN_SCRIPT_URL="https://github.com/technomancy/leiningen/raw/stable/bin/lein" 127 | $HTTP_CLIENT "$SCRIPT" "$LEIN_SCRIPT_URL" \ 128 | && chmod +x "$SCRIPT" \ 129 | && echo && $SCRIPT self-install && echo && echo "Now running" `$SCRIPT version` 130 | exit $?;; 131 | *) 132 | echo "Aborted." 133 | exit 1;; 134 | esac 135 | fi 136 | else 137 | if [ "$OSTYPE" = "cygwin" ]; then 138 | # When running on Cygwin, use Windows-style paths for java 139 | CLOJURE_JAR=`cygpath -w "$CLOJURE_JAR"` 140 | ORIGINAL_PWD=`cygpath -w "$ORIGINAL_PWD"` 141 | CLASSPATH=`cygpath -wp "$CLASSPATH"` 142 | NULL_DEVICE=NUL 143 | fi 144 | 145 | if [ $DEBUG ]; then 146 | echo $CLASSPATH 147 | echo $CLOJURE_JAR 148 | fi 149 | 150 | JLINE="" 151 | if ([ "$1" = "repl" ] || [ "$1" = "interactive" ] || [ "$1" = "int" ]) && 152 | [ -z $INSIDE_EMACS ] && [ "$TERM" != "dumb" ]; then 153 | # Use rlwrap if it's available, otherwise fall back to JLine 154 | RLWRAP=`which rlwrap` 155 | if [ ! -x "$RLWRAP" ] || [ "$RLWRAP" = "" ]; then 156 | RLWRAP="" 157 | JLINE=jline.ConsoleRunner 158 | if [ "$OSTYPE" = "cygwin" ]; then 159 | JLINE="-Djline.terminal=jline.UnixTerminal jline.ConsoleRunner" 160 | CYGWIN_JLINE=y 161 | fi 162 | fi 163 | fi 164 | 165 | # The -Xbootclasspath argument is optional here: if the jar 166 | # doesn't exist everything will still work, it will just have a 167 | # slower JVM boot. 168 | # TODO: add more to the boot classpath 169 | test $CYGWIN_JLINE && stty -icanon min 1 -echo 170 | exec $RLWRAP $JAVA_CMD -Xbootclasspath/a:"$CLOJURE_JAR" -client $JVM_OPTS \ 171 | -Dleiningen.original.pwd="$ORIGINAL_PWD" \ 172 | -cp "$CLASSPATH" $JLINE clojure.main -e "(use 'leiningen.core)(-main)" \ 173 | $NULL_DEVICE $@ 174 | test $CYGWIN_JLINE && stty icanon echo 175 | fi 176 | -------------------------------------------------------------------------------- /loopthis: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #Ensure we have the quantity specified on the CLI 4 | if [ -z "$2" ]; then ARG_ERR=ERR; fi 5 | if [ -z "$1" ]; then ARG_ERR=ERR; fi 6 | if [ -n "$ARG_ERR" ]; 7 | then 8 | echo "Usage: " 9 | exit 10 | fi 11 | 12 | sleeptimesecs=$1 13 | commandtorun=$2 14 | 15 | while [ 1 ]; do 16 | clear 17 | $commandtorun 18 | sleep $sleeptimesecs 19 | done 20 | -------------------------------------------------------------------------------- /macosx-rescan-services-menu: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | /System/Library/CoreServices/pbs -------------------------------------------------------------------------------- /macports-cleanup: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Remove the caches 4 | sudo port clean --all installed 5 | 6 | # Remove any inactive packages 7 | sudo port -f uninstall inactive 8 | -------------------------------------------------------------------------------- /macports-update: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Update Macports 4 | sudo port selfupdate 5 | 6 | # Update outdated packages 7 | sudo port upgrade outdated 8 | -------------------------------------------------------------------------------- /macprefs: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Turn on the debug (details about hidden disks) menus in Disk Utility 4 | defaults write com.apple.DiskUtility DUDebugMenuEnabled 1 5 | -------------------------------------------------------------------------------- /markdown-andopen: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | INPUTFILE="$1" 4 | OUTPUTFILE="$1".html 5 | 6 | echo Writing markdown file to \"$OUTPUTFILE\" 7 | 8 | markdown.pl "$INPUTFILE" > "$OUTPUTFILE" 9 | open "$OUTPUTFILE" -------------------------------------------------------------------------------- /markdown-here: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #Ensure we have the quantity specified on the CLI 4 | if [ -z "$1" ]; then ARG_ERR=ERR; fi 5 | if [ -n "$ARG_ERR" ]; 6 | then 7 | echo "Usage: " 8 | exit 9 | fi 10 | 11 | INPUTFILE="$1" 12 | OUTPUTFILE=`echo "$INPUTFILE" | sed "s/\.md/\.html/" | sed "s/\.markdown/\.html/"` 13 | 14 | echo Writing \"$INPUTFILE\" file to \"$OUTPUTFILE\" 15 | multimarkdown -o "$OUTPUTFILE" "$INPUTFILE" 16 | -------------------------------------------------------------------------------- /markdown.pl: -------------------------------------------------------------------------------- 1 | #!/opt/local/bin/perl 2 | #You should sudo port install p5-text-markdown to get the modules necessary to run this script 3 | #Argument 1 is the MDML input file. 4 | #It outputs the markdown-converted-to-html to the console. Redirect to a file as desired. 5 | use Text::Markdown 'markdown'; 6 | open( TEXTFILE, "<$ARGV[ 0 ]" ); 7 | print markdown( join( '', ) ); 8 | close( TEXTFILE ); -------------------------------------------------------------------------------- /mdlstaglist: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | while read N; do echo "$N"; mdls "$N" | grep "kOMUser" -H -A 1; done < <(find . -iname '*' -d 1) 3 | -------------------------------------------------------------------------------- /mvim: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This shell script passes all its arguments to the binary inside the 4 | # MacVim.app application bundle. If you make links to this script as view, 5 | # gvim, etc., then it will peek at the name used to call it and set options 6 | # appropriately. 7 | # 8 | # Based on a script by Wout Mertens and suggestions from Laurent Bihanic. This 9 | # version is the fault of Benji Fisher, 16 May 2005 (with modifications by Nico 10 | # Weber and Bjorn Winckler, Aug 13 2007). 11 | # First, check "All the Usual Suspects" for the location of the Vim.app bundle. 12 | # You can short-circuit this by setting the VIM_APP_DIR environment variable 13 | # or by un-commenting and editing the following line: 14 | # VIM_APP_DIR=/Applications 15 | 16 | if [ -z "$VIM_APP_DIR" ] 17 | then 18 | myDir="`dirname "$0"`" 19 | myAppDir="$myDir/../Applications" 20 | for i in ~/Applications ~/Applications/vim $myDir $myDir/vim $myAppDir $myAppDir/vim /Applications /Applications/vim /Applications/Utilities /Applications/Utilities/vim; do 21 | if [ -x "$i/MacVim.app" ]; then 22 | VIM_APP_DIR="$i" 23 | break 24 | fi 25 | done 26 | fi 27 | if [ -z "$VIM_APP_DIR" ] 28 | then 29 | echo "Sorry, cannot find MacVim.app. Try setting the VIM_APP_DIR environment variable to the directory containing MacVim.app." 30 | exit 1 31 | fi 32 | binary="$VIM_APP_DIR/MacVim.app/Contents/MacOS/Vim" 33 | 34 | # Next, peek at the name used to invoke this script, and set options 35 | # accordingly. 36 | 37 | name="`basename "$0"`" 38 | gui= 39 | opts= 40 | 41 | # GUI mode, implies forking 42 | case "$name" in m*|g*|rm*|rg*) gui=true ;; esac 43 | 44 | # Restricted mode 45 | case "$name" in r*) opts="$opts -Z";; esac 46 | 47 | # vimdiff, view, and ex mode 48 | case "$name" in 49 | *vimdiff) 50 | opts="$opts -dO" 51 | ;; 52 | *view) 53 | opts="$opts -R" 54 | ;; 55 | *ex) 56 | opts="$opts -e" 57 | ;; 58 | esac 59 | 60 | # Last step: fire up vim. 61 | # The program should fork by default when started in GUI mode, but it does 62 | # not; we work around this when this script is invoked as "gvim" or "rgview" 63 | # etc., but not when it is invoked as "vim -g". 64 | if [ "$gui" ]; then 65 | # Note: this isn't perfect, because any error output goes to the 66 | # terminal instead of the console log. 67 | # But if you use open instead, you will need to fully qualify the 68 | # path names for any filenames you specify, which is hard. 69 | exec "$binary" -g $opts ${1:+"$@"} 70 | else 71 | exec "$binary" $opts ${1:+"$@"} 72 | fi 73 | -------------------------------------------------------------------------------- /mysql-start: -------------------------------------------------------------------------------- 1 | mysql.server start -------------------------------------------------------------------------------- /mysql-stop: -------------------------------------------------------------------------------- 1 | mysql.server stop -------------------------------------------------------------------------------- /openmeta: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthewmccullough/scripts/40b246165445f44d253c8100969fffdcdbe3f9a0/openmeta -------------------------------------------------------------------------------- /openmetaallfileshere: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | while read N; do openmeta -a $1 -p "$N"; done < <(find . -iname '*.*' -d 1 -type f) 3 | -------------------------------------------------------------------------------- /openmetaallfoldershere: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | while read N; do openmeta -a $1 -p "$N"; done < <(find . -iname '*' -d 1 -type d) 3 | -------------------------------------------------------------------------------- /openmetalisttags: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | while read N; do openmeta -p "$N"; done < <(find . -iname '*' -d 1) 3 | -------------------------------------------------------------------------------- /orgtomarkdown: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Convert OrgMode to Markdown 4 | export MARKDOWNNAME="`echo "$1" | sed 's/$/.markdown/'`" 5 | export HTMLNAME="`echo "$1" | sed 's/$/.html/'`" 6 | 7 | # Syntax of OrgMode 8 | # * for first level bullet -> H1 9 | # ** for second level bullet -> first level markdown bullet 10 | # == for codeblock becomes ` 11 | 12 | 13 | #| tr -d '^ :[:alpha:]:$' \ 14 | #| tr -d '^ :[:alpha:]:[:blank:][:alnum:]$' \ 15 | 16 | # Convert OrgMode to Markdown 17 | cat "$1" \ 18 | | sed "s/#\+BEGIN_SRC/
/"  \
19 |          | sed "s/#\+END_SRC/<\/code><\/pre>/"  \
20 |          | sed "s/   :PROPERTIES://"  \
21 |          | sed "s/   :Effort:.*//"  \
22 |          | sed "s/   :END://"  \
23 |          | sed "s/ =/ \`/"  \
24 |          | sed "s/= /\` /"  \
25 |          | sed "s/=\./\`./"  \
26 |          | sed "s/^=/\`/"  \
27 |          | sed "s/=$/\`/"  \
28 |          | sed "s/^\* /# /"  \
29 |          | sed "s/^\*\* /## /"  \
30 |          | sed "s/^\*\*\* /### /" \
31 |          | sed "s/^\*\*\*\* /\#### /" \
32 |          | sed "s/^\*\*\*\*\* /\* /" > "$MARKDOWNNAME"
33 | 
34 | # Convert from Markdown to HTML
35 | cat "$MARKDOWNNAME" | multimarkdown > "$HTMLNAME"
36 | 


--------------------------------------------------------------------------------
/orgtomarkdowndots:
--------------------------------------------------------------------------------
 1 | #!/bin/sh
 2 | 
 3 | # Convert OrgMode to Markdown
 4 | export MARKDOWNNAME="`echo "$1" | sed 's/$/.markdown/'`"
 5 | export HTMLNAME="`echo "$1" | sed 's/$/.html/'`"
 6 | 
 7 | # Syntax of OrgMode
 8 | # * for first level bullet -> H1
 9 | # ** for second level bullet -> first level markdown bullet
10 | # == for codeblock becomes `
11 | 
12 | 
13 | #| tr -d '^   :[:alpha:]:$'  \
14 | #| tr -d '^   :[:alpha:]:[:blank:][:alnum:]$'  \
15 | 
16 | # Convert OrgMode to Markdown
17 | cat "$1" \
18 |          | sed "s/#\+BEGIN_SRC/
/"  \
19 |          | sed "s/#\+END_SRC/<\/code><\/pre>/"  \
20 |          | sed "s/   :PROPERTIES://"  \
21 |          | sed "s/   :Effort:.*//"  \
22 |          | sed "s/   :END://"  \
23 |          | sed "s/ =/ \`/"  \
24 |          | sed "s/= /\` /"  \
25 |          | sed "s/=\./\`./"  \
26 |          | sed "s/^=/\`/"  \
27 |          | sed "s/=$/\`/"  \
28 |          | sed "s/^\* /# /"  \
29 |          | sed "s/^\*\* /## /"  \
30 |          | sed "s/^\*\*\* /\* /" \
31 |          | sed "s/^\*\*\*\* /\    \* /" \
32 |          | sed "s/^\*\*\*\*\* /\        * /" > "$MARKDOWNNAME"
33 | 
34 | # Convert from Markdown to HTML
35 | cat "$MARKDOWNNAME" | multimarkdown > "$HTMLNAME"
36 | 


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


--------------------------------------------------------------------------------
/p4merge:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | /Applications/p4merge.app/Contents/MacOS/p4merge $*
3 | 


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


--------------------------------------------------------------------------------
/postgresql-start:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | 
3 | pushd /Library/PostgreSQL/8.4/bin/
4 | sudo -u postgres /Library/PostgreSQL/8.4/bin/pg_ctl start -D /Library/PostgreSQL/8.4/data/
5 | popd


--------------------------------------------------------------------------------
/postgresql-stop:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | 
3 | sudo -u postgres pg_ctl stop -D /Library/PostgreSQL/8.4/data/


--------------------------------------------------------------------------------
/prepmigrate-brew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | brew list
3 | 


--------------------------------------------------------------------------------
/prepmigrate-gems:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | gem query --local
3 | 


--------------------------------------------------------------------------------
/prepmigrate-port:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | port list installed
3 | 


--------------------------------------------------------------------------------
/ql:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | 
3 | qlmanage -p "$@" >& /dev/null &
4 | 


--------------------------------------------------------------------------------
/ramdisk:
--------------------------------------------------------------------------------
 1 | #!/bin/bash
 2 | 
 3 | if [ -n "$3" ]; then ARG_ERR=ERR; fi
 4 | if [ -z "$1" ]; then ARG_ERR=ERR; fi
 5 | if [ -n "$ARG_ERR" ];
 6 | then
 7 |     echo "usage: ramdisk  [device name]"
 8 |     exit
 9 | fi
10 | MB_SIZE=$1
11 | let "MB_SIZE *= 2048"
12 | echo Creating ${MB_SIZE} 512-blocks ramdisk
13 | CREATED_RAMDISK=`hdid -nomount ram://${MB_SIZE}`
14 | echo New block device: ${CREATED_RAMDISK}
15 | if [ -n "$2" ];
16 | then
17 |     DISK_NAME=$2
18 | else
19 |     DISK_NAME=`basename ${CREATED_RAMDISK}`
20 | fi
21 | echo Creating volume with label: ${DISK_NAME}
22 | newfs_hfs -v ${DISK_NAME} /dev/r$CREATED_RAMDISK
23 | echo Mounting in /Volumes/${DISK_NAME}
24 | diskutil mount ${CREATED_RAMDISK}


--------------------------------------------------------------------------------
/removedropboxconflicts:
--------------------------------------------------------------------------------
 1 | #!/bin/sh
 2 | 
 3 | find . -iname '*conflicted copy*' -print
 4 | 
 5 | echo "\n"
 6 | read -p "Press [Enter] to move these files to the trash or Ctrl C to abort..."
 7 | 
 8 | echo "\n\nStarting removal:"
 9 | find . -iname '*conflicted copy*' -print -exec rm "{}" \;
10 | 


--------------------------------------------------------------------------------
/replace-word-in-filename:
--------------------------------------------------------------------------------
 1 | #!/bin/bash
 2 | 
 3 | if [ -n "$4" ]; then ARG_ERR=ERR; fi
 4 | if [ -z "$3" ]; then ARG_ERR=ERR; fi
 5 | if [ -z "$2" ]; then ARG_ERR=ERR; fi
 6 | if [ -z "$1" ]; then ARG_ERR=ERR; fi
 7 | if [ -n "$ARG_ERR" ];
 8 | then
 9 |     echo "Usage:   "
10 |     exit
11 | fi
12 | for i in $1; do j=`echo $i | sed 's/$2/$3/g'`; mv "$i" "$j"; done


--------------------------------------------------------------------------------
/resty:
--------------------------------------------------------------------------------
  1 | #!/bin/bash
  2 | 
  3 | #
  4 | # resty - A tiny command line REST interface for bash.
  5 | #
  6 | # Fork me on github:
  7 | #   http://github.com/micha/resty
  8 | #
  9 | # Author:
 10 | #   Micha Niskin 
 11 | #   Copyright 2009, no rights reserved.
 12 | #
 13 | 
 14 | export _resty_host=""
 15 | export _resty_path=""
 16 | 
 17 | function resty() {
 18 |   local confdir="${HOME}/.resty"
 19 |   local host="${confdir}/host"
 20 |   local cookies="$confdir/c"
 21 |   local method="$1";          [[ $# > 0 ]] && shift
 22 |   local h2t=$((which lynx >/dev/null && echo lynx -stdin -dump) \
 23 |                 || which html2text || which cat)
 24 |   local editor=$(which "$EDITOR" || which vim || echo "vi")
 25 |   local domain path opt dat res ret out err verbose raw i d tmpf args2
 26 | 
 27 |   [ -d "$cookies" ] || (mkdir -p "$cookies"; echo "http://localhost*" > "$host")
 28 |   [ -n "$1" ] && [ "${1#/}" != "$1" ] \
 29 |     && 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
 30 | 
 31 |   for i in "$@"; do
 32 |     ([ "$i" == "--verbose" ] || echo "$i" | grep -q '^-[a-zA-Z]*v[a-zA-Z]*$') \
 33 |       && verbose="yes"
 34 |   done
 35 | 
 36 |   [ -z "$_resty_host" ] && _resty_host=$(cat "$host" 2>/dev/null)
 37 |   [ -z "$method" ] && echo "$_resty_host" && return
 38 |   [ -n "$path" ] && _resty_path=$path
 39 |   domain=$(echo -n "$_resty_host" \
 40 |     |perl -ane '/^https?:\/\/([^\/\*]+)/; print $1')
 41 |   path="${_resty_host//\*/$_resty_path}"
 42 | 
 43 |   case "$method" in
 44 |     GET|DELETE|POST|PUT)
 45 |       dat=$( ( [ "${method#P}" != "$method" ] \
 46 |         && ( ( [ -n "$1" ] && [ "${1#-}" == "$1" ] && echo "$1") \
 47 |         || echo "@-") ) || echo)
 48 |       if [ "${method#P}" != "$method" ] && [ "$1" == "-V" ]; then
 49 |         tmpf=$(mktemp /tmp/resty.XXXXXX)
 50 |         cat > $tmpf
 51 |         (exec < /dev/tty; "$editor" $tmpf)
 52 |         dat=$(cat $tmpf)
 53 |         rm -f $tmpf
 54 |       fi
 55 |       [ -n "$dat" ] && [ "$dat" != "@-" ] && shift
 56 |       [ "$1" == "-Z" ] && raw="yes" && shift
 57 |       [ -n "$dat" ] && opt="--data-binary"
 58 |       eval "args2=( $(cat "$confdir/$domain" 2>/dev/null |sed 's/^ *//' |grep ^$method |cut -b $((${#method}+2))-) )"
 59 |       res=$((((curl -sLv $opt "$dat" -X $method \
 60 |               -b "$cookies/$domain" -c "$cookies/$domain" \
 61 |               "${args2[@]}" "$@" "$path" \
 62 |         |sed 's/^/OUT /' && echo) 3>&2 2>&1 1>&3) \
 63 |         |sed 's/^/ERR /' && echo) 2>&1)
 64 |       out=$(echo "$res" |sed '/^OUT /s/^....//p; d')
 65 |       err=$(echo "$res" |sed '/^ERR /s/^....//p; d')
 66 |       ret=$(echo "$err" |sed \
 67 |         '/^.*HTTP\/1\.[01] [0-9][0-9][0-9]/s/.*\([0-9]\)[0-9][0-9].*/\1/p; d' \
 68 |         | tail -n1)
 69 |       [ -n "$err" -a -n "$verbose" ] && echo "$err" 1>&2
 70 |       echo "$err" | grep -qi '^< \s*Content-Type:  *text/html' \
 71 |         && [ -z "$raw" ] && d=$h2t || d=cat
 72 |       if [ "$ret" != "2" ]; then
 73 |         [ -n "$out" ] && echo "$out" | $d 1>&2
 74 |         return $ret
 75 |       else
 76 |         [ -n "$out" ] && echo "$out" | $d
 77 |       fi
 78 |       ;;
 79 |     http://*|https://*)
 80 |       echo "$method" |grep -q '\*' || method="${method}*"
 81 |       (echo "$method" |tee "$host") |cat 1>&2 && _resty_host="$method"
 82 |       ;;
 83 |     *)
 84 |       resty "http://$method"
 85 |       ;;
 86 |   esac
 87 | }
 88 | 
 89 | function GET() {
 90 |   resty GET "$@"
 91 | }
 92 | 
 93 | function POST() {
 94 |   resty POST "$@"
 95 | }
 96 | 
 97 | function PUT() {
 98 |   resty PUT "$@"
 99 | }
100 | 
101 | function DELETE() {
102 |   resty DELETE "$@"
103 | }
104 | 


--------------------------------------------------------------------------------
/rilconvert:
--------------------------------------------------------------------------------
 1 | #!/bin/bash
 2 | # (c) Vinzenz Vietzke 
 3 | # 
 4 | # ugly hack for importing readitlater to springpad:
 5 | # convert readitlater export files to delicious import format
 6 | 
 7 | #Ensure we have the quantity specified on the CLI
 8 | if [ -z "$2" ]; then ARG_ERR=ERR; fi
 9 | if [ -z "$1" ]; then ARG_ERR=ERR; fi
10 | if [ -n "$ARG_ERR" ];
11 | then
12 |     echo "usage: rilconvert.sh input-filename.html output-filename.html"
13 |     exit
14 | fi
15 | 
16 | 
17 | echo -e "
18 | 
19 | Bookmarks
20 | 

Bookmarks

21 |

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

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