Skip to content

Instantly share code, notes, and snippets.

@crcastle
Forked from arnorhs/gist:1517095
Created December 27, 2011 19:04
Show Gist options
  • Select an option

  • Save crcastle/1524814 to your computer and use it in GitHub Desktop.

Select an option

Save crcastle/1524814 to your computer and use it in GitHub Desktop.

Revisions

  1. @tessro tessro revised this gist Dec 23, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@

    # It's set to use macvim as the default editor, you can change that easily by
    # changing this line:
    EDITOR="$HOME/bin/mvim --remote-silent"
    EDITOR=${EDITOR:-"$HOME/bin/mvim --remote-silent"}

    COMMAND=diff
    REV=HEAD
  2. @arnorhs arnorhs revised this gist Dec 22, 2011. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    # This script will open all files from a git diff or a git show in vim.

    # My bash fu sucks, so this could probably be done more intelligently
    # My bash skills are a bit primitive so this can probably be done more intelligently

    # Usage:
    # gitopen -- opens all added files that have changed since HEAD
    @@ -14,7 +14,7 @@

    # It's set to use macvim as the default editor, you can change that easily by
    # changing this line:
    EDITOR="~/bin/mvim --remote-silent"
    EDITOR="$HOME/bin/mvim --remote-silent"

    COMMAND=diff
    REV=HEAD
  3. @arnorhs arnorhs renamed this gist Dec 22, 2011. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. @arnorhs arnorhs created this gist Dec 22, 2011.
    36 changes: 36 additions & 0 deletions gitopen
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    #!/bin/bash

    # This script will open all files from a git diff or a git show in vim.

    # My bash fu sucks, so this could probably be done more intelligently

    # Usage:
    # gitopen -- opens all added files that have changed since HEAD
    # gitopen diff HEAD -- these are the default parameters
    # gitopen diff master -- opens files that have changed from master
    # gitopen show -- opens files that were changed in the last revision (HEAD)
    # gitopen show HEAD -- default param, does the same
    # gitopen show 4b3ca34 -- opens a particular REV

    # It's set to use macvim as the default editor, you can change that easily by
    # changing this line:
    EDITOR="~/bin/mvim --remote-silent"

    COMMAND=diff
    REV=HEAD

    if [ $1 ]; then
    COMMAND=$1
    fi

    if [ $2 ]; then
    REV=$2
    fi

    if [ $COMMAND = "show" ]; then
    PARAM='--pretty=format: --name-only'
    else
    PARAM='--name-only'
    fi

    git $COMMAND $PARAM $REV | xargs $EDITOR