~tardypad/dotfiles

ref: HEAD dotfiles/setup/substitute-keys -rwxr-xr-x 805 bytes
56d57f55Damien Tardy-Panis Fix aerc bindings for Backup account 3 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh

SCRIPT_FILE="build/substitute-keys"

if [ -f "${SCRIPT_FILE}" ]; then
  sed -f "${SCRIPT_FILE}" -
  exit
fi

KEYS_FILE="config/keys"

mkdir -p build

{
  sed '/^$/d' "${KEYS_FILE}" \
    | while read -r LINE; do
        ALIAS=$( echo "${LINE}" | cut -f1 -d' ' )
        KEY=$( echo "${LINE}" | tr -s ' ' | cut -f2 -d' ' )
        KEY_LOW=$( echo "${KEY}" | tr '[:upper:]' '[:lower:]' )
        KEY_UPP=$( echo "${KEY}" | tr '[:lower:]' '[:upper:]' )
        echo "s|{key/${ALIAS}}|${KEY}|g"
        echo "s|{key/${ALIAS}/low}|${KEY_LOW}|g"
        echo "s|{key/${ALIAS}/upp}|${KEY_UPP}|g"
        echo "s|{key/${ALIAS}/\([^}]*\)}|\1|g"
      done

  # other non aliased keys
  echo 's|{key/[^/}]*/\([^}]*\)}|\1|g'
  echo 's|{key/\([^}]*\)}|\1|g'
} > "${SCRIPT_FILE}"

sed -f "${SCRIPT_FILE}" -