From 6b20c727c0eb5f6633607ee42050bcc3cacc094d Mon Sep 17 00:00:00 2001 From: Danilo Cesa Date: Tue, 19 May 2026 00:33:39 +0800 Subject: [PATCH] feat: Initial commit --- config/default.yml | 53 +++++ match/.DS_Store | Bin 0 -> 6148 bytes match/base.yml | 40 ++++ match/docker.yml | 249 ++++++++++++++++++++++ match/git.yml | 515 +++++++++++++++++++++++++++++++++++++++++++++ match/sql.yml | 160 ++++++++++++++ 6 files changed, 1017 insertions(+) create mode 100644 config/default.yml create mode 100644 match/.DS_Store create mode 100644 match/base.yml create mode 100644 match/docker.yml create mode 100644 match/git.yml create mode 100644 match/sql.yml diff --git a/config/default.yml b/config/default.yml new file mode 100644 index 0000000..7f9ee7d --- /dev/null +++ b/config/default.yml @@ -0,0 +1,53 @@ +# espanso configuration file + +# yaml-language-server: $schema=https://raw.githubusercontent.com/espanso/espanso/dev/schemas/config.schema.json + +# For a complete introduction, visit the official docs at: https://espanso.org/docs/ + +# You can use this file to define the global configuration options for espanso. +# These are the parameters that will be used by default on every application, +# but you can also override them on a per-application basis. + +# To make customization easier, this file contains some of the commonly used +# parameters. Feel free to uncomment and tune them to fit your needs! + +# --- Toggle key + +# Customize the key used to disable and enable espanso (when double tapped) +# Available options: CTRL, SHIFT, ALT, CMD, OFF +# You can also specify the key variant, such as LEFT_CTRL, RIGHT_SHIFT, etc... +# toggle_key: ALT +# You can also disable the toggle key completely with +# toggle_key: OFF + +# --- Injection Backend + +# Espanso supports multiple ways of injecting text into applications. Each of +# them has its quirks, therefore you may want to change it if you are having problems. +# By default, espanso uses the "Auto" backend which should work well in most cases, +# but you may want to try the "Clipboard" or "Inject" backend in case of issues. +# backend: Clipboard + +# --- Auto-restart + +# Enable/disable the config auto-reload after a file change is detected. +# auto_restart: false + +# --- Clipboard threshold + +# Because injecting long texts char-by-char is a slow operation, espanso automatically +# uses the clipboard if the text is longer than 'clipboard_threshold' characters. +# clipboard_threshold: 100 + +# --- Regex Buffer Size + +# The maximum number of characters to hold in memory for regex triggers. +# This value determines the maximum length of a regex trigger that can be +# matched by espanso and by default have 30 chars. +# It's advisable to keep this value reasonably low. +# You might want to increase this value if you have very long triggers, +# at the cost of higher memory usage. +# max_regex_buffer_size: 30 + +# For a list of all the available options, visit the official docs at: https://espanso.org/docs/ +search_shortcut: ALT+SHIFT+SPACE diff --git a/match/.DS_Store b/match/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..404efbf7d3aa1a1299d19c1fccca39ab024b6fda GIT binary patch literal 6148 zcmeHKISv9b477n_B^pY~e1RWC2wuPkI7I;xNQizb-o?`x9|dTkg9eQyXA;MgC{wK0 zBBImlb|Nwokp^xkHygTU`{o_%Wki8+oUxLu7m_W|QJat3oFhiCr!bUNB5 zjS5f!DnJFO02TPE0$E<0;a5-PVN`$${DT7aeJF6ln%D;Vrvrnx0KfslZkT&70W1~( z*2Fdt5ts%Q7*x#`LxYZZ$-J7_1_oU;n-9&KH9Hjb+i`yJbkQ2fkqS_OR|Wd999jLJ z!$0)@uOzOh02TNv1#~c5%%*r!*4EDBtkxFz5^gznxEbb7!QkZ>=;as-E5~C`io9ZT X?AOFL(CLUf9mt;n(}hL_eyzX*+7K0P literal 0 HcmV?d00001 diff --git a/match/base.yml b/match/base.yml new file mode 100644 index 0000000..acc7123 --- /dev/null +++ b/match/base.yml @@ -0,0 +1,40 @@ +# espanso match file + +# For a complete introduction, visit the official docs at: https://espanso.org/docs/ + +# You can use this file to define the base matches (aka snippets) +# that will be available in every application when using espanso. + +# Matches are substitution rules: when you type the "trigger" string +# it gets replaced by the "replace" string. + +# yaml-language-server: $schema=https://raw.githubusercontent.com/espanso/espanso/dev/schemas/match.schema.json + +matches: + # Simple text replacement + - trigger: ":espanso" + replace: "Hi there!" + + # NOTE: espanso uses YAML to define matches, so pay attention to the indentation! + + # But matches can also be dynamic: + + # Print the current date + - trigger: ":date" + replace: "{{mydate}}" + vars: + - name: mydate + type: date + params: + format: "%m/%d/%Y" + + # Print the output of a shell command + - trigger: ":shell" + replace: "{{output}}" + vars: + - name: output + type: shell + params: + cmd: "echo 'Hello from your shell'" + + # And much more! For more information, visit the docs: https://espanso.org/docs/ \ No newline at end of file diff --git a/match/docker.yml b/match/docker.yml new file mode 100644 index 0000000..13b36a1 --- /dev/null +++ b/match/docker.yml @@ -0,0 +1,249 @@ +# Docker Snippets for Espanso +matches: + # === Core Docker Commands === + - trigger: "}dckr" + replace: "docker run $1$ $2$ $3$ $4$" + vars: + - name: image + type: choice + params: + values: ["$|$", "nginx", "postgres:15", "redis:alpine", "node:20"] + - name: mode + type: choice + params: + values: ["", "-d", "-it"] + - name: ports + type: choice + params: + values: ["", "-p 8080:80", "-p 3000:3000", "-p 5432:5432"] + - name: volumes + type: choice + params: + values: + ["", "-v $(pwd):/app", "-v ~/data:/var/lib/postgresql/data", ""] + + - trigger: "}dckb" + replace: "docker build -t $1$ $2$" + vars: + - name: tag + type: choice + params: + values: ["$|$", "my-app:v1", "my-app:latest"] + - name: context + type: choice + params: + values: [".", "/path/to/build/context", ""] + + - trigger: "}dckp" + replace: "docker push $1$" + vars: + - name: image + type: choice + params: + values: ["$|$", "my-app:v1", "registry.example.com/my-app:latest"] + + - trigger: "}dckpl" + replace: "docker pull $1$" + vars: + - name: image + type: choice + params: + values: ["$|$", "nginx:latest", "postgres:15-alpine"] + + - trigger: "}dckps" + replace: "docker ps $1$" + vars: + - name: option + type: choice + params: + values: + ["", "-a", "--format \"table {{.Names}}\t{{.Image}}\t{{.Ports}}\""] + + - trigger: "}dckim" + replace: "docker images" + + - trigger: "}dckstop" + replace: "docker stop $1$" + vars: + - name: target + type: choice + params: + values: ["$|$", "", "$(docker ps -q)"] + + - trigger: "}dckstopa" + replace: "docker stop $(docker ps -q)" + label: Stop ALL running containers (use with caution!) + + - trigger: "}dckrm" + replace: "docker rm $1$" + vars: + - name: target + type: choice + params: + values: ["$|$", "", "$(docker ps -aq)"] + + - trigger: "}dckrmi" + replace: "docker rmi $1$" + vars: + - name: target + type: choice + params: + values: ["$|$", "", "$(docker images -q)"] + + - trigger: "}dcklog" + replace: "docker logs -f $1$" + vars: + - name: container + type: choice + params: + values: ["$|$", ""] + + - trigger: "}dckex" + replace: "docker exec -it $1$ $2$" + vars: + - name: container + type: choice + params: + values: ["$|$", ""] + - name: command + type: choice + params: + values: ["sh", "bash", "/bin/bash", ""] + + - trigger: "}dckprune" + replace: "docker system prune -f" + + - trigger: "}dckpruneall" + replace: "docker system prune -a --volumes -f" + label: Remove ALL unused Docker resources (irreversible!) + + - trigger: "}dckinspect" + replace: "docker inspect $1$" + vars: + - name: target + type: choice + params: + values: ["$|$", "", ""] + + # === Docker Compose Commands === + - trigger: "}dckcu" + replace: "docker compose up $1$ $2$" + vars: + - name: option + type: choice + params: + values: ["", "-d", "--build"] + - name: service + type: choice + params: + values: ["$|$", "", "web", "db", "redis"] + + - trigger: "}dckcd" + replace: "docker compose down $1$" + vars: + - name: option + type: choice + params: + values: ["", "--volumes", "--rmi all"] + + - trigger: "}dckcl" + replace: "docker compose logs -f $1$" + vars: + - name: service + type: choice + params: + values: ["$|$", "web", "db", ""] + + - trigger: "}dckex" + replace: "docker compose exec $1$ $2$" + vars: + - name: service + type: choice + params: + values: ["$|$", "web", "db"] + - name: command + type: choice + params: + values: ["sh", "bash", "python manage.py migrate", ""] + + - trigger: "}dckcb" + replace: "docker compose build $1$" + vars: + - name: service + type: choice + params: + values: ["$|$", "web", "db", ""] + + # === Dockerfile Snippets === + - trigger: "}dckfile" + replace: | + FROM $1$ + WORKDIR /app + COPY . . + RUN $2$ + EXPOSE 80 + CMD ["$3$"] + vars: + - name: base_image + type: choice + params: + values: ["$|$", "alpine:latest", "ubuntu:22.04"] + - name: install_cmd + type: choice + params: + values: + [ + "apt update && apt install -y ", + "apk add --no-cache ", + "pip install -r requirements.txt", + "", + ] + - name: start_cmd + type: choice + params: + values: + ["nginx -g 'daemon off;'", "python app.py", "node server.js", ""] + + - trigger: "}dckfile-node" + replace: | + FROM node:20-alpine + WORKDIR /app + COPY package*.json ./ + RUN npm ci + COPY . . + EXPOSE 3000 + CMD ["npm", "start"] + + - trigger: "}dckfile-py" + replace: | + FROM python:3.11-slim + WORKDIR /app + COPY requirements.txt . + RUN pip install --no-cache-dir -r requirements.txt + COPY . . + EXPOSE 8000 + CMD ["python", "app.py"] + + # === Common Config Snippets === + - trigger: "}dckignore" + replace: | + .git + node_modules + .env + *.log + Dockerfile + .dockerignore + dist/ + build/ + + - trigger: "}dckenv" + replace: "ENV $1$=$2$" + vars: + - name: key + type: choice + params: + values: ["$|$", "NODE_ENV", "PORT", "DB_HOST", "DEBUG"] + - name: value + type: choice + params: + values: ["production", "3000", "localhost", "true", ""] diff --git a/match/git.yml b/match/git.yml new file mode 100644 index 0000000..c20b30c --- /dev/null +++ b/match/git.yml @@ -0,0 +1,515 @@ +# Git Snippets for Espanso +matches: + # === BASIC COMMANDS === + + # Git init + - trigger: "}ginit" + replace: "git init" + + # Git clone + - trigger: "}gclone" + replace: "git clone $1$" + + # Git status + - trigger: "}gst" + replace: "git status" + + # Git add + - trigger: "}ga" + #replace: "git add $1$" + vars: + - name: "dot" + type: "choice" + params: + values: + - ". " + - "" + - name: "file" + type: "choice" + params: + values: + - "$|$" + - " " + replace: "git add {{dot}}{{file}}" + + # Git commit + - trigger: "}gcs" + replace: 'git commit -m "$|$"' + + # Git commit with amend + - trigger: "}gca" + replace: 'git commit --amend -m "$|$"' + + # Git commit all + - trigger: "}gcaa" + replace: 'git commit -am "$|$"' + + # Git push + - trigger: "}gp" + #replace: "git push $1$ $2$" + vars: + - name: "option" + type: "choice" + params: + values: + - "" + - "--force" + - "--tags" + - name: "remote_branch" + type: "choice" + params: + values: + - "" + - "origin main" + - "origin master" + - "origin HEAD" + replace: "git push {{option}} {{remote_branch}}" + + # Git pull + - trigger: "}gl" + #replace: "git pull $1$ $2$" + vars: + - name: "option" + type: "choice" + params: + values: + - "" + - "--rebase" + - name: "remote_branch" + type: "choice" + params: + values: + - "" + - "origin main" + - "origin master" + replace: "git pull {{option}} {{remote_branch}}" + + # Git fetch + - trigger: "}gf" + #replace: "git fetch $1$" + vars: + - name: "remote" + type: "choice" + params: + values: + - "" + - "origin" + - "--all" + replace: "git fetch {{remote}}" + + # Git log + - trigger: "}glg" + replace: "git log --oneline --graph --all" + + # Git diff + - trigger: "}gd" + #replace: "git diff $1$" + vars: + - name: "option" + type: "choice" + params: + values: + - "" + - "--staged" + - "HEAD~1" + replace: "git diff {{option}}" + + # Git checkout + - trigger: "}gco" + #replace: "git checkout $1$" + vars: + - name: "what" + type: "choice" + params: + values: + - "" + - "-b " + - "-- " + - name: "target" + type: "choice" + params: + values: + - "$|$" + - "main" + - "master" + - "develop" + replace: "git checkout {{what}}{{target}}" + + # Git branch + - trigger: "}gb" + #replace: "git branch $1$" + vars: + - name: "option" + type: "choice" + params: + values: + - "" + - "-d " + - "-D " + - "-a" + - "-r" + - name: "branch" + type: "choice" + params: + values: + - "$|$" + - "feature/" + - "bugfix/" + - "hotfix/" + replace: "git branch {{option}}{{branch}}" + + # Git merge + - trigger: "}gm" + #replace: "git merge $1$" + vars: + - name: "option" + type: "choice" + params: + values: + - "" + - "--no-ff " + - "--squash " + - "--abort" + - name: "branch" + type: "choice" + params: + values: + - "$|$" + - "main" + - "master" + - "develop" + replace: "git merge {{option}}{{branch}}" + + # Git rebase + - trigger: "}gr" + #replace: "git rebase $1$" + vars: + - name: "option" + type: "choice" + params: + values: + - "" + - "-i " + - "--abort" + - "--continue" + - "--skip" + - name: "target" + type: "choice" + params: + values: + - "$|$" + - "main" + - "master" + - "HEAD~3" + replace: "git rebase {{option}}{{target}}" + + # Git stash + - trigger: "}gstash" + #replace: "git stash $1$" + vars: + - name: "option" + type: "choice" + params: + values: + - "" + - 'push -m "$|$"' + - "pop" + - "list" + - "drop" + replace: "git stash {{option}}" + + # Git remote + - trigger: "}gr" + #replace: "git remote $1$" + vars: + - name: "option" + type: "choice" + params: + values: + - "-v" + - "add origin " + - "remove " + - name: "url" + type: "choice" + params: + values: + - "$|$" + - "https://github.com/user/repo.git" + replace: "git remote {{option}}{{url}}" + + # Git reset + - trigger: "}greset" + #replace: "git reset $1$ $2$" + vars: + - name: "mode" + type: "choice" + params: + values: + - "--soft " + - "--hard " + - "" + - name: "target" + type: "choice" + params: + values: + - "HEAD~1" + - "HEAD~2" + - "HEAD~3" + - "$|$" + replace: "git reset {{mode}}{{target}}" + + # Git clean + - trigger: "}gclean" + #replace: "git clean -fd $1$" + vars: + - name: "dry" + type: "choice" + params: + values: + - "" + - "-n" + replace: "git clean -fd{{dry}}" + + # Git show + - trigger: "}gshow" + #replace: "git show $1$" + vars: + - name: "ref" + type: "choice" + params: + values: + - "HEAD" + - "HEAD~1" + - "$|$" + - "" + replace: "git show {{ref}}" + + # Git cherry-pick + - trigger: "}gcp" + #replace: "git cherry-pick $1$" + vars: + - name: "option" + type: "choice" + params: + values: + - "" + - "-x " + - "--continue" + - "--abort" + - name: "commit" + type: "choice" + params: + values: + - "$|$" + - "" + - "HEAD~1" + replace: "git cherry-pick {{option}}{{commit}}" + + # Git revert + - trigger: "}grev" + #replace: "git revert $1$" + vars: + - name: "commit" + type: "choice" + params: + values: + - "HEAD" + - "HEAD~1" + - "$|$" + - "" + replace: "git revert {{commit}}" + + # Git bisect + - trigger: "}gbisect" + #replace: "git bisect $1$" + vars: + - name: "action" + type: "choice" + params: + values: + - "start" + - "good" + - "bad" + - "reset" + - "log" + replace: "git bisect {{action}}" + + # Git blame + - trigger: "}gblame" + #replace: "git blame $1$" + vars: + - name: "file" + type: "choice" + params: + values: + - "$|$" + - "" + replace: "git blame {{file}}" + + # Git reflog + - trigger: "}grl" + #replace: "git reflog" + replace: "git reflog" + + # Git config + - trigger: "}gconf" + #replace: "git config --global $1$ $2$" + vars: + - name: "key" + type: "choice" + params: + values: + - "user.name" + - "user.email" + - "core.editor" + - "init.defaultBranch" + - name: "value" + type: "choice" + params: + values: + - "$|$" + - "Your Name" + - "your.email@example.com" + - "vim" + - "main" + replace: 'git config --global {{key}} "{{value}}"' + + # === COMMIT MESSAGE CONVENTIONS === + # Conventional Commits + - trigger: "}gcc" + vars: + - name: "type" + type: "choice" + params: + values: + - "feat" + - "fix" + - "docs" + - "style" + - "refactor" + - "perf" + - "test" + - "chore" + - "revert" + - name: "scope" + type: "choice" + params: + values: + - "" + - "(auth)" + - "(api)" + - "(db)" + - "(ui)" + - "(cli)" + replace: "{{type}}{{scope}}: " + + # Fix typo in commit + - trigger: "}gfix" + replace: "fixup! $|$" + + # Squash commit + - trigger: "}gsquash" + replace: "squash! $|$" + + # === 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 + - trigger: "}gbr" + replace: "release/v$1$.$2$.$3$" + vars: + - name: "major" + type: "choice" + params: + values: ["0", "1", "2"] + - name: "minor" + type: "choice" + params: + values: ["0", "1", "2"] + - name: "patch" + type: "choice" + params: + values: ["0", "1", "2"] + + # === TROUBLESHOOTING === + + # Discard local changes (CAREFUL!) + - trigger: "}gdc" + replace: "git checkout -- $1$" + vars: + - name: "file" + type: "choice" + params: + values: + - "." + - "$|$" + - "" + + # Undo last commit (keep changes) + - trigger: "}gundo" + replace: "git reset --soft HEAD~1" + + # Undo last commit (discard changes) + - trigger: "}gundohard" + replace: "git reset --hard HEAD~1" + + # Remove untracked files (CAREFUL!) + - trigger: "}grmuntracked" + replace: "git clean -fd" + + # See what branch you're on + - trigger: "}gcurrbranch" + replace: "git branch --show-current" + + # List all branches with last commit + - trigger: "}gbrl" + replace: "git branch -vva" + + # Find deleted branches + - trigger: "}gbrd" + replace: "git branch --merged | egrep -v \"(^\\*|main|master|develop)\"" + + # === GIT IGNORE === + + # Add to .gitignore + - trigger: "gignore" + replace: 'echo "$1$" >> .gitignore' + + # Common .gitignore entries + - trigger: "ignode" + replace: "node_modules/\n.env\nnpm-debug.log" + + - trigger: "igpython" + replace: "__pycache__/\n*.pyc\n.env\nvenv/\n.venv/\n*.egg-info/" + + - trigger: "igidea" + replace: ".idea/\n*.iml\n.vscode/\n.DS_Store" + + - trigger: "igbuild" + replace: "dist/\nbuild/\n*.o\n*.obj\n*.exe\n*.dll\n*.so\n*.dylib" diff --git a/match/sql.yml b/match/sql.yml new file mode 100644 index 0000000..d455677 --- /dev/null +++ b/match/sql.yml @@ -0,0 +1,160 @@ +# SQL Snippets for Espanso +matches: + # Basic SELECT statement + - trigger: "}sqls" + replace: | + SELECT + [columns] + FROM + [table] + [WHERE conditions] + [ORDER BY column] + [LIMIT n]; + + # SELECT with common clauses + - trigger: "}sqlsel" + replace: | + SELECT + $1$ -- columns + FROM + $2$ -- table + $3$ -- optional: WHERE, GROUP BY, etc. + $4$; -- optional: semicolon or other ending + + # INSERT statement + - trigger: "}sqli" + replace: | + INSERT INTO + [table] ([columns]) + VALUES + ([values]); + + # UPDATE statement + - trigger: "}sqlu" + replace: | + UPDATE + [table] + SET + [column] = [value] + [WHERE conditions]; + + # DELETE statement + - trigger: "}sqld" + replace: | + DELETE FROM + [table] + [WHERE conditions]; + + # CREATE TABLE + - trigger: "}sqlct" + replace: | + CREATE TABLE [table] ( + [column1] [type] [constraints], + [column2] [type] [constraints], + ... + ); + + # Common WHERE clauses + - trigger: "}sqlw" + replace: | + WHERE + [conditions] + + # JOIN patterns + - trigger: "}sqlj" + replace: | + [table1] + [JOIN_TYPE] JOIN [table2] + ON [table1].[key] = [table2].[key] + + # Aggregate functions + - trigger: "}sqlagg" + replace: | + SELECT + [GROUP_BY_COLUMN], + COUNT(*) as count, + SUM([numeric_column]) as total, + AVG([numeric_column]) as average, + MAX([column]) as max_value, + MIN([column]) as min_value + FROM + [table] + GROUP BY + [GROUP_BY_COLUMN] + + # Subquery pattern + - trigger: "}sqlsub" + replace: | + SELECT + [columns] + FROM + [table1] + WHERE [column] IN ( + SELECT [column] + FROM [table2] + WHERE [conditions] + ) + + # Common SQL comments + - trigger: "}sqlc" + replace: "-- $|$" + - trigger: "}sqlcb" + replace: "/* $|$ */" + + # Transaction wrapper + - trigger: "}sqltr" + replace: | + BEGIN TRANSACTION; + + $|$ + + COMMIT; + -- ROLLBACK; -- uncomment to rollback instead + + # CTE (Common Table Expression) + - trigger: "}sqlcte" + replace: | + WITH [cte_name] AS ( + SELECT + [columns] + FROM + [table] + WHERE + [conditions] + ) + SELECT + [columns] + FROM + [cte_name]; + + # CASE statement + - trigger: "}sqlcase" + replace: | + CASE + WHEN [condition1] THEN [result1] + WHEN [condition2] THEN [result2] + ELSE [default_result] + END as [alias] + + # Window functions pattern + - trigger: "}sqlwin" + replace: | + SELECT + [columns], + [function]() OVER ( + PARTITION BY [partition_column] + ORDER BY [order_column] + [ROWS/RANGE frame] + ) as [alias] + FROM + [table] + +# Placeholders guide (use these in your templates): +# [columns] - list of columns (comma-separated or *) +# [table] - table name(s) +# [conditions] - WHERE clause conditions +# [JOIN_TYPE] - INNER, LEFT, RIGHT, FULL, CROSS +# [numeric_column] - column with numeric values for aggregates +# [GROUP_BY_COLUMN] - column to group by +# $1$, $2$ etc. - tab stops (use Tab to navigate) +# $|$ - final cursor position