Skip to content

Instantly share code, notes, and snippets.

@garunski
Last active August 17, 2017 16:13
Show Gist options
  • Save garunski/27b616ca0ba8c22720c5e98e813cb4cd to your computer and use it in GitHub Desktop.
Save garunski/27b616ca0ba8c22720c5e98e813cb4cd to your computer and use it in GitHub Desktop.
zsh git extension shortcuts for powershell
#powershell aliases for zsh git plugin
#https://github.com/robbyrussell/oh-my-zsh/wiki/Plugin:git
function gitBranchName {
$currentBranch=''
git branch | foreach {
if ($_ -match "^\* (.*)") {
$currentBranch += $matches[1]
}
}
return $currentBranch
}
remove-item alias:gcb
function Zsh-Shortcut-Git-Cmd-g { & git }; New-Alias -Name g -Value Zsh-Shortcut-Git-Cmd-g -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-ga { & git add }; New-Alias -Name ga -Value Zsh-Shortcut-Git-Cmd-ga -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gaa { & git add --all }; New-Alias -Name gaa -Value Zsh-Shortcut-Git-Cmd-gaa -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gapa { & git add --patch }; New-Alias -Name gapa -Value Zsh-Shortcut-Git-Cmd-gapa -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gb { & git branch }; New-Alias -Name gb -Value Zsh-Shortcut-Git-Cmd-gb -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gba { & git branch -a }; New-Alias -Name gba -Value Zsh-Shortcut-Git-Cmd-gba -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gbda { & git branch --merged | command grep -vE "^(*|\smaster\s$)" | command xargs -n 1 git branch -d }; New-Alias -Name gbda -Value Zsh-Shortcut-Git-Cmd-gbda -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gbl { & git blame -b -w }; New-Alias -Name gbl -Value Zsh-Shortcut-Git-Cmd-gbl -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gbnm { & git branch --no-merged }; New-Alias -Name gbnm -Value Zsh-Shortcut-Git-Cmd-gbnm -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gbr { & git branch --remote }; New-Alias -Name gbr -Value Zsh-Shortcut-Git-Cmd-gbr -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gbs { & git bisect }; New-Alias -Name gbs -Value Zsh-Shortcut-Git-Cmd-gbs -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gbsb { & git bisect bad }; New-Alias -Name gbsb -Value Zsh-Shortcut-Git-Cmd-gbsb -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gbsg { & git bisect good }; New-Alias -Name gbsg -Value Zsh-Shortcut-Git-Cmd-gbsg -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gbsr { & git bisect reset }; New-Alias -Name gbsr -Value Zsh-Shortcut-Git-Cmd-gbsr -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gbss { & git bisect start }; New-Alias -Name gbss -Value Zsh-Shortcut-Git-Cmd-gbss -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gc { & git commit -v }; New-Alias -Name gc -Value Zsh-Shortcut-Git-Cmd-gc -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gc! { & git commit -v --amend }; New-Alias -Name gc! -Value Zsh-Shortcut-Git-Cmd-gc! -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gca { & git commit -v -a }; New-Alias -Name gca -Value Zsh-Shortcut-Git-Cmd-gca -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gcam { & git commit -a -m }; New-Alias -Name gcam -Value Zsh-Shortcut-Git-Cmd-gcam -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gca! { & git commit -v -a --amend }; New-Alias -Name gca! -Value Zsh-Shortcut-Git-Cmd-gca! -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gcan! { & git commit -v -a -s --no-edit --amend }; New-Alias -Name gcan! -Value Zsh-Shortcut-Git-Cmd-gcan! -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gcb { & git checkout -b }; New-Alias -Name gcb -Value Zsh-Shortcut-Git-Cmd-gcb -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gcf { & git config --list }; New-Alias -Name gcf -Value Zsh-Shortcut-Git-Cmd-gcf -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gcl { & git clone --recursive }; New-Alias -Name gcl -Value Zsh-Shortcut-Git-Cmd-gcl -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gclean { & git clean -df }; New-Alias -Name gclean -Value Zsh-Shortcut-Git-Cmd-gclean -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gcm { & git checkout master }; New-Alias -Name gcm -Value Zsh-Shortcut-Git-Cmd-gcm -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gcd { & git checkout develop }; New-Alias -Name gcd -Value Zsh-Shortcut-Git-Cmd-gcd -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gcmsg { & git commit -m }; New-Alias -Name gcmsg -Value Zsh-Shortcut-Git-Cmd-gcmsg -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gco { & git checkout }; New-Alias -Name gco -Value Zsh-Shortcut-Git-Cmd-gco -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gcount { & git shortlog -sn }; New-Alias -Name gcount -Value Zsh-Shortcut-Git-Cmd-gcount -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gcp { & git cherry-pick }; New-Alias -Name gcp -Value Zsh-Shortcut-Git-Cmd-gcp -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gcpa { & git cherry-pick --abort }; New-Alias -Name gcpa -Value Zsh-Shortcut-Git-Cmd-gcpa -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gcpc { & git cherry-pick --continue }; New-Alias -Name gcpc -Value Zsh-Shortcut-Git-Cmd-gcpc -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gcs { & git commit -S }; New-Alias -Name gcs -Value Zsh-Shortcut-Git-Cmd-gcs -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gd { & git diff }; New-Alias -Name gd -Value Zsh-Shortcut-Git-Cmd-gd -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gdca { & git diff --cached }; New-Alias -Name gdca -Value Zsh-Shortcut-Git-Cmd-gdca -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gdt { & git diff-tree --no-commit-id --name-only -r }; New-Alias -Name gdt -Value Zsh-Shortcut-Git-Cmd-gdt -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gdw { & git diff --word-diff }; New-Alias -Name gdw -Value Zsh-Shortcut-Git-Cmd-gdw -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gf { & git fetch }; New-Alias -Name gf -Value Zsh-Shortcut-Git-Cmd-gf -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gfa { & git fetch --all --prune }; New-Alias -Name gfa -Value Zsh-Shortcut-Git-Cmd-gfa -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gfo { & git fetch origin }; New-Alias -Name gfo -Value Zsh-Shortcut-Git-Cmd-gfo -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gg { & git gui citool }; New-Alias -Name gg -Value Zsh-Shortcut-Git-Cmd-gg -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gga { & git gui citool --amend }; New-Alias -Name gga -Value Zsh-Shortcut-Git-Cmd-gga -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-ggf { & git push --force origin $(current_branch) }; New-Alias -Name ggf -Value Zsh-Shortcut-Git-Cmd-ggf -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-ghh { & git help }; New-Alias -Name ghh -Value Zsh-Shortcut-Git-Cmd-ghh -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-ggsup { & git branch --set-upstream-to=origin/$(current_branch) }; New-Alias -Name ggsup -Value Zsh-Shortcut-Git-Cmd-ggsup -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gpsup { & git push --set-upstream origin $(current_branch) }; New-Alias -Name gpsup -Value Zsh-Shortcut-Git-Cmd-gpsup -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gignore { & git update-index --assume-unchanged }; New-Alias -Name gignore -Value Zsh-Shortcut-Git-Cmd-gignore -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gignored { & git ls-files -v | grep "^:lower:" }; New-Alias -Name gignored -Value Zsh-Shortcut-Git-Cmd-gignored -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gl { & git pull }; New-Alias -Name gl -Value Zsh-Shortcut-Git-Cmd-gl -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-glg { & git log --stat --color }; New-Alias -Name glg -Value Zsh-Shortcut-Git-Cmd-glg -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-glgg { & git log --graph --color }; New-Alias -Name glgg -Value Zsh-Shortcut-Git-Cmd-glgg -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-glgga { & git log --graph --decorate --all }; New-Alias -Name glgga -Value Zsh-Shortcut-Git-Cmd-glgga -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-glgm { & git log --graph --max-count=10 }; New-Alias -Name glgm -Value Zsh-Shortcut-Git-Cmd-glgm -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-glgp { & git log --stat --color -p }; New-Alias -Name glgp -Value Zsh-Shortcut-Git-Cmd-glgp -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-glo { & git log --oneline --decorate --color }; New-Alias -Name glo -Value Zsh-Shortcut-Git-Cmd-glo -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-glog { & git log --oneline --decorate --color --graph }; New-Alias -Name glog -Value Zsh-Shortcut-Git-Cmd-glog -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-glol { & git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit }; New-Alias -Name glol -Value Zsh-Shortcut-Git-Cmd-glol -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-glola { & git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all }; New-Alias -Name glola -Value Zsh-Shortcut-Git-Cmd-glola -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-glp { & _git_log_prettily }; New-Alias -Name glp -Value Zsh-Shortcut-Git-Cmd-glp -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gm { & git merge }; New-Alias -Name gm -Value Zsh-Shortcut-Git-Cmd-gm -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gmom { & git merge origin/master }; New-Alias -Name gmom -Value Zsh-Shortcut-Git-Cmd-gmom -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gmt { & git mergetool --no-prompt }; New-Alias -Name gmt -Value Zsh-Shortcut-Git-Cmd-gmt -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gmtvim { & git mergetool --no-prompt --tool=vimdiff }; New-Alias -Name gmtvim -Value Zsh-Shortcut-Git-Cmd-gmtvim -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gmum { & git merge upstream/master }; New-Alias -Name gmum -Value Zsh-Shortcut-Git-Cmd-gmum -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gp { & git push }; New-Alias -Name gp -Value Zsh-Shortcut-Git-Cmd-gp -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gpd { & git push --dry-run }; New-Alias -Name gpd -Value Zsh-Shortcut-Git-Cmd-gpd -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gpu { & git push upstream }; New-Alias -Name gpu -Value Zsh-Shortcut-Git-Cmd-gpu -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gpv { & git push -v }; New-Alias -Name gpv -Value Zsh-Shortcut-Git-Cmd-gpv -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gr { & git remote }; New-Alias -Name gr -Value Zsh-Shortcut-Git-Cmd-gr -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gra { & git remote add }; New-Alias -Name gra -Value Zsh-Shortcut-Git-Cmd-gra -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-grb { & git rebase }; New-Alias -Name grb -Value Zsh-Shortcut-Git-Cmd-grb -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-grba { & git rebase --abort }; New-Alias -Name grba -Value Zsh-Shortcut-Git-Cmd-grba -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-grbc { & git rebase --continue }; New-Alias -Name grbc -Value Zsh-Shortcut-Git-Cmd-grbc -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-grbi { & git rebase -i }; New-Alias -Name grbi -Value Zsh-Shortcut-Git-Cmd-grbi -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-grbm { & git rebase master }; New-Alias -Name grbm -Value Zsh-Shortcut-Git-Cmd-grbm -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-grbs { & git rebase --skip }; New-Alias -Name grbs -Value Zsh-Shortcut-Git-Cmd-grbs -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-grh { & git reset HEAD }; New-Alias -Name grh -Value Zsh-Shortcut-Git-Cmd-grh -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-grhh { & git reset HEAD --hard }; New-Alias -Name grhh -Value Zsh-Shortcut-Git-Cmd-grhh -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-grmv { & git remote rename }; New-Alias -Name grmv -Value Zsh-Shortcut-Git-Cmd-grmv -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-grrm { & git remote remove }; New-Alias -Name grrm -Value Zsh-Shortcut-Git-Cmd-grrm -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-grset { & git remote set-url }; New-Alias -Name grset -Value Zsh-Shortcut-Git-Cmd-grset -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gru { & git reset -- }; New-Alias -Name gru -Value Zsh-Shortcut-Git-Cmd-gru -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-grup { & git remote update }; New-Alias -Name grup -Value Zsh-Shortcut-Git-Cmd-grup -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-grv { & git remote -v }; New-Alias -Name grv -Value Zsh-Shortcut-Git-Cmd-grv -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gsb { & git status -sb }; New-Alias -Name gsb -Value Zsh-Shortcut-Git-Cmd-gsb -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gsd { & git svn dcommit }; New-Alias -Name gsd -Value Zsh-Shortcut-Git-Cmd-gsd -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gsi { & git submodule init }; New-Alias -Name gsi -Value Zsh-Shortcut-Git-Cmd-gsi -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gsps { & git show --pretty=short --show-signature }; New-Alias -Name gsps -Value Zsh-Shortcut-Git-Cmd-gsps -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gsr { & git svn rebase }; New-Alias -Name gsr -Value Zsh-Shortcut-Git-Cmd-gsr -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gss { & git status -s }; New-Alias -Name gss -Value Zsh-Shortcut-Git-Cmd-gss -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gst { & git status }; New-Alias -Name gst -Value Zsh-Shortcut-Git-Cmd-gst -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gsta { & git stash save }; New-Alias -Name gsta -Value Zsh-Shortcut-Git-Cmd-gsta -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gstaa { & git stash apply }; New-Alias -Name gstaa -Value Zsh-Shortcut-Git-Cmd-gstaa -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gstd { & git stash drop }; New-Alias -Name gstd -Value Zsh-Shortcut-Git-Cmd-gstd -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gstl { & git stash list }; New-Alias -Name gstl -Value Zsh-Shortcut-Git-Cmd-gstl -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gstp { & git stash pop }; New-Alias -Name gstp -Value Zsh-Shortcut-Git-Cmd-gstp -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gstc { & git stash clear }; New-Alias -Name gstc -Value Zsh-Shortcut-Git-Cmd-gstc -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gsts { & git stash show --text }; New-Alias -Name gsts -Value Zsh-Shortcut-Git-Cmd-gsts -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gsu { & git submodule update }; New-Alias -Name gsu -Value Zsh-Shortcut-Git-Cmd-gsu -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gts { & git tag -s }; New-Alias -Name gts -Value Zsh-Shortcut-Git-Cmd-gts -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gunignore { & git update-index --no-assume-unchanged }; New-Alias -Name gunignore -Value Zsh-Shortcut-Git-Cmd-gunignore -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gup { & git pull --rebase }; New-Alias -Name gup -Value Zsh-Shortcut-Git-Cmd-gup -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gupv { & git pull --rebase -v }; New-Alias -Name gupv -Value Zsh-Shortcut-Git-Cmd-gupv -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-glum { & git pull upstream master }; New-Alias -Name glum -Value Zsh-Shortcut-Git-Cmd-glum -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gvt { & git verify-tag }; New-Alias -Name gvt -Value Zsh-Shortcut-Git-Cmd-gvt -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-gwch { & git whatchanged -p --abbrev-commit --pretty=medium }; New-Alias -Name gwch -Value Zsh-Shortcut-Git-Cmd-gwch -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-ggl { $current_branch=gitBranchName; & git pull origin $current_branch }; New-Alias -Name ggl -Value Zsh-Shortcut-Git-Cmd-ggl -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-ggp { $current_branch=gitBranchName; & git push origin $current_branch }; New-Alias -Name ggp -Value Zsh-Shortcut-Git-Cmd-ggp -Force -Option AllScope;
function Zsh-Shortcut-Git-Cmd-ggu { $current_branch=gitBranchName; & git pull --rebase origin $current_branch }; New-Alias -Name ggu -Value Zsh-Shortcut-Git-Cmd-ggu -Force -Option AllScope;
Import-Module 'C:\tools\poshgit\dahlbyk-posh-git-a4faccd\src\posh-git.psd1'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment