Skip to content

Instantly share code, notes, and snippets.

@kenglxn
Created March 16, 2018 13:28
Show Gist options
  • Save kenglxn/0902128222db04f388c740b828f3645d to your computer and use it in GitHub Desktop.
Save kenglxn/0902128222db04f388c740b828f3645d to your computer and use it in GitHub Desktop.
fish function for showing the number of commits origin/master is ahead, if any
function diff_stat_master
git remote update > /dev/null
set __master_commits (git rev-list HEAD..origin/master --count)
if test $__master_commits -gt 0
echo ""
echo "- There are $__master_commits new commits on origin/master -"
echo ""
end
end
@kenglxn
Copy link
Author

kenglxn commented Mar 16, 2018

Install

Just copy to your fish functions directory:

curl -o ~/.config/fish/functions/diff_stat_master.fish -L https://gist.github.com/kenglxn/0902128222db04f388c740b828f3645d/raw/2ea0ed09bc46811e487a43727f295d211b51af8c/diff_stat_master.fish

Can be used with direnv to get a message when you enter the directory: https://direnv.net/

Example output

~/d/git $ cd some_repository
direnv: loading .envrc

- There are 16 new commits on origin/master -

Setup

Install direnv https://direnv.net/

create a .envrc file in the repo with following content

#!/bin/bash
fish -c diff_stat_master

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