Skip to content

Instantly share code, notes, and snippets.

@ricardobeat
Created September 29, 2014 12:05
Show Gist options
  • Save ricardobeat/01245b5b6eaeb1821c6c to your computer and use it in GitHub Desktop.
Save ricardobeat/01245b5b6eaeb1821c6c to your computer and use it in GitHub Desktop.
git-open - open all modified files
#!/bin/bash
#
# Open all changed files in Sublime Text
#
# Install:
# save this file to /usr/local/bin/git-open
# chmod +x /usr/local/bin/git-open
#
# It will now be available as 'git open'
#
prefix=$(git rev-parse --show-prefix)
subl $(git diff --name-only HEAD | sed "s,$prefix,," | tr '\n' ' ')
@reidcooper
Copy link

was receiving this error: sed: first RE may not be empty

My change:

#!/bin/bash
#
# Open all changed files in Sublime Text
#
# Install:
#    save this file to /usr/local/bin/git-open
#    chmod +x /usr/local/bin/git-open
#
# It will now be available as 'git open'
# https://gist.github.com/ricardobeat/01245b5b6eaeb1821c6c

# If in /bin, show prefix will display /bin
# Otherwise, it will return ''
prefix=$(git rev-parse --show-prefix)

if [[ -z "$prefix" ]]; then
  prefix=" "
fi

subl $(git diff --name-only HEAD | sed "s,$prefix,," | tr '\n' ' ')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment