refactor: update git trigger

This commit is contained in:
Danilo Cesa 2026-05-20 08:54:23 +08:00
parent 6b20c727c0
commit 3c46e21b34
3 changed files with 57 additions and 75 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.DS_Store

BIN
match/.DS_Store vendored

Binary file not shown.

View File

@ -1,21 +1,20 @@
# Git Snippets for Espanso # Git Snippets for Espanso
matches: matches:
# === BASIC COMMANDS === # === BASIC COMMANDS ===
# Git init # Git init
- trigger: "}ginit" - trigger: "}giti"
replace: "git init" replace: "git init"
# Git clone # Git clone
- trigger: "}gclone" - trigger: "}gitcl"
replace: "git clone $1$" replace: "git clone $1$"
# Git status # Git status
- trigger: "}gst" - trigger: "}gits"
replace: "git status" replace: "git status"
# Git add # Git add
- trigger: "}ga" - trigger: "}gita"
# replace: "git add $1$" # replace: "git add $1$"
vars: vars:
- name: "dot" - name: "dot"
@ -33,19 +32,19 @@ matches:
replace: "git add {{dot}}{{file}}" replace: "git add {{dot}}{{file}}"
# Git commit # Git commit
- trigger: "}gcs" - trigger: "}gitc"
replace: 'git commit -m "$|$"' replace: 'git commit -m "$|$"'
# Git commit with amend # Git commit with amend
- trigger: "}gca" - trigger: "}gitcam"
replace: 'git commit --amend -m "$|$"' replace: 'git commit --amend -m "$|$"'
# Git commit all # Git commit all
- trigger: "}gcaa" - trigger: "}gitcal"
replace: 'git commit -am "$|$"' replace: 'git commit -am "$|$"'
# Git push # Git push
- trigger: "}gp" - trigger: "}gitp"
#replace: "git push $1$ $2$" #replace: "git push $1$ $2$"
vars: vars:
- name: "option" - name: "option"
@ -63,10 +62,11 @@ matches:
- "origin main" - "origin main"
- "origin master" - "origin master"
- "origin HEAD" - "origin HEAD"
- "origin development"
replace: "git push {{option}} {{remote_branch}}" replace: "git push {{option}} {{remote_branch}}"
# Git pull # Git pull
- trigger: "}gl" - trigger: "}gitpl"
#replace: "git pull $1$ $2$" #replace: "git pull $1$ $2$"
vars: vars:
- name: "option" - name: "option"
@ -82,10 +82,12 @@ matches:
- "" - ""
- "origin main" - "origin main"
- "origin master" - "origin master"
- "origin HEAD"
- "origin development"
replace: "git pull {{option}} {{remote_branch}}" replace: "git pull {{option}} {{remote_branch}}"
# Git fetch # Git fetch
- trigger: "}gf" - trigger: "}gitf"
# replace: "git fetch $1$" # replace: "git fetch $1$"
vars: vars:
- name: "remote" - name: "remote"
@ -98,11 +100,11 @@ matches:
replace: "git fetch {{remote}}" replace: "git fetch {{remote}}"
# Git log # Git log
- trigger: "}glg" - trigger: "}gitlg"
replace: "git log --oneline --graph --all" replace: "git log --oneline --graph --all"
# Git diff # Git diff
- trigger: "}gd" - trigger: "}gitdf"
#replace: "git diff $1$" #replace: "git diff $1$"
vars: vars:
- name: "option" - name: "option"
@ -115,7 +117,7 @@ matches:
replace: "git diff {{option}}" replace: "git diff {{option}}"
# Git checkout # Git checkout
- trigger: "}gco" - trigger: "}gitco"
#replace: "git checkout $1$" #replace: "git checkout $1$"
vars: vars:
- name: "what" - name: "what"
@ -132,11 +134,11 @@ matches:
- "$|$" - "$|$"
- "main" - "main"
- "master" - "master"
- "develop" - "development"
replace: "git checkout {{what}}{{target}}" replace: "git checkout {{what}}{{target}}"
# Git branch # Git branch
- trigger: "}gb" - trigger: "}gitb"
#replace: "git branch $1$" #replace: "git branch $1$"
vars: vars:
- name: "option" - name: "option"
@ -156,10 +158,12 @@ matches:
- "feature/" - "feature/"
- "bugfix/" - "bugfix/"
- "hotfix/" - "hotfix/"
- "chore/"
- "test/"
replace: "git branch {{option}}{{branch}}" replace: "git branch {{option}}{{branch}}"
# Git merge # Git merge
- trigger: "}gm" - trigger: "}gitm"
#replace: "git merge $1$" #replace: "git merge $1$"
vars: vars:
- name: "option" - name: "option"
@ -177,11 +181,11 @@ matches:
- "$|$" - "$|$"
- "main" - "main"
- "master" - "master"
- "develop" - "development"
replace: "git merge {{option}}{{branch}}" replace: "git merge {{option}}{{branch}}"
# Git rebase # Git rebase
- trigger: "}gr" - trigger: "}gitr"
#replace: "git rebase $1$" #replace: "git rebase $1$"
vars: vars:
- name: "option" - name: "option"
@ -201,10 +205,12 @@ matches:
- "main" - "main"
- "master" - "master"
- "HEAD~3" - "HEAD~3"
- "development"
- "staging"
replace: "git rebase {{option}}{{target}}" replace: "git rebase {{option}}{{target}}"
# Git stash # Git stash
- trigger: "}gstash" - trigger: "}gitsah"
#replace: "git stash $1$" #replace: "git stash $1$"
vars: vars:
- name: "option" - name: "option"
@ -216,10 +222,12 @@ matches:
- "pop" - "pop"
- "list" - "list"
- "drop" - "drop"
- "apply"
- "--include-untracked"
replace: "git stash {{option}}" replace: "git stash {{option}}"
# Git remote # Git remote
- trigger: "}gr" - trigger: "}gitr"
#replace: "git remote $1$" #replace: "git remote $1$"
vars: vars:
- name: "option" - name: "option"
@ -238,7 +246,7 @@ matches:
replace: "git remote {{option}}{{url}}" replace: "git remote {{option}}{{url}}"
# Git reset # Git reset
- trigger: "}greset" - trigger: "}gitrst"
#replace: "git reset $1$ $2$" #replace: "git reset $1$ $2$"
vars: vars:
- name: "mode" - name: "mode"
@ -259,7 +267,7 @@ matches:
replace: "git reset {{mode}}{{target}}" replace: "git reset {{mode}}{{target}}"
# Git clean # Git clean
- trigger: "}gclean" - trigger: "}gitcln"
#replace: "git clean -fd $1$" #replace: "git clean -fd $1$"
vars: vars:
- name: "dry" - name: "dry"
@ -271,7 +279,7 @@ matches:
replace: "git clean -fd{{dry}}" replace: "git clean -fd{{dry}}"
# Git show # Git show
- trigger: "}gshow" - trigger: "}gitshow"
#replace: "git show $1$" #replace: "git show $1$"
vars: vars:
- name: "ref" - name: "ref"
@ -285,7 +293,7 @@ matches:
replace: "git show {{ref}}" replace: "git show {{ref}}"
# Git cherry-pick # Git cherry-pick
- trigger: "}gcp" - trigger: "}gitcp"
#replace: "git cherry-pick $1$" #replace: "git cherry-pick $1$"
vars: vars:
- name: "option" - name: "option"
@ -306,7 +314,7 @@ matches:
replace: "git cherry-pick {{option}}{{commit}}" replace: "git cherry-pick {{option}}{{commit}}"
# Git revert # Git revert
- trigger: "}grev" - trigger: "}gitrev"
#replace: "git revert $1$" #replace: "git revert $1$"
vars: vars:
- name: "commit" - name: "commit"
@ -320,7 +328,7 @@ matches:
replace: "git revert {{commit}}" replace: "git revert {{commit}}"
# Git bisect # Git bisect
- trigger: "}gbisect" - trigger: "}gitbst"
#replace: "git bisect $1$" #replace: "git bisect $1$"
vars: vars:
- name: "action" - name: "action"
@ -335,7 +343,7 @@ matches:
replace: "git bisect {{action}}" replace: "git bisect {{action}}"
# Git blame # Git blame
- trigger: "}gblame" - trigger: "}gitblame"
#replace: "git blame $1$" #replace: "git blame $1$"
vars: vars:
- name: "file" - name: "file"
@ -347,12 +355,12 @@ matches:
replace: "git blame {{file}}" replace: "git blame {{file}}"
# Git reflog # Git reflog
- trigger: "}grl" - trigger: "}gitrl"
#replace: "git reflog" #replace: "git reflog"
replace: "git reflog" replace: "git reflog"
# Git config # Git config
- trigger: "}gconf" - trigger: "}gitconf"
#replace: "git config --global $1$ $2$" #replace: "git config --global $1$ $2$"
vars: vars:
- name: "key" - name: "key"
@ -376,7 +384,7 @@ matches:
# === COMMIT MESSAGE CONVENTIONS === # === COMMIT MESSAGE CONVENTIONS ===
# Conventional Commits # Conventional Commits
- trigger: "}gcc" - trigger: "}gitcc"
vars: vars:
- name: "type" - name: "type"
type: "choice" type: "choice"
@ -404,44 +412,17 @@ matches:
replace: "{{type}}{{scope}}: " replace: "{{type}}{{scope}}: "
# Fix typo in commit # Fix typo in commit
- trigger: "}gfix" - trigger: "}gitfix"
replace: "fixup! $|$" replace: "fixup! $|$"
# Squash commit # Squash commit
- trigger: "}gsquash" - trigger: "}gitsquash"
replace: "squash! $|$" replace: "squash! $|$"
# === BRANCH NAMING CONVENTIONS === # === BRANCH NAMING CONVENTIONS ===
# Feature branch
- trigger: "}gbf"
replace: "feature/$|$-{{mydate}}"
vars:
- name: "mydate"
type: "date"
params:
format: "%Y-%m-%d"
# Bugfix branch
- trigger: "}gbb"
replace: "bugfix/$|$-{{mydate}}"
vars:
- name: "mydate"
type: "date"
params:
format: "%Y-%m-%d"
# Hotfix branch
- trigger: "}gbh"
replace: "hotfix/$|$-{{mydate}}"
vars:
- name: "mydate"
type: "date"
params:
format: "%Y-%m-%d"
# Release branch # Release branch
- trigger: "}gbr" - trigger: "}gitbr"
replace: "release/v$1$.$2$.$3$" replace: "release/v$1$.$2$.$3$"
vars: vars:
- name: "major" - name: "major"
@ -460,7 +441,7 @@ matches:
# === TROUBLESHOOTING === # === TROUBLESHOOTING ===
# Discard local changes (CAREFUL!) # Discard local changes (CAREFUL!)
- trigger: "}gdc" - trigger: "}gitdc"
replace: "git checkout -- $1$" replace: "git checkout -- $1$"
vars: vars:
- name: "file" - name: "file"
@ -472,44 +453,44 @@ matches:
- "<filename>" - "<filename>"
# Undo last commit (keep changes) # Undo last commit (keep changes)
- trigger: "}gundo" - trigger: "}gitundo"
replace: "git reset --soft HEAD~1" replace: "git reset --soft HEAD~1"
# Undo last commit (discard changes) # Undo last commit (discard changes)
- trigger: "}gundohard" - trigger: "}gitundohard"
replace: "git reset --hard HEAD~1" replace: "git reset --hard HEAD~1"
# Remove untracked files (CAREFUL!) # Remove untracked files (CAREFUL!)
- trigger: "}grmuntracked" - trigger: "}gitrmuntracked"
replace: "git clean -fd" replace: "git clean -fd"
# See what branch you're on # See what branch you're on
- trigger: "}gcurrbranch" - trigger: "}gitcurrbranch"
replace: "git branch --show-current" replace: "git branch --show-current"
# List all branches with last commit # List all branches with last commit
- trigger: "}gbrl" - trigger: "}gitbrl"
replace: "git branch -vva" replace: "git branch -vva"
# Find deleted branches # Find deleted branches
- trigger: "}gbrd" - trigger: "}gitbrd"
replace: "git branch --merged | egrep -v \"(^\\*|main|master|develop)\"" replace: "git branch --merged | egrep -v \"(^\\*|main|master|develop)\""
# === GIT IGNORE === # === GIT IGNORE ===
# Add to .gitignore # Add to .gitignore
- trigger: "gignore" - trigger: "}gitignore"
replace: 'echo "$1$" >> .gitignore' replace: 'echo "$1$" >> .gitignore'
# Common .gitignore entries # Common .gitignore entries
- trigger: "ignode" - trigger: "}gitignode"
replace: "node_modules/\n.env\nnpm-debug.log" replace: "node_modules/\n.env\nnpm-debug.log"
- trigger: "igpython" - trigger: "}gitpython"
replace: "__pycache__/\n*.pyc\n.env\nvenv/\n.venv/\n*.egg-info/" replace: "__pycache__/\n*.pyc\n.env\nvenv/\n.venv/\n*.egg-info/"
- trigger: "igidea" - trigger: "}gitidea"
replace: ".idea/\n*.iml\n.vscode/\n.DS_Store" replace: ".idea/\n*.iml\n.vscode/\n.DS_Store"
- trigger: "igbuild" - trigger: "}gitbuild"
replace: "dist/\nbuild/\n*.o\n*.obj\n*.exe\n*.dll\n*.so\n*.dylib" replace: "dist/\nbuild/\n*.o\n*.obj\n*.exe\n*.dll\n*.so\n*.dylib"