Skip to content

Instantly share code, notes, and snippets.

@fstamour
Created March 1, 2021 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fstamour/97ee60069322ec27eed7cfef2198670f to your computer and use it in GitHub Desktop.
Save fstamour/97ee60069322ec27eed7cfef2198670f to your computer and use it in GitHub Desktop.
espanso script to generate configurations from CSV files

file gen:

#!/usr/bin/env -S awk -f
#
# Usage: ./gen misspells-fr.csv > user/misspells-fr.yml

BEGIN {
  FS=","
  print "parent: default"
  print "matches: "
}

{
  print ""
  print "  - trigger: \""$1"\""
  print "    replace: \""$2"\""
  print "    propagate_case: true"
  print "    word: true"
}

file gen-all:

#!/bin/sh

espanso stop

set -x

for file in *.csv; do
  ./gen $file > user/$(basename -s .csv $file).yml
done

espanso start
@fstamour
Copy link
Author

fstamour commented Mar 3, 2021

I'm always addind more expansions, and theses scripts really saved me a lot of typing:

input

$ wc -l *.csv
  55 misspells-en.csv
  42 misspells-fr.csv
  97 total

output

$ wc -l user/*
 277 user/misspells-en.yml
 212 user/misspells-fr.yml
 489 total

yes, I make a lot of typos xD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment