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