Diferentes formas de agregar un reemplazo:
defaults write -g NSUserDictionaryReplacementItems -array-add '{on=1;replace=a;with=b;}'
defaults write -g NSUserDictionaryReplacementItems -array-add '<dict><key>on</key><integer>1</integer><key>replace</key><string>a</string><key>with</key><string>b</string></dict>'
Diferentes formas de reemplazar la lista completa:
defaults write -g NSUserDictionaryReplacementItems -array '{on=1;replace=a;with="b \"\b";}' '{on=1;replace=c;with=d;}'
defaults write -g NSUserDictionaryReplacementItems '({on=1;replace=a;with="b \"\b";},{on=1;replace=c;with=d;})'
defaults write -g NSUserDictionaryReplacementItems '<array><dict><key>on</key><integer>1</integer><key>replace</key><string>a</string><key>with</key><string>b "\b</string></dict><dict><key>on</key><integer>1</integer><key>replace</key><string>c</string><key>with</key><string>d</string></dict></array>'
Cierre y vuelva a abrir las aplicaciones para aplicar los cambios.
Editar: los cambios realizados con defaults
se pierden si abre la pestaña Texto del panel de preferencias del teclado. Para evitarlo, use un script como este:
date=$(date +%s)
while read -r replace with; do
plist+="{on=1;replace=\"$replace\";with=\"$with\";},"
sql+="INSERT INTO 'ZUSERDICTIONARYENTRY' VALUES($((++i)),1,1,0,0,0,0,$date,NULL,NULL,NULL,NULL,NULL,\"$with\",\"$replace\",NULL);"
done < <(sed 's/\/\\/g;s/"/\"/g' ~/replacements.txt)
sqlite3 ~/Library/Dictionaries/CoreDataUbiquitySupport/$USER~*/UserDictionary/local/store/UserDictionary.db "delete from ZUSERDICTIONARYENTRY;$sql"
defaults write -g NSUserDictionaryReplacementItems "(${plist%?})"
Los reemplazos se guardan en ~/Library/Dictionaries/CoreDataUbiquitySupport/$USER~*/UserDictionary/local/store/UserDictionary.db
incluso si iCloud está deshabilitado.