Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fish support

  • Loading branch information...
commit 3faae4fa4baabc7fdf2893ecc440ddb2f2728389 1 parent b3ce548
Olivier Refalo authored committed
Showing with 2,144 additions and 2 deletions.
  1. 0  { → bash}/Makefile
  2. 0  { → bash}/cmds/color.sh
  3. 0  { → bash}/cmds/g2-abort.sh
  4. 0  { → bash}/cmds/g2-br.sh
  5. 0  { → bash}/cmds/g2-ci.sh
  6. 0  { → bash}/cmds/g2-co.sh
  7. 0  { → bash}/cmds/g2-continue.sh
  8. 0  { → bash}/cmds/g2-cp.sh
  9. 0  { → bash}/cmds/g2-freeze.sh
  10. +1 −1  { → bash}/cmds/g2-g2add.sh
  11. 0  { → bash}/cmds/g2-g2am.sh
  12. 0  { → bash}/cmds/g2-g2brstatus.sh
  13. 0  { → bash}/cmds/g2-g2gc.sh
  14. 0  { → bash}/cmds/g2-g2getremote.sh
  15. 0  { → bash}/cmds/g2-g2haschanges.sh
  16. 0  { → bash}/cmds/g2-g2haslocalcommit.sh
  17. 0  { → bash}/cmds/g2-g2help.sh
  18. 0  { → bash}/cmds/g2-g2isbehind.sh
  19. 0  { → bash}/cmds/g2-g2isforced.sh
  20. 0  { → bash}/cmds/g2-g2iswip.sh
  21. 0  { → bash}/cmds/g2-g2pull.sh
  22. 0  { → bash}/cmds/g2-g2push.sh
  23. 0  { → bash}/cmds/g2-g2version.sh
  24. 0  { → bash}/cmds/g2-ig.sh
  25. 0  { → bash}/cmds/g2-key.sh
  26. 0  { → bash}/cmds/g2-lg.sh
  27. 0  { → bash}/cmds/g2-mg.sh
  28. 0  { → bash}/cmds/g2-panic.sh
  29. 0  { → bash}/cmds/g2-rb.sh
  30. +1 −1  { → bash}/cmds/g2-rs.sh
  31. 0  { → bash}/cmds/g2-setup.sh
  32. 0  { → bash}/cmds/g2-sh.sh
  33. 0  { → bash}/cmds/g2-sync.sh
  34. 0  { → bash}/cmds/g2-track.sh
  35. 0  { → bash}/cmds/g2-undo.sh
  36. 0  { → bash}/cmds/g2-unfreeze.sh
  37. 0  { → bash}/cmds/g2-unwip.sh
  38. 0  { → bash}/cmds/g2-wip.sh
  39. 0  { → bash}/g2-completion.sh
  40. 0  { → bash}/g2-config.sh
  41. 0  { → bash}/g2-install.sh
  42. 0  { → bash}/g2-prompt.conf
  43. 0  { → bash}/g2-prompt.sh
  44. 0  { → bash}/g2.sh
  45. +18 −0 fish/TODO
  46. +6 −0 fish/fish_right_prompt.fish
  47. +383 −0 fish/g2-completion.fish
  48. +40 −0 fish/g2-motd.fish
  49. +393 −0 fish/g2-prompt.fish
  50. +1,159 −0 fish/g2.fish
  51. +143 −0 fish/test.fish
View
0  Makefile → bash/Makefile
File renamed without changes
View
0  cmds/color.sh → bash/cmds/color.sh
File renamed without changes
View
0  cmds/g2-abort.sh → bash/cmds/g2-abort.sh
File renamed without changes
View
0  cmds/g2-br.sh → bash/cmds/g2-br.sh
File renamed without changes
View
0  cmds/g2-ci.sh → bash/cmds/g2-ci.sh
File renamed without changes
View
0  cmds/g2-co.sh → bash/cmds/g2-co.sh
File renamed without changes
View
0  cmds/g2-continue.sh → bash/cmds/g2-continue.sh
File renamed without changes
View
0  cmds/g2-cp.sh → bash/cmds/g2-cp.sh
File renamed without changes
View
0  cmds/g2-freeze.sh → bash/cmds/g2-freeze.sh
File renamed without changes
View
2  cmds/g2-g2add.sh → bash/cmds/g2-g2add.sh
@@ -1,4 +1,4 @@
#!/bin/bash
#
source "$G2_HOME/cmds/color.sh"
-fatal "Please don't use ${boldon}add${boldoff} with G2, ${boldon}freeze${boldoff} and ${boldon}unfreeze${boldoff} are more powerfull commands"
+fatal "Please don't use ${boldon}add${boldoff} with G2, ${boldon}freeze${boldoff} and ${boldon}unfreeze${boldoff} are more powerfull commands"
View
0  cmds/g2-g2am.sh → bash/cmds/g2-g2am.sh
File renamed without changes
View
0  cmds/g2-g2brstatus.sh → bash/cmds/g2-g2brstatus.sh
File renamed without changes
View
0  cmds/g2-g2gc.sh → bash/cmds/g2-g2gc.sh
File renamed without changes
View
0  cmds/g2-g2getremote.sh → bash/cmds/g2-g2getremote.sh
File renamed without changes
View
0  cmds/g2-g2haschanges.sh → bash/cmds/g2-g2haschanges.sh
File renamed without changes
View
0  cmds/g2-g2haslocalcommit.sh → bash/cmds/g2-g2haslocalcommit.sh
File renamed without changes
View
0  cmds/g2-g2help.sh → bash/cmds/g2-g2help.sh
File renamed without changes
View
0  cmds/g2-g2isbehind.sh → bash/cmds/g2-g2isbehind.sh
File renamed without changes
View
0  cmds/g2-g2isforced.sh → bash/cmds/g2-g2isforced.sh
File renamed without changes
View
0  cmds/g2-g2iswip.sh → bash/cmds/g2-g2iswip.sh
File renamed without changes
View
0  cmds/g2-g2pull.sh → bash/cmds/g2-g2pull.sh
File renamed without changes
View
0  cmds/g2-g2push.sh → bash/cmds/g2-g2push.sh
File renamed without changes
View
0  cmds/g2-g2version.sh → bash/cmds/g2-g2version.sh
File renamed without changes
View
0  cmds/g2-ig.sh → bash/cmds/g2-ig.sh
File renamed without changes
View
0  cmds/g2-key.sh → bash/cmds/g2-key.sh
File renamed without changes
View
0  cmds/g2-lg.sh → bash/cmds/g2-lg.sh
File renamed without changes
View
0  cmds/g2-mg.sh → bash/cmds/g2-mg.sh
File renamed without changes
View
0  cmds/g2-panic.sh → bash/cmds/g2-panic.sh
File renamed without changes
View
0  cmds/g2-rb.sh → bash/cmds/g2-rb.sh
File renamed without changes
View
2  cmds/g2-rs.sh → bash/cmds/g2-rs.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-#
+
"$GIT_EXE" rev-parse || exit 1
source "$G2_HOME/cmds/color.sh"
View
0  cmds/g2-setup.sh → bash/cmds/g2-setup.sh
File renamed without changes
View
0  cmds/g2-sh.sh → bash/cmds/g2-sh.sh
File renamed without changes
View
0  cmds/g2-sync.sh → bash/cmds/g2-sync.sh
File renamed without changes
View
0  cmds/g2-track.sh → bash/cmds/g2-track.sh
File renamed without changes
View
0  cmds/g2-undo.sh → bash/cmds/g2-undo.sh
File renamed without changes
View
0  cmds/g2-unfreeze.sh → bash/cmds/g2-unfreeze.sh
File renamed without changes
View
0  cmds/g2-unwip.sh → bash/cmds/g2-unwip.sh
File renamed without changes
View
0  cmds/g2-wip.sh → bash/cmds/g2-wip.sh
File renamed without changes
View
0  g2-completion.sh → bash/g2-completion.sh
File renamed without changes
View
0  g2-config.sh → bash/g2-config.sh
File renamed without changes
View
0  g2-install.sh → bash/g2-install.sh
File renamed without changes
View
0  g2-prompt.conf → bash/g2-prompt.conf
File renamed without changes
View
0  g2-prompt.sh → bash/g2-prompt.sh
File renamed without changes
View
0  g2.sh → bash/g2.sh
File renamed without changes
View
18 fish/TODO
@@ -0,0 +1,18 @@
+
+setup advanved mode
+g check
+
+add right prompt
+
+check if merge/commit in undo
+
+
+ if test (command git diff --cached --numstat | wc -l) -eq 0
+ __g2_fatal 'No changes to amend, please use <g freeze> to stage your modification, then try amending again.'
+ return 1
+ end
+ -- better
+ if not git diff --cached --no-ext-diff --quiet --exit-code
+ __g2_fatal 'No changes to amend, please use <g freeze> to stage your modification, then try amending again.'
+ return 1
+ end
View
6 fish/fish_right_prompt.fish
@@ -0,0 +1,6 @@
+function fish_right_prompt
+ set_color $fish_color_autosuggestion[1]
+ set_color green
+ printf (date "+$c2%H$c0:$c2%M$c0:$c2%S")
+ set_color normal
+end
View
383 fish/g2-completion.fish
@@ -0,0 +1,383 @@
+# fish completion for git
+# Use 'command git' to avoid interactions for aliases from git to (e.g.) hub
+
+function __g2_prompt_branches
+ command git branch --no-color -a ^/dev/null | sgrep -v ' -> ' | sed -e 's/^..//' -e 's/^remotes\///'
+end
+
+function __g2_prompt_remotebranches
+ __g2_prompt_branches | grep /
+end
+
+function __g2_prompt_tags
+ command git tag
+end
+
+function __g2_prompt_heads
+ __g2_prompt_branches
+ __g2_prompt_tags
+end
+
+function __g2_prompt_remotes
+ command git remote
+end
+
+# commit hashs
+function __g2_prompt_getcommithash
+ command git log --no-merges --pretty=format:"%h" --since=1.weeks
+end
+
+# merge commit hashes
+function __g2_prompt_getmergecommithash
+ command git log --merges --pretty=format:"%h" --since=1.weeks
+end
+
+# files changed in workspace
+function __g2_prompt_modified_files
+ command git ls-files -m --exclude-standard ^/dev/null
+end
+
+# files modified
+function __g2_prompt_add_files
+ command git ls-files -mo --exclude-standard ^/dev/null
+end
+
+# files in staging area
+function __g2_prompt_fileinstaging
+ command git diff --cached --name-only --relative .
+end
+
+function __g2_prompt_ranges
+ set -l from (commandline -ot | perl -ne 'if (index($_, "..") > 0) { my @parts = split(/\.\./); print $parts[0]; }')
+ if test -z "$from"
+ __g2_prompt_branches
+ return 0
+ end
+
+ set -l to (commandline -ot | perl -ne 'if (index($_, "..") > 0) { my @parts = split(/\.\./); print $parts[1]; }')
+ for from_ref in (__g2_prompt_heads | sgrep -e "$from")
+ for to_ref in (__g2_prompt_heads | sgrep -e "$to")
+ printf "%s..%s\n" $from_ref $to_ref
+ end
+ end
+end
+
+function __g2_prompt_needs_command
+ set cmd (commandline -opc)
+ if [ (count $cmd) -eq 1 ]
+ switch $cmd[1]
+ case 'g' 'git'
+ return 0
+ end
+ end
+ return 1
+end
+
+function __g2_prompt_using_command
+ set cmd (commandline -opc)
+ if [ (count $cmd) -gt 1 ]
+ if [ $argv[1] = $cmd[2] ]
+ return 0
+ end
+
+ # aliased command
+ set -l aliased (command git config --get "alias.$cmd[2]" ^ /dev/null | sed 's/ .*$//')
+ if [ $argv[1] = "$aliased" ]
+ return 0
+ end
+ end
+ return 1
+end
+
+# general options
+complete -f -c g -n 'not __g2_prompt_needs_command' -l help -d 'Display the manual of a git command'
+
+# abort
+complete -f -c g -n '__g2_prompt_needs_command' -a 'abort' -d 'Aborts any rebase/merge'
+
+# am
+complete -f -c g -n '__g2_prompt_needs_command' -a 'am' -d 'Amends last commit with content from the staging area'
+complete -f -c g -n '__g2_prompt_using_command am' -s f -l verbose -d 'Force amends'
+
+# br
+complete -f -c g -n '__g2_prompt_needs_command' -a 'br' -d 'List, create, or delete branches'
+complete -f -c g -n '__g2_prompt_using_command br' -a '(__g2_prompt_branches)' -d 'Branch'
+complete -f -c g -n '__g2_prompt_using_command br' -s d -d 'Delete branch'
+complete -f -c g -n '__g2_prompt_using_command br' -s D -d 'Force deletion of branch'
+complete -f -c g -n '__g2_prompt_using_command br' -s m -d 'Rename branch'
+complete -f -c g -n '__g2_prompt_using_command br' -s M -d 'Force renaming branch'
+complete -f -c g -n '__g2_prompt_using_command br' -s a -d 'Lists both local and remote branches'
+complete -f -c g -n '__g2_prompt_using_command br' -s t -l track -d 'Track remote branch'
+complete -f -c g -n '__g2_prompt_using_command br' -l no-track -d 'Do not track remote branch'
+complete -f -c g -n '__g2_prompt_using_command br' -l set-upstream -d 'Set remote branch to track'
+
+# bs
+complete -f -c g -n '__g2_prompt_needs_command' -a 'bs' -d 'Find the change that introduced a bug by binary search'
+
+# co
+complete -f -c g -n '__g2_prompt_needs_command' -a 'co' -d 'Checkout and switch to a branch'
+complete -f -c g -n '__g2_prompt_using_command co' -a '(__g2_prompt_branches)' --description 'Branch'
+complete -f -c g -n '__g2_prompt_using_command co' -a '(__g2_prompt_tags)' --description 'Tag'
+complete -f -c g -n '__g2_prompt_using_command co' -a '(__g2_prompt_modified_files)' --description 'File'
+complete -f -c g -n '__g2_prompt_using_command co' -s b -d 'Create a new branch'
+complete -f -c g -n '__g2_prompt_using_command co' -s t -l track -d 'Track a new branch'
+
+complete -f -c g -n '__g2_prompt_needs_command' -a 'continue' -d 'Resumes conflict resolution process'
+
+# cp
+complete -f -c g -n '__g2_prompt_needs_command' -a 'cp' -d 'Apply the change introduced by an existing commit'
+complete -f -c g -n '__g2_prompt_using_command cp' -a '(__g2_prompt_branches)' -d 'Branch'
+
+# co
+complete -f -c g -n '__g2_prompt_needs_command' -a 'ci' -d 'Record changes to the repository'
+complete -f -c g -n '__g2_prompt_using_command ci' -s m -l message -d 'Use the given <msg> as the commit message.'
+
+# clone
+complete -f -c g -n '__g2_prompt_needs_command' -a 'clone' -d 'Clone a repository into a new directory'
+
+# df
+complete -c g -n '__g2_prompt_needs_command' -a 'df' -d 'Show changes between commits, commit and working tree, etc'
+complete -c g -n '__g2_prompt_using_command df' -a '(__g2_prompt_ranges)' -d 'Branch'
+complete -c g -n '__g2_prompt_using_command df' -l cached -d 'Show diff of changes in the index'
+
+# dt
+complete -c g -n '__g2_prompt_needs_command' -a 'dt' -d 'Open diffs in a visual tool'
+complete -c g -n '__g2_prompt_using_command dt' -a '(__g2_prompt_ranges)' -d 'Branch'
+complete -c g -n '__g2_prompt_using_command dt' -l cached -d 'Visually show diff of changes in the index'
+
+# fetch
+complete -f -c g -n '__g2_prompt_needs_command' -a fetch -d 'Download objects and refs from another repository'
+complete -f -c g -n '__g2_prompt_using_command fetch' -a '(__g2_prompt_remotes)' -d 'Remote'
+complete -f -c g -n '__g2_prompt_using_command fetch' -s q -l quiet -d 'Be quiet'
+complete -f -c g -n '__g2_prompt_using_command fetch' -s v -l verbose -d 'Be verbose'
+complete -f -c g -n '__g2_prompt_using_command fetch' -s a -l append -d 'Append ref names and object names'
+# TODO --upload-pack
+complete -f -c g -n '__g2_prompt_using_command fetch' -s f -l force -d 'Force update of local branches'
+
+# freeze
+complete -c g -n '__g2_prompt_needs_command' -a freeze -d 'Freezes file contents to the index'
+complete -f -c g -n '__g2_prompt_using_command freeze' -s m -l message -d 'Create a commit using the given <msg>.'
+complete -f -c g -n '__g2_prompt_using_command freeze; and __fish_contains_opt -s p patch' -a '(__g2_prompt_modified_files)'
+complete -f -c g -n '__g2_prompt_using_command freeze' -a '(__g2_prompt_add_files)'
+
+# unfreeze
+complete -c g -n '__g2_prompt_needs_command' -a unfreeze -d 'UnFreezes file contents from the index'
+complete -f -c g -n '__g2_prompt_using_command unfreeze; and __fish_contains_opt -s p patch' -a '(__g2_prompt_modified_files)'
+complete -f -c g -n '__g2_prompt_using_command unfreeze' -a '(__g2_prompt_fileinstaging)'
+
+#gc
+complete -f -c g -n '__g2_prompt_needs_command' -a 'gc' -d 'Garbage collects and cleansup the repository'
+
+# gp
+complete -c g -n '__g2_prompt_needs_command' -a 'gp' -d 'Print lines matching a pattern'
+
+# gui
+complete -c g -n '__g2_prompt_needs_command' -a 'gui' -d 'Opens git gui'
+
+# ig
+complete -c g -n '__g2_prompt_needs_command' -a 'ig' -d 'adds pattern to .ignore file'
+
+# init
+complete -f -c g -n '__g2_prompt_needs_command' -a 'init' -d 'Create an empty git repository or reinitialize an existing one'
+
+# key
+complete -c g -n '__g2_prompt_needs_command' -a 'key' -d 'Displays your ssh public key'
+complete -f -c g -n '__g2_prompt_using_command key' -s gen -d 'Generates a new ssh identify'
+
+# mg
+complete -f -c g -n '__g2_prompt_needs_command' -a 'mg' -d 'Join two or more development histories together'
+complete -f -c g -n '__g2_prompt_using_command mg' -a '(__g2_prompt_branches)' -d 'Branch'
+complete -f -c g -n '__g2_prompt_using_command mg' -l commit -d "Autocommit the merge"
+complete -f -c g -n '__g2_prompt_using_command mg' -l no-commit -d "Don't autocommit the merge"
+complete -f -c g -n '__g2_prompt_using_command mg' -l edit -d 'Edit auto-generated merge message'
+complete -f -c g -n '__g2_prompt_using_command mg' -l no-edit -d "Don't edit auto-generated merge message"
+complete -f -c g -n '__g2_prompt_using_command mg' -l ff -d "Don't generate a merge commit if merge is fast-forward"
+complete -f -c g -n '__g2_prompt_using_command mg' -l no-ff -d "Generate a merge commit even if merge is fast-forward"
+complete -f -c g -n '__g2_prompt_using_command mg' -l ff-only -d 'Refuse to merge unless fast-forward possible'
+complete -f -c g -n '__g2_prompt_using_command mg' -l log -d 'Populate the log message with one-line descriptions'
+complete -f -c g -n '__g2_prompt_using_command mg' -l no-log -d "Don't populate the log message with one-line descriptions"
+complete -f -c g -n '__g2_prompt_using_command mg' -l stat -d "Show diffstat of the merge"
+complete -f -c g -n '__g2_prompt_using_command mg' -s n -l no-stat -d "Don't show diffstat of the merge"
+complete -f -c g -n '__g2_prompt_using_command mg' -l squash -d "Squash changes from other branch as a single commit"
+complete -f -c g -n '__g2_prompt_using_command mg' -l no-squash -d "Don't squash changes"
+complete -f -c g -n '__g2_prompt_using_command mg' -s q -l quiet -d 'Be quiet'
+complete -f -c g -n '__g2_prompt_using_command mg' -s v -l verbose -d 'Be verbose'
+complete -f -c g -n '__g2_prompt_using_command mg' -l progress -d 'Force progress status'
+complete -f -c g -n '__g2_prompt_using_command mg' -l no-progress -d 'Force no progress status'
+complete -f -c g -n '__g2_prompt_using_command mg' -s m -d 'Set the commit message'
+complete -f -c g -n '__g2_prompt_using_command mg' -l abort -d 'Abort the current conflict resolution process'
+
+# mt
+complete -f -c g -n '__g2_prompt_needs_command' -a 'mt' -d 'Visually resolve conflicts'
+
+# mv
+complete -c g -n '__g2_prompt_needs_command' -a 'mv' -d 'Move or rename a file, a directory, or a symlink'
+
+# lg
+complete -c g -n '__g2_prompt_needs_command' -a 'lg' -d 'Show commit logs'
+complete -c g -n '__g2_prompt_using_command lg' -a '(__g2_prompt_heads) (__g2_prompt_ranges)' -d 'Branch'
+complete -f -c g -n '__g2_prompt_using_command lg' -l pretty -a 'oneline short medium full fuller email raw format:'
+
+# ls
+complete -c g -n '__g2_prompt_needs_command' -a 'ls' -d 'Lists files under source control'
+
+# panic
+complete -f -c g -n '__g2_prompt_needs_command' -a 'panic' -d 'Checks out HEAD, clean all untracked files'
+
+# push
+complete -f -c g -n '__g2_prompt_needs_command' -a 'push' -d 'Update remote refs along with associated objects'
+complete -f -c g -n '__g2_prompt_using_command push' -a '(git remote)' -d 'Remote alias'
+complete -f -c g -n '__g2_prompt_using_command push' -a '(__g2_prompt_branches)' -d 'Branch'
+complete -f -c g -n '__g2_prompt_using_command push' -l all -d 'Push all refs under refs/heads/'
+complete -f -c g -n '__g2_prompt_using_command push' -l prune -d "Remove remote branches that don't have a local counterpart"
+complete -f -c g -n '__g2_prompt_using_command push' -l mirror -d 'Push all refs under refs/'
+complete -f -c g -n '__g2_prompt_using_command push' -l delete -d 'Delete all listed refs from the remote repository'
+complete -f -c g -n '__g2_prompt_using_command push' -l tags -d 'Push all refs under refs/tags'
+complete -f -c g -n '__g2_prompt_using_command push' -s n -l dry-run -d 'Do everything except actually send the updates'
+complete -f -c g -n '__g2_prompt_using_command push' -l porcelain -d 'Produce machine-readable output'
+complete -f -c g -n '__g2_prompt_using_command push' -s f -l force -d 'Force update of remote refs'
+complete -f -c g -n '__g2_prompt_using_command push' -s u -l set-upstream -d 'Add upstream (tracking) reference'
+complete -f -c g -n '__g2_prompt_using_command push' -s q -l quiet -d 'Be quiet'
+complete -f -c g -n '__g2_prompt_using_command push' -s v -l verbose -d 'Be verbose'
+complete -f -c g -n '__g2_prompt_using_command push' -l progress -d 'Force progress status'
+# TODO --recurse-submodules=check|on-demand
+
+# pull
+complete -f -c g -n '__g2_prompt_needs_command' -a 'pull' -d 'Fetch from and merge with another repository or a local branch'
+complete -f -c g -n '__g2_prompt_using_command pull' -s q -l quiet -d 'Be quiet'
+complete -f -c g -n '__g2_prompt_using_command pull' -s v -l verbose -d 'Be verbose'
+# Options related to fetching
+complete -f -c g -n '__g2_prompt_using_command pull' -l all -d 'Fetch all remotes'
+complete -f -c g -n '__g2_prompt_using_command pull' -s a -l append -d 'Append ref names and object names'
+complete -f -c g -n '__g2_prompt_using_command pull' -s f -l force -d 'Force update of local branches'
+complete -f -c g -n '__g2_prompt_using_command pull' -s k -l keep -d 'Keep downloaded pack'
+complete -f -c g -n '__g2_prompt_using_command pull' -l no-tags -d 'Disable automatic tag following'
+# TODO --upload-pack
+complete -f -c g -n '__g2_prompt_using_command pull' -l progress -d 'Force progress status'
+complete -f -c g -n '__g2_prompt_using_command pull' -a '(git remote)' -d 'Remote alias'
+complete -f -c g -n '__g2_prompt_using_command pull' -a '(__g2_prompt_branches)' -d 'Branch'
+
+# rb
+complete -f -c g -n '__g2_prompt_needs_command' -a 'rb' -d 'Forward-port local commits to the updated upstream head'
+complete -f -c g -n '__g2_prompt_using_command rb' -a '(git remote)' -d 'Remote alias'
+complete -f -c g -n '__g2_prompt_using_command rb' -a '(__g2_prompt_branches)' -d 'Branch'
+complete -f -c g -n '__g2_prompt_using_command rb' -l continue -d 'Restart the rebasing process'
+complete -f -c g -n '__g2_prompt_using_command rb' -l abort -d 'Abort the rebase operation'
+complete -f -c g -n '__g2_prompt_using_command rb' -l keep-empty -d "Keep the commits that don't cahnge anything"
+complete -f -c g -n '__g2_prompt_using_command rb' -l skip -d 'Restart the rebasing process by skipping the current patch'
+complete -f -c g -n '__g2_prompt_using_command rb' -s m -l merge -d 'Use merging strategies to rebase'
+complete -f -c g -n '__g2_prompt_using_command rb' -s q -l quiet -d 'Be quiet'
+complete -f -c g -n '__g2_prompt_using_command rb' -s v -l verbose -d 'Be verbose'
+complete -f -c g -n '__g2_prompt_using_command rb' -l stat -d "Show diffstat of the rebase"
+complete -f -c g -n '__g2_prompt_using_command rb' -s n -l no-stat -d "Don't show diffstat of the rebase"
+complete -f -c g -n '__g2_prompt_using_command rb' -l verify -d "Allow the pre-rebase hook to run"
+complete -f -c g -n '__g2_prompt_using_command rb' -l no-verify -d "Don't allow the pre-rebase hook to run"
+complete -f -c g -n '__g2_prompt_using_command rb' -s f -l force-rebase -d 'Force the rebase'
+complete -f -c g -n '__g2_prompt_using_command rb' -s i -l interactive -d 'Interactive mode'
+complete -f -c g -n '__g2_prompt_using_command rb' -s p -l preserve-merges -d 'Try to recreate merges'
+complete -f -c g -n '__g2_prompt_using_command rb' -l root -d 'Rebase all reachable commits'
+complete -f -c g -n '__g2_prompt_using_command rb' -l autosquash -d 'Automatic squashing'
+complete -f -c g -n '__g2_prompt_using_command rb' -l no-autosquash -d 'No automatic squashing'
+complete -f -c g -n '__g2_prompt_using_command rb' -l no-ff -d 'No fast-forward'
+
+# rm
+complete -c g -n '__g2_prompt_needs_command' -a 'rm' -d 'Remove files from the working tree and from the index'
+complete -c g -n '__g2_prompt_using_command rm' -f
+complete -c g -n '__g2_prompt_using_command rm' -l cached -d 'Keep local copies'
+complete -c g -n '__g2_prompt_using_command rm' -l ignore-unmatch -d 'Exit with a zero status even if no files matched'
+complete -c g -n '__g2_prompt_using_command rm' -s r -d 'Allow recursive removal'
+complete -c g -n '__g2_prompt_using_command rm' -s q -l quiet -d 'Be quiet'
+complete -c g -n '__g2_prompt_using_command rm' -s f -l force -d 'Override the up-to-date check'
+complete -c g -n '__g2_prompt_using_command rm' -s n -l dry-run -d 'Dry run'
+
+# rs
+complete -c g -n '__g2_prompt_needs_command' -a 'rs' -d 'Reset current HEAD to the specified state'
+complete -f -c g -n '__g2_prompt_using_command rs' -l hard -d 'Reset files in working directory'
+complete -c g -n '__g2_prompt_using_command rs' -a '(__g2_prompt_branches)'
+
+# rt
+complete -f -c g -n '__g2_prompt_needs_command' -a rt -d 'Manage set of tracked repositories'
+complete -f -c g -n '__g2_prompt_using_command rt' -a '(__g2_prompt_remotes)'
+complete -f -c g -n '__g2_prompt_using_command rt' -s v -l verbose -d 'Be verbose'
+complete -f -c g -n '__g2_prompt_using_command rt' -a add -d 'Adds a new remote'
+complete -f -c g -n '__g2_prompt_using_command rt' -a rm -d 'Removes a remote'
+complete -f -c g -n '__g2_prompt_using_command rt' -a show -d 'Shows a remote'
+complete -f -c g -n '__g2_prompt_using_command rt' -a prune -d 'Deletes all stale tracking branches'
+complete -f -c g -n '__g2_prompt_using_command rt' -a update -d 'Fetches updates'
+
+# rv
+complete -f -c g -n '__g2_prompt_needs_command' -a 'rv' -d 'Revert an existing commit'
+
+# server
+complete -f -c g -n '__g2_prompt_needs_command' -a 'server' -d 'Starts a local git:// server on current repo'
+
+# setup
+complete -f -c g -n '__g2_prompt_needs_command' -a 'setup' -d 'Runs the Git confirguration tool'
+
+# sh
+complete -f -c g -n '__g2_prompt_needs_command' -a 'sh' -d 'Shows the last commit details'
+complete -f -c g -n '__g2_prompt_using_command sh' -a '(__g2_prompt_branches)' -d 'Branch'
+
+# sm
+complete -f -c g -n '__g2_prompt_needs_command' -a 'sm' -d 'Initialize, update or inspect submodules'
+complete -f -c g -n '__g2_prompt_using_command sm' -a 'add' -d 'Add a submodule'
+complete -f -c g -n '__g2_prompt_using_command sm' -a 'status' -d 'Show submodule status'
+complete -f -c g -n '__g2_prompt_using_command sm' -a 'init' -d 'Initialize all submodules'
+complete -f -c g -n '__g2_prompt_using_command sm' -a 'update' -d 'Update all submodules'
+complete -f -c g -n '__g2_prompt_using_command sm' -a 'summary' -d 'Show commit summary'
+complete -f -c g -n '__g2_prompt_using_command sm' -a 'foreach' -d 'Run command on each submodule'
+complete -f -c g -n '__g2_prompt_using_command sm' -a 'sync' -d 'Sync submodules URL with .gitmodules'
+
+### ss
+complete -c g -n '__g2_prompt_needs_command' -a 'ss' -d 'Stash away changes'
+complete -f -c g -n '__g2_prompt_using_command ss' -a list -d 'List stashes'
+complete -f -c g -n '__g2_prompt_using_command ss' -a show -d 'Show the changes recorded in the stash'
+complete -f -c g -n '__g2_prompt_using_command ss' -a pop -d 'Apply and remove a single stashed state'
+complete -f -c g -n '__g2_prompt_using_command ss' -a apply -d 'Apply a single stashed state'
+complete -f -c g -n '__g2_prompt_using_command ss' -a clear -d 'Remove all stashed states'
+complete -f -c g -n '__g2_prompt_using_command ss' -a drop -d 'Remove a single stashed state from the stash list'
+complete -f -c g -n '__g2_prompt_using_command ss' -a create -d 'Create a stash'
+complete -f -c g -n '__g2_prompt_using_command ss' -a save -d 'Save a new stash'
+complete -f -c g -n '__g2_prompt_using_command ss' -a branch -d 'Create a new branch from a stash'
+
+### st
+complete -f -c g -n '__g2_prompt_needs_command' -a 'st' -d 'Show the working tree status'
+complete -f -c g -n '__g2_prompt_using_command st' -s s -l short -d 'Give the output in the short-format'
+complete -f -c g -n '__g2_prompt_using_command st' -s b -l branch -d 'Show the branch and tracking info even in short-format'
+complete -f -c g -n '__g2_prompt_using_command st' -l porcelain -d 'Give the output in a stable, easy-to-parse format'
+complete -f -c g -n '__g2_prompt_using_command st' -s z -d 'Terminate entries with null character'
+complete -f -c g -n '__g2_prompt_using_command st' -s u -l untracked-files -x -a 'no normal all' -d 'The untracked files handling mode'
+complete -f -c g -n '__g2_prompt_using_command st' -l ignore-submodules -x -a 'none untracked dirty all' -d 'Ignore changes to submodules'
+
+### sync
+complete -f -c g -n '__g2_prompt_needs_command' -a 'sync' -d 'Synchronizes working branch with remote'
+
+### tg
+complete -f -c g -n '__g2_prompt_needs_command' -a 'tg' -d 'Create, list, delete or verify a tag object signed with GPG'
+complete -f -c g -n '__g2_prompt_using_command tg ; and __fish_not_contain_opt -s d; and __fish_not_contain_opt -s v; and test (count (commandline -opc | sgrep -v -e \'^-\')) -eq 3' -a '(__g2_prompt_branches)' -d 'Branch'
+complete -f -c g -n '__g2_prompt_using_command tg' -s a -l annotate -d 'Make an unsigned, annotated tag object'
+complete -f -c g -n '__g2_prompt_using_command tg' -s s -l sign -d 'Make a GPG-signed tag'
+complete -f -c g -n '__g2_prompt_using_command tg' -s d -l delete -d 'Remove a tag'
+complete -f -c g -n '__g2_prompt_using_command tg' -s v -l verify -d 'Verify signature of a tag'
+complete -f -c g -n '__g2_prompt_using_command tg' -s f -l force -d 'Force overwriting exising tag'
+complete -f -c g -n '__g2_prompt_using_command tg' -s l -l list -d 'List tags'
+complete -f -c g -n '__fish_contains_opt -s d' -a '(__g2_prompt_tags)' -d 'Tag'
+complete -f -c g -n '__fish_contains_opt -s v' -a '(__g2_prompt_tags)' -d 'Tag'
+
+# track
+complete -f -c g -n '__g2_prompt_needs_command' -a 'track' -d 'Displays/set remote branch tracking'
+complete -f -c g -n '__g2_prompt_using_command track' -a '(__g2_prompt_remotebranches)'
+
+# undo <file>|commit|merge - reverts changes
+complete -c g -n '__g2_prompt_needs_command' -a 'undo' -d 'Undo a file, a last commit or last merge'
+complete -f -c g -n '__g2_prompt_using_command undo' -a commit -d 'Undo the last commit'
+complete -f -c g -n '__g2_prompt_using_command undo' -a merge -d 'Undo the last merge'
+
+# version
+complete -f -c g -n '__g2_prompt_needs_command' -a 'version' -d 'Displays G2 version information'
+
+# wip
+complete -f -c g -n '__g2_prompt_needs_command' -a 'wip' -d 'Pushes Work In Progress on the index '
+
+#unwip
+complete -f -c g -n '__g2_prompt_needs_command' -a 'unwip' -d 'Pulls Work In Progress from the index'
View
40 fish/g2-motd.fish
@@ -0,0 +1,40 @@
+
+function __g2_greeting
+ if status -i
+
+ set -l tips \
+ "<g sync> adds your changes to the tip of the branch and synchronizes with the servers both ways." \
+ "<g freeze> is a handy command to freeze all the changes in one shot." \
+ "g2 saves time by providing high level commands." \
+ "g2 is safer than git as it prompts before destructive actions." \
+ "run <g setup> to configure git." \
+ "g2 provides two letter acronyms for most commands." \
+ "g2 eases the merge process by introducing <g continue> and <g abort>." \
+ "g2 purposely provides a reduced set of commands." \
+ "g2 enhances command line experience with auto-completion <TAB-key> and a smart prompt." \
+ "g2 warns when the branch history was changed on the server (forced pushed)." \
+ "g2 checks the branch freshness prior to merging and warns accordingly." \
+ "g2 enforces a clean linear history by introducing new commands." \
+ "g2 requires a clean state before rebasing, checking out, branching or merging." \
+ "g2 provides guidance when it cannot perform an operation." \
+ "g2 brings a number of friendly commands such as : panic, sync, freeze, wip." \
+ "g2 eases branch creation. try it <g br branchName>." \
+ "Need to display your ssh public key? try <g key>." \
+ "g2 is just easier at undoing things: try <g undo commit> or <g undo merge>." \
+ "When lost, <g panic> is the easiest way to get back on track." \
+ "Use <g track> to review how local/remote branches are setup." \
+ "Remember, you may always access the native git command using <command git>."\
+ "Unlike git, g2 actions only apply to the current branch."
+
+ set_color --bold white
+ echo -n "Tip of the day: "
+ set_color normal
+ set -l idx (math 1+(random)\*(count $tips)/32766)
+ echo $tips[$idx];
+
+ end
+end
+
+function fish_greeting
+ __g2_greeting
+end
View
393 fish/g2-prompt.fish
@@ -0,0 +1,393 @@
+# name: g2 prompt
+#
+# Inspired from bobthefish is a Powerline-style, Git-aware fish theme optimized for awesome.
+#
+# You will probably need a Powerline-patched font for this to work:
+#
+# https://powerline.readthedocs.org/en/latest/fontpatching.html
+#
+# I recommend picking one of these:
+#
+# https://github.com/Lokaltog/powerline-fonts
+#
+# You can override some default options in your config.fish:
+#
+# set -g theme_display_user yes
+# set -g default_user your_normal_user
+
+set -g current_bg NONE
+
+# Powerline glyphs
+set branch_glyph \uE0A0
+set ln_glyph \uE0A1
+set padlock_glyph \uE0A2
+set right_black_arrow_glyph \uE0B0
+set right_arrow_glyph \uE0B1
+set left_black_arrow_glyph \uE0B2
+set left_arrow_glyph \uE0B3
+
+# Additional glyphs
+set detached_glyph \u27A6
+set superuser_glyph '# '
+set bg_job_glyph '% '
+
+# Colors
+set lt_green addc10
+set med_green 189303
+set dk_green 0c4801
+
+set lt_red C99
+set med_red ce000f
+set dk_red 600
+
+set slate_blue 255e87
+
+set lt_orange f6b117
+set dk_orange 3a2a03
+
+set dk_grey 333
+set med_grey 999
+set lt_grey ccc
+
+# ===========================
+# Helper methods
+# ===========================
+
+function __g2prompt_in_git
+ command git rev-parse --is-inside-work-tree >/dev/null ^/dev/null
+end
+
+function __g2prompt_pretty_parent -d 'Print a parent directory, shortened to fit the prompt'
+ echo -n (dirname $argv[1]) | sed -e 's|/private||' -e "s|^$HOME|~|" -e 's-/\(\.\{0,1\}[^/]\)\([^/]*\)-/\1-g' -e 's|/$||'
+end
+
+function __g2prompt_project_dir -d 'Print the current git project base directory'
+ command git rev-parse --show-toplevel ^/dev/null
+end
+
+function __g2prompt_project_pwd -d 'Print the working directory relative to project root'
+ set -l base_dir (__g2prompt_project_dir)
+ echo "$PWD" | sed -e "s*$base_dir**g" -e 's*^/**'
+end
+
+function __g2prompt_aheadbehind --argument-names local
+ if test "$local"
+ set -l remote (__g2_getremote)
+
+ set -l cnt (command git rev-list --left-right --count $local...$remote -- ^/dev/null |tr \t \n)
+ if [ $cnt[1] -gt 0 -a $cnt[2] -gt 0 ]
+ echo -n ' ±'
+ else
+ test $cnt[1] -gt 0; and echo -n ' +'
+ test $cnt[2] -gt 0; and echo -n ' -'
+ end
+ end
+end
+
+function __g2prompt_getBranchOp
+
+ set -l git_dir (command git rev-parse --git-dir ^/dev/null)
+ test ! -d $git_dir; and return 1
+
+ # get repo status & branch name
+ set -l op ''
+ set -l branch ''
+
+ command git ls-tree HEAD >/dev/null ^/dev/null
+
+ if test $status -eq 128
+ set op 'init'
+ else
+
+ set -l step
+ set -l total
+
+ if test -d "$git_dir/rebase-merge"
+
+ set step (cat "$git_dir/rebase-merge/msgnum")
+ set total (cat "$git_dir/rebase-merge/end")
+ set branch (cat "$git_dir/rebase-merge/head-name")" $step/$total"
+
+ if test -f "$git_dir/rebase-merge/interactive"
+ set op 'rebase -i'
+ else
+ set op 'rebase -m'
+ end
+
+ else
+
+ if test -d "$git_dir/rebase-apply"
+
+ set step (cat "$git_dir/rebase-apply/next")
+ set total (cat "$git_dir/rebase-apply/last")
+
+ if test -f "$git_dir/rebase-apply/rebasing"
+ set op 'rebase'
+ else
+ if test -f "$git_dir/rebase-apply/applying"
+ set op 'am'
+ else
+ set op 'am/rebase'
+ end
+ end
+ else
+ if test -f "$git_dir/MERGE_HEAD"
+ set op 'merge'
+ else
+ if test -f "$git_dir/CHERRY_PICK_HEAD"
+ set op 'cherrypick'
+ else
+ if test -f "$git_dir/REVERT_HEAD"
+ set op 'revert'
+ else
+ if test -f "$git_dir/BISECT_LOG"
+ set op 'bisect'
+ end
+ end
+ end
+ end
+ end
+
+
+ if not set branch (command git symbolic-ref HEAD ^/dev/null)
+
+ test ! "$op"; and set op 'detached'
+
+ if not set branch (command git describe --tags --exact-match HEAD ^/dev/null)
+ if not set branch (cut -c 1-7 "$git_dir/HEAD" ^/dev/null)
+ set branch 'unknown'
+ end
+ end
+
+ if test "$step" -a "$total"
+ set branch "[$branch $step/$total]"
+ else
+ set branch "[$branch]"
+ end
+
+ end
+ end
+
+ end
+ echo $branch | sed 's/refs\/heads\///g'
+ echo $op
+end
+
+
+# ===========================
+# Segment functions
+# ===========================
+
+function __g2prompt_start_segment -d 'Start a segment'
+ set_color -b $argv[1]
+ set_color $argv[2]
+ if [ "$current_bg" = 'NONE' ]
+ # If there's no background, just start one
+ echo -n ' '
+ else
+ # If there's already a background...
+ if [ "$argv[1]" = "$current_bg" ]
+ # and it's the same color, draw a separator
+ echo -n "$right_arrow_glyph "
+ else
+ # otherwise, draw the end of the previous segment and the start of the next
+ set_color $current_bg
+ echo -n "$right_black_arrow_glyph "
+ set_color $argv[2]
+ end
+ end
+ set current_bg $argv[1]
+end
+
+function __g2prompt_path_segment -d 'Display a shortened form of a directory'
+ if test -w "$argv[1]"
+ __g2prompt_start_segment $dk_grey $med_grey
+ else
+ __g2prompt_start_segment $dk_red $lt_red
+ end
+
+ set -l directory
+ set -l parent
+
+ switch "$argv[1]"
+ case /
+ set directory '/'
+ case "$HOME"
+ set directory '~'
+ case '*'
+ set parent (__g2prompt_pretty_parent "$argv[1]")
+ set parent "$parent/"
+ set directory (basename "$argv[1]")
+ end
+
+ test "$parent"; and echo -n -s "$parent"
+ set_color fff --bold
+ echo -n "$directory "
+ set_color normal
+end
+
+function __g2prompt_finish_segments -d 'Close open segments'
+ if [ -n $current_bg -a $current_bg != 'NONE' ]
+ set_color -b normal
+ set_color $current_bg
+ echo -n "$right_black_arrow_glyph "
+ set_color normal
+ end
+ set -g current_bg NONE
+end
+
+
+# ===========================
+# Theme components
+# ===========================
+
+function __g2prompt_prompt_status -d 'the symbols for a non zero exit status, root and background jobs'
+ set -l nonzero
+ set -l superuser
+ set -l bg_jobs
+
+ # Last exit was nonzero
+ test $RETVAL -ne 0; and set nonzero $RETVAL
+
+ # if superuser (uid == 0)
+ set -l uid (id -u $USER)
+ test $uid -eq 0; and set superuser $superuser_glyph
+
+ # Jobs display
+ [ (jobs -l | wc -l) -gt 0 ]; and set bg_jobs $bg_job_glyph
+
+ set -l status_flags "$nonzero$superuser$bg_jobs"
+
+ if test "$nonzero" -o "$superuser" -o "$bg_jobs"
+ __g2prompt_start_segment fff 000
+ if [ "$nonzero" ]
+ set_color $med_red --bold
+ echo -n $nonzero_exit_glyph
+ end
+
+ if [ "$superuser" ]
+ set_color $med_green --bold
+ echo -n $superuser_glyph
+ end
+
+ if [ "$bg_jobs" ]
+ set_color $slate_blue --bold
+ echo -n $bg_job_glyph
+ end
+ end
+end
+
+function __g2prompt_prompt_user -d 'Display actual user if different from $default_user'
+ if [ "$theme_display_user" = 'yes' ]
+ if [ "$USER" != "$default_user" -o -n "$SSH_CLIENT" ]
+ __g2prompt_start_segment $lt_grey $slate_blue
+ echo -n -s (whoami) '@' (hostname | cut -d . -f 1) ' '
+ end
+ end
+end
+
+function __g2prompt_prompt_git -d 'Display the actual git state'
+
+ set -l v (__g2prompt_getBranchOp)
+ set -l branch $v[1]
+ set -l op $v[2]
+
+ set -l icon "$branch_glyph "
+ test $op = 'detached'; and set icon "$detached_glyph "
+
+ #### PARSE STATUS
+ set -l new 0
+ set -l staged 0
+ set -l dirty 0
+
+ set -l git_status (command git status --porcelain ^/dev/null)
+
+ for line in $git_status
+ set -l x (echo $line | cut -c 1)
+ set -l y (echo $line | cut -c 2)
+
+ if test $x = '?'
+ set new (math $new + 1)
+ else
+ test $x != ' '; and set staged (math $staged + 1)
+ test $y != ' '; and set dirty (math $dirty + 1)
+ end
+ end
+
+ set -l flags (__g2prompt_aheadbehind $branch)
+
+ set -l flag_bg $med_grey
+ set -l flag_fg 000
+
+ if test -n "$op"
+ if test "$op" = 'init'
+ set flag_bg fff
+ set flag_fg 000
+ set branch 'init'
+ else
+ set flag_bg $med_red
+ set flag_fg fff
+ set branch "$op:$branch"
+ end
+ else
+ if test $staged -gt 0
+ set flag_bg $lt_green
+ set flag_fg $dk_green
+ end
+
+ if test $dirty -gt 0 -o $new -gt 0
+ set flag_bg $lt_orange
+ set flag_fg $dk_orange
+ end
+ end
+
+ __g2prompt_path_segment (__g2prompt_project_dir)
+
+ __g2prompt_start_segment $flag_bg $flag_fg
+ set_color $flag_fg --bold
+ echo -n -s $icon$branch $flags ' '
+
+ set_color normal
+
+ set -l project_pwd (__g2prompt_project_pwd)
+ if test "$project_pwd"
+ if test -w "$PWD"
+ __g2prompt_start_segment 333 999
+ else
+ __g2prompt_start_segment $med_red $lt_red
+ end
+
+ echo -n -s $project_pwd ' '
+ end
+end
+
+function __g2prompt_prompt_dir -d 'Display a shortened form of the current directory'
+ __g2prompt_path_segment "$PWD"
+end
+
+
+# ===========================
+# Apply theme
+# ===========================
+
+function fish_prompt
+ set -g RETVAL $status
+ __g2prompt_prompt_status
+ __g2prompt_prompt_user
+
+ if __g2prompt_in_git
+ __g2prompt_prompt_git
+ else
+ __g2prompt_prompt_dir
+ end
+
+ __g2prompt_finish_segments
+end
+
+function fish_right_prompt
+ set_color $fish_color_autosuggestion[1]
+ printf (date "+$c2%H$c0:$c2%M$c0:$c2%S")
+ set_color normal
+end
+
+
View
1,159 fish/g2.fish
@@ -0,0 +1,1159 @@
+#
+# G2 for fish shell
+#
+# Author - Olivier Refalo
+#
+
+#### output functions ------------------------------------------------------------------
+
+function __g2_fatal
+ set_color red;
+ echo 'fatal: '$argv[1];
+ set_color normal;
+end
+
+function __g2_info
+ set_color --bold white;
+ echo $argv[1];
+ set_color normal;
+end
+
+
+#### IO functions ------------------------------------------------------------------
+
+function __g2_askInput --argument-names prompt default trimResult
+
+ function __g2_askprompt --no-scope-shadowing
+ set_color --bold white;
+ echo -n $prompt
+ set_color normal
+ if test "$default"
+ set_color green
+ echo -n ' ('$default')'
+ set_color normal
+ end
+ echo -n ': '
+ end
+
+ set -l REPLY
+ while test ! (echo "$REPLY" | tr -d ' ')
+ read -p __g2_askprompt REPLY
+ if test -z "$REPLY" -a -n "$default"
+ set REPLY $default
+ end
+ end
+
+ if test "$trimResult" = "true"
+ echo "$REPLY" | tr -d ' '
+ else
+ echo $REPLY
+ end
+
+end
+
+function __g2_askChoice --argument-names prompt choices default trimResult
+
+ set -l list (echo $choices | tr ' ' \n)
+
+ function __g2_askprompt --no-scope-shadowing
+ set_color --bold white;
+ echo $prompt:
+ set_color normal
+
+ set -l defaultFound 0
+ for opt in $list
+ if test "$opt" = "$default"
+ set_color green
+ echo '*' $opt
+ set_color normal
+ set defaultFound 1
+ else
+ echo $opt
+ end
+ end
+
+ if test $defaultFound -eq 0 -a -n "$default"
+ set_color green
+ echo '*' $default
+ set_color normal
+ end
+
+ set_color --bold white
+ if test "$default"
+ echo -n ' Choice ('$default'): '
+ else
+ echo -n ' Choice : '
+ end
+ set_color normal
+
+ end
+
+ set -l REPLY
+ while test -z (echo "$REPLY" | tr -d ' ')
+ read -p __g2_askprompt REPLY
+ if test -z "$REPLY" -a -n "$default"
+ set REPLY $default
+ end
+ end
+
+ if test "$trimResult" = "true"
+ echo "$REPLY" | tr -d ' '
+ else
+ echo "$REPLY"
+ end
+
+end
+
+
+# 1 - means YES 0-No
+function __g2_askYN --argument-names prompt
+
+ function __g2_askprompt --no-scope-shadowing
+ set_color --bold white;
+ echo -n $prompt
+ set_color green
+ echo -n ' [y/N]'
+ set_color normal
+ echo -n '? > '
+ end
+
+ set -l REPLY
+ while test -z "$REPLY"
+ read -p __g2_askprompt -l REPLY
+ switch $REPLY
+ case y Y yes Yes YES
+ return 1
+ end
+ end
+ return 0
+end
+
+#### GIT Utility functions ------------------------------------------------------------------
+
+function __g2_getremote
+ set -l remote (command git rev-parse --symbolic-full-name --abbrev-ref '@{u}' ^/dev/null)
+ if test "$remote" = '@{u}'
+ echo ''
+ else
+ echo $remote
+ end
+end
+
+# Internal command that return "rebase", "merge" or "false" depending on the repository status
+# returns true(0) if merge or rebase
+function __g2_wrkspcState
+
+ set -l git_dir (command git rev-parse --git-dir ^/dev/null)
+
+ if test -d "$git_dir/rebase-merge" -o -d "$git_dir/rebase-apply"
+ echo 'rebase'
+ return 0
+ end
+
+ if test -d "$git_dir/MERGE_HEAD"
+ echo 'merge'
+ return 0
+ end
+
+ echo 'false'
+ return 1
+end
+
+# Returns true(1) if the branch is behind its matching upstream branch
+function __g2_isbehind --argument-names remote
+
+ set -l branch (command git rev-parse --symbolic-full-name --abbrev-ref HEAD)
+ if test -z "$remote"
+ set remote (__g2_getremote)
+ end
+ if test "$remote"
+ command git fetch
+ set -l CNT (command git rev-list --right-only --count $branch...$remote -- )
+ if test $CNT -gt 0
+ return 1;
+ end
+ end
+ return 0
+end
+
+# Returns true(1) if the branch is forward its matching upstream branch
+function __g2_isforward --argument-names remote
+
+ set -l branch (command git rev-parse --symbolic-full-name --abbrev-ref HEAD)
+ test ! "$remote";and set remote (__g2_getremote)
+ if test "$remote"
+ set -l CNT (command git rev-list --left-only --count $branch...$remote -- )
+ if test $CNT -gt 0
+ return 1
+ end
+ end
+ return 0
+end
+
+# Returns true(1) if the given branch was force updated
+# if no parameters are provided, figures the upstream branch from the tracking table
+function __g2_isforced --argument-names remote
+
+ test ! "$remote";and set remote (__g2_getremote)
+ if test "$remote"
+ command git rev-list $remote | grep -quiet (command git rev-parse $remote ) ^/dev/null; and return 1
+ end
+ return 0
+end
+
+# Returns true(1) if the repo has pending changes
+function __g2_isdirty
+
+# if command git diff --no-ext-diff --quiet --exit-code
+# command git diff --cached --no-ext-diff --quiet --exit-code; and return 0
+# end
+
+ if command git diff-files --quiet
+ command git diff-index --quiet --cached HEAD; and return 0
+ end
+
+ __g2_fatal 'Changes detected, please commit them or get them out of the way <g wip>. You may also discard them with a <g panic>.'
+ return 1
+
+end
+
+# return true(1) if top commit is wip - work in progress
+# the proper validation is __g2_iswip; or return 1
+function __g2_iswip --argument-names remote
+
+ #command git rev-parse; or return 0
+
+ test ! "$remote";and set remote (__g2_getremote)
+
+ set -l wip 0
+ if test -z "$remote"
+ set wip (command git log --online -1 ^/dev/null | cut -f 2 -d ' ' | grep -c wip)
+ else
+ set wip (command git log $remote..HEAD --oneline ^/dev/null | cut -f 2 -d ' ' | uniq | grep -c wip)
+ end
+
+ if test $wip -gt 0
+ __g2_fatal 'Work In Progress (wip) detected, please run <g unwip> to resume work items first.'
+ return 1;
+ end
+
+ return 0;
+end
+
+
+#### Now the real thing ------------------------------------------------------------------
+
+
+function __g2_usage
+ echo "G2 Usage:
+ abort - aborts any rebase/merge
+ am <?-f> - amends last commit with staging area
+ br <?-D> <?-M> <?branch> - list or create branches
+ bs - bisect, aka bug finder
+ co <branch> - switches branch (either local/remote)
+ continue - resumes a conflict resolution
+ cp <commit> - cherry-pick
+ ci <?params...> - commit
+ clone <url> - clone a remote repository
+ df/dt <?params...> <file> - compares files
+ fetch - gets changes sitting on the server
+ freeze/unfreeze <?-m comment> <?file> - freeze/unfreeze files
+ gc - garbage collects repository, runs fsck & gc
+ gp - grep
+ gui - launches the GUI
+ ig <file> - adds to gitignore & removes from source control
+ init <folder> - init a repository
+ key <?-gen> - displays/generates your ssh public key
+ mg <?params...> <branch> - merge
+ mt <?params...> - fixes conflicts by opening a visual mergetool
+ mv - move (rename) a file
+ lg - displays branch history log
+ ls <?params...> - list files under source control
+ panic - gets you back on HEAD, cleans all untracked files
+ pull/push <?opts> <remote> <branch> - deals with other branches
+ rb <?params...> <branch> or <upstream> - rebase
+ rm <params...> - remove files
+ rs <params...> - reset branch status
+ rs upstream - resets branch to upstream state
+ rt <?params...> - git remotes management
+ rv <commit> - reverts commits
+ server - starts a local git:// server on current repo
+ setup - configures user, key, editor, tools
+ sh <?-deep> - show commit contents
+ sm <?params...> - submodule management
+ ss <?params> - stash changes
+ st <?params...> - display status
+ sync <?upstream> - syncs working branch: fetch, rebase & push
+ tg - tag
+ track <?upstream_branch> - shows/set remove branch tracking
+ undo <file>|commit|merge - reverts last changes
+ version - prints g2 version
+ wip/unwip - save/restore work in progress to branch"
+end
+
+function __g2_lg
+ if test (count $argv) -eq 0
+ command git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
+ else
+ command git log $argv
+ end
+end
+
+function __g2_st
+ if test (count $argv) -eq 0
+ command git status
+ else
+ command git status $argv
+ end
+end
+
+function __g2_freeze --argument-names flag msg
+ command git rev-parse; or return 1
+
+ if test "$flag" = '-m'
+ if test "$msg"
+ # remove two parameters from the left
+ if test (count $argv) -gt 2
+ set argv $argv[3..-1]
+ else
+ set argv
+ end
+ else
+ __g2_fatal 'Usage: freeze -m message'
+ end
+ end
+ begin
+ if test -z "$argv"
+ command git add -A :/
+ else
+ command git add -A $argv
+ end
+ end;
+ and if test "$msg"
+ __g2_ci -m "$msg"; and command git status -s
+ end
+ return 0
+end
+
+function __g2_unfreeze
+ command command git rev-parse; or return 1
+ if test -z "$argv"
+ if test (command git reset -q HEAD > /dev/null) -eq 1
+ __g2_fatal 'The first repo commit must be unfrozen file by file. Sorry about that...'
+ return 1
+ end
+ else
+ command git reset -q HEAD -- $argv > /dev/null; or command git rm -q --cached $argv
+ end
+ command git status
+end
+
+function __g2_ci
+ __g2_iswip; or return 1
+
+ if command git diff --cached --no-ext-diff --quiet --exit-code
+ __g2_fatal 'No changes to amend, please use <g freeze> to stage your modification, then try amending again.'
+ return 1
+ else
+ command git commit $argv
+ return $status
+ end
+end
+
+function __g2_am
+ command git rev-parse; or return 1
+
+ if command git diff --cached --no-ext-diff --quiet --exit-code
+ __g2_fatal 'No changes to amend, please use <g freeze> to stage your modification, then try amending again.'
+ return 1
+ end
+
+ if __g2_isforward
+ if test "$argv[1]" = '-f'
+ __g2_askYN 'Warning: force amending will rewrite the history, please confirm'; and return 1
+ else
+ __g2_fatal 'There are no local commits to amend.'
+ return 1
+ end
+ end
+ command git commit --amend -C HEAD
+end
+
+function __g2_cp
+ command git rev-parse; or return 1
+ __g2_iswip; or return 1
+ command git cherry-pick $argv
+end
+
+function __g2_ig
+ command git rev-parse; or return 1
+
+ if test -z "$argv"
+ __g2_info 'Usage: ignore [file]'
+ else
+ if test not -e .gitignore
+ touch .gitignore
+ end
+
+ echo "$GIT_PREFIX$argv[1]" >> .gitignore
+ __g2_info "Ignoring file $argv[1]"
+ command git rm --cached $GIT_PREFIX$argv >/dev/null ^&1
+ command git status
+ end
+end
+
+function __g2_server
+ command git config --global alias.server "daemon --verbose --export-all --base-path=.git --reuseaddr --strict-paths .git/"
+end
+
+function __g2_abort
+ command git rev-parse; or return 1
+ command git merge --abort ^ /dev/null; or command git rebase --abort ^ /dev/null
+end
+
+function __g2_continue
+
+ command git rev-parse; or return 1
+
+ switch (__g2_wrkspcState)
+
+ case rebase
+ set action '--continue'
+ command git diff-index --quiet HEAD --
+ if test $status -eq 0
+ __g2_info "The last commit brings no significant changes -- automatically skipping"
+ set action '--skip'
+ end
+ command git rebase $action ^ /dev/null
+ return 0
+
+ case merge
+ # Count the number of unmerged files
+ set count=(command git ls-files --unmerged | wc -l)
+ if [ $count -ne 0 ]
+ __g2_fatal ">>>>> Hey! you still have unmerged files, please run <g mt> to resolve conflicts"
+ return 1
+ else
+ command git commit
+ return $status
+ end
+ end
+end
+
+function __g2_panic
+ command git rev-parse; or return 1
+
+ __g2_askYN 'This action may discard all uncommited changes, are you sure'
+ if test $status -eq 1
+ __g2_abort
+ set -l g2excludes (command git config --global --get g2.panic.excludes)
+ command git reset --hard HEAD; and command git clean -fdx $g2excludes
+ set -l branch (command git rev-parse --symbolic-full-name --abbrev-ref HEAD)
+ if [ "$branch" = '(no branch)' ]
+ command git checkout master
+ end
+ end
+end
+
+function __g2_gc
+ command git rev-parse; or return 1
+
+ command git fetch --all -p
+ and command git fsck
+ and command git reflog expire --expire=now --all
+ and command git gc --aggressive --prune=now
+end
+
+function __g2_br
+ command git rev-parse; or return 1
+
+ if test (count $argv) -eq 0
+ command git branch -a
+ echo '-----------------'
+
+ command git for-each-ref --format='%(refname:short) %(upstream:short)' refs/heads | \
+ while read local remote
+ test ! "$remote"; and continue
+
+ set -l count (command git rev-list --left-right --count $local...$remote -- ^/dev/null |tr \t \n); or continue
+ __g2_info "$local (to sync:$count[1]) | (to merge:$count[2]) $remote"
+ end
+ else
+ command git branch $argv
+ end
+end
+
+# displays or generates ssh keys
+function __g2_key --argument-names opt
+
+ if test "$opt" = "-gen"
+ if test -f $HOME/.ssh/id_rsa.pub
+ __g2_askYN 'Regenerate SSH Key'; and return 1
+ end
+
+ __g2_info 'Generating SSH keys...'
+ set -l emailinput (command git config --global --get user.email)
+ command ssh-keygen -t rsa -P '' -C "$emailinput" -f "$HOME/.ssh/id_rsa"
+ end
+
+ if test -f "$HOME/.ssh/id_rsa.pub"
+ set_color yellow
+ cat "$HOME/.ssh/id_rsa.pub"
+ set_color normal
+ else
+ __g2_fatal "SSH key not found at $HOME/.ssh/id_rsa.pub"
+ return 1
+ end
+end
+
+function __g2_wip
+ command git rev-parse; or return 1
+
+ __g2_iswip
+ if test $status -eq 1
+ __g2_info "Amending previous wip commit..."
+ __g2_freeze; and command git commit --amend -C HEAD
+ else
+ __g2_freeze -m "wip"
+ end
+end
+
+function __g2_unwip
+ command git rev-parse; or return 1
+
+ __g2_iswip
+ if test $status -eq 0
+ __g2_fatal "There is nothing to unwip..."
+ else
+ if test -z (command git log -n 1 | grep -q -c "wip")
+ command git reset HEAD~1
+ end
+ end
+end
+
+function __g2_track --argument-names branch
+
+ command git rev-parse; or return 1
+ if test "$branch"
+
+ if test (echo $branch | grep -e '^[\[\]()a-zA-Z0-9\._\-]*/[\[\]()a-zA-Z0-9\._\-]*$' | wc -l) -ne 1
+ __g2_fatal "The remote branch mush be specified in the form remote/branchname."
+ return 1
+ end
+
+ if test (command git ls-remote --exit-code . "$branch" >/dev/null ^&1) -ne 0
+
+ if not __g2_askYN "Remote branch not found, would you like to refresh from the server"
+ command git fetch
+ __g2_info "Good, now try the command again";
+ return 1
+ end
+ end
+ command git branch --set-upstream-to "$branch"
+ else
+ __g2_info "--Tracking--------------"
+ set_color green
+ command git for-each-ref --format='local: %(refname:short) <--sync--> remote: %(upstream:short)' refs/heads
+ __g2_info "--Remotes---------------"
+ set_color yellow
+ command git remote -v
+ set_color normal
+ end
+end
+
+function __g2_version
+ __g2_info 'G2 is based on '(command git version)" and fish version $FISH_VERSION"
+end
+
+function __g2_rs --argument-names arg1
+
+ command git rev-parse; or return 1
+
+ if test "$arg1" = 'upstream'
+ if not __g2_askYN 'Warning: resetting to the upstream may erase local changes, are you sure'
+ __g2_abort
+ set -l remote (__g2_getremote)
+ if test "$remote"
+ __g2_info "Resetting branch to $remote"
+ command git reset --hard "$remote"
+ else
+ __g2_fatal 'Please setup tracking for this branch, for instance <g track remote/branch>'
+ end
+ end
+ else
+ command git reset $argv
+ end
+end
+
+function __g2_rb
+
+ command git rev-parse; or return 1
+
+ if test (__g2_wrkspcState) = 'false'
+ if __g2_askYN 'The branch history is about to be rewritten. It is an advanced operation, please confirm'
+ return 1
+ end
+ end
+
+ command git rebase $argv
+end
+
+function __g2_mg
+
+ command git rev-parse; or return 1
+
+ if test (__g2_isbehind) -eq 1
+ __g2_askYN 'It appears the current branch is in the past, proceed with the merge'; and return 1
+ end
+
+ # merge returns 0 when it merges correctly
+ command git merge $argv
+ if test $status -ne 0
+ set -l unmerged (command git ls-files --unmerged)
+ if test "$unmerged"
+ __g2_info 'A few files need to be merged manually, please use <g mt> to fix conflicts...'
+ __g2_info ' once all resolved, <freeze> and <commit> the files.'
+ __g2_info ' note: you may abort the merge at any time with <g abort>.'
+ end
+ return 1;
+ end
+end
+
+function __g2_co --argument-names branch
+ command git rev-parse; or return 1
+
+ # check if it's a hash
+ if test -z (echo "$branch" | grep -e '^[0-9A-Fa-f]*$')
+
+ if test (command git branch -a | grep -c "$branch") -gt 0
+ __g2_abort
+ __g2_isdirty; or return 1
+ set -l g2excludes (command git config --global --get g2.panic.excludes)
+ command git checkout $argv; and command git clean -fdx $g2excludes
+ return $status
+ end
+
+ __g2_info "There is no branch named '$branch', you may want to run <g fetch> to refresh from the server"
+ __g2_info "If you are trying to revert a file, consider <g undo $branch>"
+
+ else
+ command git checkout $argv
+ end
+ return $status
+end
+
+function __g2_add
+
+ command git rev-parse; or return 1
+ __g2_iswip; or return 1
+
+ set -l level (command git config --global --get g2.userlevel)
+ if test "$level" = 'advanced'
+ command git add $argv
+ else
+ __g2_fatal "Please don't use <add> with G2, <freeze> and <unfreeze> are powerful commands"
+ end
+
+end
+
+function __g2_undo --argument-names action
+
+ command git rev-parse; or return 1
+ if test (count $argv) -lt 1
+ __g2_fatal 'Usage : g undo <file|commit|merge> <?path>'
+ return 1
+ end
+
+ __g2_askYN 'Warning: the action may discard your changes, would you like to continue'; and return 1
+
+ switch $action
+ case commit
+ __g2_isforward
+ __g2_askYN 'It appears you already synced the changes to the server. Are you sure you want to alter the branch history'; and return 1
+ __g2_info 'Undoing last commit and moving changes to the staging area.'
+ command git reset --soft HEAD^
+
+ case merge
+ __g2_isforward
+ __g2_askYN 'It appears you already synced the changes to the server. Are you sure you want to alter the branch history'; and return 1
+ __g2_info 'Reverting back prior to the last merge.'
+ command git reset --hard ORIG_HEAD
+
+ case '*'
+ command git checkout -- $argv[1]
+ end
+end
+
+function __g2_push
+
+ command git rev-parse; or return 1
+ __g2_iswip; or return 1
+
+ # figure if the force flag is being used
+ set -l forceFlag 0
+ set -l idx 1
+ for v in $argv
+ switch $v
+ case '-f' '--force'
+ set forceFlag 1
+ set -e argv[$idx]
+ end
+ set idx (math $idx + 1)
+ end
+
+ set idx (count $argv)
+
+ if test $idx -lt 2 -a $forceFlag -eq 0
+ __g2_info 'Remember, you may only use <push> or <pull> against a feature branch, and <sync> against the working branch.'
+ __g2_fatal 'Usage: push <?opts> <remote> <branch>'
+ return 1
+ end
+
+ # read the branch
+ set -l branch $argv[$idx]
+ set -e argv[$idx]
+ set idx (math $idx - 1)
+
+ # read remote
+ set -l rmt $argv[$idx]
+ set -e argv[$idx]
+
+ set -l dst "$rmt/$branch"
+ set -l remote (__g2_getremote)
+
+ if test -z "$remote"
+ __g2_askYN "Would you like to track $dst"; or __g2_track "$dst"
+ else
+ if test $forceFlag -eq 0 -a "$dst" = "$remote"
+
+ set -l level (command git config --global --get g2.userlevel)
+ if test "$level" = 'advanced'
+ __g2_askYN "Advanced: Are you sure you want to PUSH?"; or command git pull --no-ff $argv $rmt $branch
+ else
+ __g2_fatal 'Please use <sync> to synchronize the current branch and <push> to copy to another branch'
+ return 1
+ end
+ end
+ end
+
+ if test $forceFlag -eq 1
+ command git push -f $argv $rmt $branch
+ else
+ command git push $argv $rmt $branch
+ end
+ return $status
+end
+
+# g2 pull uses the --no-ff flag
+function __g2_pull
+
+ command git rev-parse; or return 1
+ __g2_iswip; or return 1
+
+ set -l idx (count $argv)
+ if test $idx -lt 2
+ __g2_fatal 'Usage: pull <?opts> <remote> <branch>'
+ return 1
+ end
+
+ # read the branch
+ set -l branch $argv[$idx]
+ set -e argv[$idx]
+ set idx (math $idx - 1)
+
+ # read remote
+ set -l rmt $argv[$idx]
+ set -e argv[$idx]
+ set -l dst "$rmt/$branch"
+ set -l remote (__g2_getremote)
+
+ if test -z "$remote"
+ __g2_askYN "Would you like to track $dst"; or __g2_track "$dst"
+ else
+ if test "$dst" = "$remote"
+ set -l level (command git config --global --get g2.userlevel)
+ if test "$level" = 'advanced'
+ __g2_askYN "Advanced: Are you sure you want to PULL?"; or command git pull --no-ff $argv $rmt $branch
+ else
+ __g2_fatal 'Please use <sync> to synchronize the current branch and <pull> to merge a feature branch'
+ return 1
+ end
+ end
+ end
+
+ command git pull --no-ff $argv $rmt $branch
+ return $status
+end
+
+# Performs a fetch, rebase, push with a bunch of validations
+function __g2_sync --argument-names flag
+
+ command git rev-parse; or return 1
+ __g2_iswip; or return 1
+ __g2_isdirty; or return 1
+
+ set -l pullOnly 0
+ if test "$flag" = "--pull-only"
+ set pullOnly 1
+ set -e argv[1]
+ end
+
+ if test (count $argv) -gt 0
+ __g2_info 'Remember, you may only use <sync> against the working branch, use <pull> or <push> for feature branches.'
+ __g2_fatal 'Usage: sync <?--pull-only>'
+ return 1
+ end
+
+ set -l remote (__g2_getremote)
+ if test -z "$remote"
+ __g2_fatal 'Please use <g track remote/branch> to setup branch tracking'
+ return 1
+ end
+
+ command git fetch; or return $status
+
+ if not __g2_isforced $remote
+ __g2_fatal 'It appears the history of the branch was changed on the server.'
+ __g2_fatal 'please issue <g reset upstream> or <g rebase $remote> to resume'
+ return 1
+ end
+
+ set -l branch (command git rev-parse --symbolic-full-name --abbrev-ref HEAD)
+
+ # count the number of changes in/out
+ set -l tmpfile "/tmp/delta$RANDOM"
+ command git rev-list --left-right "$branch...$remote" -- ^ /dev/null > "$tmpfile"
+ set -l lchg (grep -c '^<' "$tmpfile");
+ set -l rchg (grep -c '^>' "$tmpfile");
+ rm -f "$tmpfile"
+
+ if test $rchg -gt 0
+ command git rebase $remote;
+ else
+ set unmerged (command git ls-files --unmerged)
+ if test "$unmerged"
+ __g2_info "A few files need to be merged manually, please use <g mt> to fix conflicts."
+ __g2_info " Once all conflicts are resolved, do NOT commit, but use <g continue> to resume."
+ __g2_info " Note: you may abort the merge at any time with <g abort>."
+ return 1;
+ end
+ end
+
+ if test $pullOnly -eq 0 -a \( $rchg -gt 0 -o $lchg -gt 0 \)
+ command git push
+ return $status
+ end
+ return 0;
+end
+
+function __g2_mg
+
+ command git rev-parse; or return 1
+ __g2_iswip; or return 1
+
+ if not __g2_isbehind
+ __g2_askYN "It appears the current branch is in the past, proceed with the merge"; and return 1
+ end
+
+ # merge returns 0 when it merges correctly
+
+ if command git merge $argv
+ set -l unmerged (command git ls-files --unmerged)
+ if test $unmerged
+ __g2_info "A few files need to be merged manually, please use <g mt> to fix conflicts..."
+ __g2_info " once all resolved, <g freeze> and <g commit> the files."
+ __g2_info " note: you may abort the merge at any time with <g abort> ."
+ end
+ retrun 1
+ end
+end
+
+function __g2_setup
+
+ __g2_info "-----------------------------------------------------"
+ __g2_info " G2 setup, press <ENTER> to select the default value"
+ __g2_info "-----------------------------------------------------"
+
+ ## USER NAME
+ set -l default (command git config --global --get user.name)
+ set -l nameinput (__g2_askInput "Please input your full name" "$default" false)
+ command git config --global user.name "$nameinput"
+
+ ## EMAIL
+ __g2_info "-----------------------------------------------------"
+ set -l default (command git config --global --get user.email)
+ set -l emailinput (__g2_askInput "Please input your email" "$default" true)
+ command git config --global user.email "$emailinput"
+
+ ## EDITOR
+ __g2_info "-----------------------------------------------------"
+ set -l default (command git config --global --get core.editor)
+ test ! "$default"; and set default vi
+ set -l editor (__g2_askInput "Preferred Editor" "$default" false)
+ command git config --global core.editor "$editor"
+
+ ## EXCLUDE FILES
+ __g2_info "-----------------------------------------------------"
+ set -l default (command git config --global --get g2.panic.excludes)
+ test ! "$default"; and set default "-e .classpath -e .settings -e *.iml"
+ set -l g2excludes (__g2_askInput 'Pattern of files to keep untouched' "$default" false)
+ command git config --global g2.panic.excludes "$g2excludes"
+
+ ## DIFFTOOL
+ __g2_info "-----------------------------------------------------"
+ set -l difftools "difftools araxis bc3 diffuse emerge ecmerge gvimdiff kdiff3 kompare meld opendiff p4merge tkdiff vimdiff xxdiff deltawalker"
+ set -l default_dt (command git config diff.tool)
+ set -l choice (__g2_askChoice 'Please select a difftool' "$difftools" "$default_dt" true)
+ command git config --global diff.tool "$choice"
+
+ ## MERGETOOL
+ __g2_info "-----------------------------------------------------"
+ set -l mergetools "difftools araxis bc3 diffuse emerge ecmerge gvimdiff kdiff3 kompare meld opendiff p4merge tkdiff vimdiff xxdiff deltawalker"
+ set -l default_mt (command git config merge.tool)
+ set -l choice (__g2_askChoice 'Please select a mergetool' "$mergetools" "$default_mt" true)
+ command git config --global merge.tool "$choice"
+
+ ## TRUST EXIT CODE
+ __g2_info "-----------------------------------------------------"
+ set -l default (command git config mergetool.$choice.trustExitCode)
+ test ! $default; and set default false
+ set -l existCode (__g2_askInput "Trust mergetool exit code?" "$default" false)
+ command git config --global mergetool.$choice.trustExitCode $existCode
+
+ ## COLOR
+ command git config --global color.branch auto
+ command git config --global color.diff auto
+ command git config --global color.interactive auto
+ command git config --global color.status auto
+
+ # FIX A FEW OTHER SETTINGS
+
+ # For windows, use these default settings
+ if test (uname -a | grep -c MINGW) -eq 1
+ command git config --global core.autocrlf true
+ command git config --global core.symlinks false
+ command git config --global pack.packSizeLimit 2g
+ else
+ command git config --global core.autocrlf input
+ end
+
+ command git config --global core.safecrlf warn
+ command git config --global push.default current
+ command git config --global mergetool.keepBackup false
+
+ __g2_info "-----------------------------------------------------"
+ __g2_info "For the prompt to display correctly, remember to have"
+ __g2_info " your terminal use a Powerline-patched font."
+ __g2_info "Sample Powerline-p fonts can be downloaded from"
+ __g2_info " https://github.com/Lokaltog/powerline-fonts"
+ __g2_info "-----------------------------------------------------"
+
+ ## SSH KEY
+ __g2_key -gen
+
+end
+
+function g
+ if test (count $argv) -eq 0
+ __g2_usage;
+ else
+ set -l CMDS "abort"\
+ "add"\
+ "am"\
+ "br"\
+ "branch"\
+ "bs"\
+ "bisect"\
+ "clone"\
+ "ci"\
+ "commit"\
+ "co"\
+ "checkout"\
+ "continue"\
+ "cp"\
+ "cherry-pick"\
+ "df"\
+ "diff"\
+ "dt"\
+ "difftool"\
+ "fetch"\
+ "freeze"\
+ "gc"\
+ "gp"\
+ "grep"\
+ "gui"\
+ "help"\
+ "ig"\
+ "init"\
+ "key"\
+ "lg"\
+ "log"\
+ "ls"\
+ "ls-files"\
+ "mg"\
+ "merge"\
+ "mt"\
+ "mergetool"\
+ "mv"\
+ "panic"\
+ "pull"\
+ "push"\
+ "rb"\
+ "rebase"\
+ "refresh"\
+ "rt"\
+ "remote"\
+ "rm"\
+ "rs"\
+ "reset"\
+ "rv"\
+ "revert"\
+ "setup"\
+ "server"\
+ "sh"\
+ "show"\
+ "sm"\
+ "submodule"\
+ "ss"\
+ "stash"\
+ "st"\
+ "status"\
+ "sync"\
+ "tg"\
+ "tag"\
+ "track"\
+ "undo"\
+ "unfreeze"\
+ "unwip"\
+ "version"\
+ "wip";
+
+ set -l arg1 $argv[1]
+
+ for i in $CMDS
+
+ if test "$i" = "$arg1"
+
+ # strip the first argument, if any
+ set -e argv[1]
+
+ # fish and eval doen't play well together, the following does work well with builtin functions
+ # eval $CMDS[(math $i+1)] '$argv'
+
+ switch $i
+ case abort
+ __g2_abort
+ case add
+ __g2_add
+ case am
+ __g2_am $argv
+ case br branch
+ __g2_br $argv
+ case bs bisect
+ command git bisect $argv
+ case clone
+ command git clone $argv
+ case ci commit
+ __g2_ci $argv
+ case co checkout
+ __g2_co $argv
+ case continue
+ __g2_continue
+ case cp cherry-pick
+ __g2_cp $argv
+ case df diff
+ command git diff $argv
+ case dt difftool
+ command git difftool $argv
+ case fetch
+ command git fetch $argv
+ case freeze
+ __g2_freeze $argv
+ case gc
+ __g2_gc
+ case gp grep
+ command git grep $argv
+ case gui
+ command git gui $argv
+ case help
+ command git help $argv
+ case ig
+ __g2_ig $argv
+ case init
+ command git init $argv
+ case key
+ __g2_key $argv
+ case lg log
+ __g2_lg $argv
+ case ls ls-files
+ command git ls-files $argv
+ case mg merge
+ __g2_mg $argv
+ case mt mergetool
+ command git mergetool $argv
+ case mv
+ command git mv $argv
+ case panic
+ __g2_panic
+ case pull
+ __g2_pull $argv
+ case push
+ __g2_push $argv
+ case rb rebase
+ __g2_rb $argv
+ case refresh
+ __g2_refresh
+ case rt remote
+ command git remote $argv
+ case rm
+ command git rm $argv
+ case rs reset
+ __g2_rs $argv
+ case rv revert
+ __g2_rv $argv
+ case setup
+ __g2_setup
+ case server
+ __g2_server
+ case sh show
+ command git show $argv
+ case sm submodule
+ command git submodule $argv
+ case ss stash
+ command git stash $argv
+ case st status
+ __g2_st $argv
+ case sync
+ __g2_sync $argv
+ case tg tag
+ command git tag $argv
+ case track
+ __g2_track $argv
+ case undo
+ __g2_undo $argv
+ case unfreeze
+ __g2_unfreeze $argv
+ case unwip
+ __g2_unwip
+ case version
+ __g2_version
+ case wip
+ __g2_wip
+ case '*'
+ __g2_fatal "Action $i not implemented"
+ return 1
+ end
+ return $status
+ end
+ end
+
+ __g2_usage
+ __g2_fatal "Invalid g2 command!"
+ return 1
+
+ end
+end
+
+set GIT_EXE (which git)
+test ! "$GIT_EXE"; and __g2_fatal "Sorry, git is a required G2 dependency and must be in the PATH"
+set -x GIT_EXE
View
143 fish/test.fish
@@ -0,0 +1,143 @@
+#### PARSE STATUS
+set -l untracked 0
+set -l added 0