Skip to content

Instantly share code, notes, and snippets.

@amjith
Created February 21, 2018 03:05
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save amjith/c8179e589f84b16894aae962d2fb0e39 to your computer and use it in GitHub Desktop.
Save amjith/c8179e589f84b16894aae962d2fb0e39 to your computer and use it in GitHub Desktop.
git-open.sh
#!/bin/bash
dirty=`git status --porcelain -uno | sed s/^...//`
last_modified=`git show --pretty="format:" --name-only HEAD`
if [ -n "$dirty" ]; then
echo $dirty
else
echo $last_modified
fi
@atefBB
Copy link

atefBB commented Apr 15, 2018

I'm using ubuntu 16.04 and I'm wondering: where to put this .sh file?

@rscata
Copy link

rscata commented Apr 17, 2018

@atefBB , in ~ (your home directory) .

You still need to give permissions chmod +x to the .sh file, and in .gitconfig add alias like this:

open = !vim `~/git-open.sh`

With this solution, it works for me

Thanks @amjith.

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