command = "git" [[match_err]] pattern = [ "is not a git command" ] suggest = [ ''' #[err_contains(the most similar command is)] {{command[0]}} {{err::(?:the most similar command is )(\S+)}} {{command[2:]}}''', ''' #[!err_contains(the most similar command is)] {{command[0]}} {{typo[1]( add, am, archive, bisect, branch, bundle, checkout, cherry-pick, citool, clean, clone, commit, describe, diff, fetch, format-patch, gc, gitk, grep, gui, init, log, maintenance, merge, mv, notes, pull, push, range-diff, rebase, reset, restore, revert, rm, scalar, shortlog, show, sparse-checkout, stash, status, submodule, switch, tag, worktree, config, fast-export, fast-import, filter-branch, mergetool, pack-refs, prune, reflog, remote, repack, replace, )}} {{command[2:]}}''' ] [[match_err]] pattern = [ "did not match any file" ] suggest = [ ''' #[cmd_contains(checkout)] git checkout {{typo[2]({{shell(git branch | sed 's/^*//')}})}} ''', ''' #[cmd_contains(checkout)] git branch {{command[2]}} && \ git checkout {{command[2]}} ''' ] [[match_err]] pattern = [ "has no upstream branch" ] suggest = [ ''' #[cmd_contains(push)] git push --set-upstream origin {{shell(git rev-parse --abbrev-ref HEAD)}} ''' ] [[match_err]] pattern = [ "no tracking information for the current branch" ] suggest = [ ''' #[cmd_contains(pull)] git pull --set-upstream origin {{shell(git rev-parse --abbrev-ref HEAD)}} ''' ] [[match_err]] pattern = [ "a branch named" ] suggest = [ ''' #[cmd_contains(branch)] git checkout {{command[2]}} ''' ] [[match_err]] pattern = [ "updates were rejected" ] suggest = [ ''' #[cmd_contains(push)] git pull && \ {{command}} ''', ''' #[cmd_contains(push)] {{command}} --force ''' ] [[match_err]] pattern = [ "you have unstaged changes", "stash them" ] suggest = [ ''' #[cmd_contains(pull)] {{command}} --rebase --autostash ''', ''' git stash && \ {{command}} && \ git stash pop ''' ] [[match_err]] pattern = [ "you have divergent branches and need to specify how to reconcile them" ] suggest = [ ''' #[cmd_contains(pull)] {{command}} --rebase ''', ''' #[cmd_contains(pull)] {{command}} --merge ''' ]