- Open Git Bash shell. Put this in
~/.bashrc
export PATH=$PATH:$HOME/Downloads/notify-send
gpn() {
if git push --force-with-lease origin "$@" ; then
notify-send.exe "Push Success" "Keep pushin'! ✔"
else
notify-send.exe -i error "Push failure" "Is it lint or test?"
fi
}
-
Download and extract
notify-send
equivalent for Windows. Rename the extracted folder tonotify-send
. -
Create a git alias by typing
git config --global alias.gpn '!source ~/.bashrc && gpn'
in shell.
Open Sublime Merge > Preferences > Browse Packages...
Open or create User/Default.sublime-commands
there and fill it with following content:
[
{
"caption": "Push to origin and notify",
"command": "git",
"args": { "argv": ["gpn", "$select_local_branch"] }
}
]
Close and re-open Sublime Merge.
You are done! Use the command name given in above caption.
Open File > Preferences > Custom Commands > Click on + (Add) > Add branch custom command
- Only keep Local Branch as ticked
- Change name to "Push to origin and notify"
- Choose Action option from UI/Action radio buttons
- Click on Action button
- In Action button choose Start Process
- For Path use "$git" (without quotes)
- For parameters use "gpn $name" (without quotes)
- Tick on Wait for Exit and untick Always Show Output
- Save the fields using Edit button
- Close Preferences
Now if you right click on a local branch a new option that we just created will appear.
- In Windows CLI (Powershell/Command Prompt), navigate to a git repo and use
git gpn branch-name
. - If you prefer Git Bash and don't want Sublime Merge or Fork integration, use
git config --global alias.gpn '!gpn'
instead. - If you just use Powershell and don't want all this fuss then try to find something like this for it.
- Only show notification when Sublime Merge window is not in focus. Clicking on notification brings focus to the app.
- If you have in your PATH a shell file or a script that prefixed with
git-
, you can run it like a git subcommand. Eg. givengit-muse
in PATH, one can rungit muse
in command line. We can use this over git alias.
You can also use BurntToast to display a notification. This is useful if you don't like notifications generated from
notify-send
blocking the push in Fork/Sublime Merge until you click on the notification (or until it moves itself to action center). Here is a rough draft on how BurntToast can be used:Install-Module -Name BurntToast -Scope CurrentUser
.bashrc
, instead of using the PATH defined above, useexport PATH=$PATH:/c/Windows/System32/WindowsPowerShell/v1.0
notify-send.exe ...
lines in.bashrc
withpowershell.exe -Command "& {New-BurntToastNotification -Text 'Yay pushed!'}"