1--- # misc
2matches:
3 - trigger: ";192"
4 replace: 192.168.0.
5
6 - trigger: ";search"
7 replace: "-site:reddit.com -site:twitter.com -site:pinterest.com"
8
9 - trigger: ";shebang"
10 replace: "#!/usr/bin/env "
11
12 - trigger: ";strict" # bash "strict mode"
13 replace: |
14 set -euo pipefail
15 IFS=$'\n\t'
16
17 - trigger: ";chapply" # apply chezmoi dotfiles as a oneshot operation
18 replace: 'sh -c "$(curl -fsLS get.chezmoi.io)" -- init --one-shot {{GITHUB_USERNAME}}'
19 vars:
20 - name: GITHUB_USERNAME
21 type: shell
22 params:
23 cmd: "git config --global --get user.name"
24
25 # easily bootstrap rust tools, for when I'm in ephemeral environments, like containers
26 - trigger: ";rustup"
27 replace: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
28
29 # same idea as rustup, but to get Helix, the best text editor 😎
30 - trigger: ";helix"
31 replace: |
32 {
33 sudo apt install software-properties-common git -y
34 sudo add-apt-repository ppa:maveonair/helix-editor -y
35 sudo apt update
36 sudo apt install helix -y
37 } || {
38 sudo dnf install helix -y
39 } || {
40 sudo pacman -S helix --noconfirm
41 } || {
42 flatpak install flathub com.helix_editor.Helix
43 flatpak run com.helix_editor.Helix
44 }
45 hx --grammar fetch
46 mkdir -p ~/.config/helix
47 echo '{{HELIX_CONFIG}}' > ~/.config/helix/config.toml
48 echo '{{HELIX_LANG_CONFIG}}' > ~/.config/helix/languages.toml
49 vars:
50 # these yoink the values from the helix configs on my host
51 # and redirect them into files on the target so I can keep
52 # them "portable"
53 - name: HELIX_CONFIG
54 type: shell
55 params:
56 cmd: "cat ~/.config/helix/config.toml"
57 - name: HELIX_LANG_CONFIG
58 type: shell
59 params:
60 cmd: "cat ~/.config/helix/languages.toml"
61
62 # i use dracula theme colors for lots of things
63 - triggers: [";dracback", ";dracdark"]
64 replace: "#282a36"
65 - triggers: [";dractext", ";dracwhite", ";draclight"]
66 replace: "#f8f8f2"
67 - trigger: ";dracgreen"
68 replace: "#50fa7b"
69 - trigger: ";dracred"
70 replace: "#ff5555"
71 - trigger: ";dracyellow"
72 replace: "#f1fa8c"
73 - trigger: ";dracblue"
74 replace: "#8be9fd"
75 - trigger: ";dracpurple"
76 replace: "#bd93f9"
77 - trigger: ";dracpink"
78 replace: "#ff79c6"
79 - trigger: ";dracorange"
80 replace: "#ffb86c"
81 - triggers: [";dracgray", ";dracgrey"]
82 replace: "#6272a4"
83
84 - triggers: ["allinpath", "listall", "listallinpath"]
85 replace: "bash -c \"for dir in $(echo $PATH | tr ':' ' '); do ls -1 $dir; done\""
86
87 - triggers: ["reporoot", "gitreporoot"]
88 replace: "git rev-parse --show-toplevel"
89
90 # you like readable YAML? too bad :D
91 - trigger: ";arch"
92 replace: " \t -`\n \t .o+`\n \t `ooo/\n \t `+oooo:\n \t `+oooooo:\n \t -+oooooo+:\n \t `/:-:++oooo+:\n \t `/++++/+++++++:\n \t `/++++++++++++++:\n \t `/+++ooooooooooooo/`\n \t ./ooosssso++osssssso+`\n \t .oossssso-````/ossssss+`\n \t -osssssso. :ssssssso.\n \t :osssssss/ osssso+++.\n \t /ossssssss/ +ssssooo/-\n \t `/ossssso+/:- -:/+osssso+-\n \t `+sso+:-` `.-/+oso:\n \t`++:. `-/+/\n \t.` `/\n "
93
94--- # pseudo-autofill
95global_vars:
96 - name: bws_access_token
97 type: shell
98 params:
99 # use the OS keyring to get access token for secrets manager, where BW_PASSWORD is stored
100 cmd: 'security find-generic-password -w -s "BWS_ACCESS_TOKEN" -a "$USER"' # macOS
101 - name: bw_session
102 type: shell
103 params:
104 cmd: |
105 if [ -z "$BW_SESSION" ]; then
106 export BW_NOINTERACTION=1
107 export BWS_ACCESS_TOKEN="{{bws_access_token}}"
108 # `bws run` injects the environment variables in the following command
109 bws run 'bw unlock "$BW_PASSWORD" --raw || bw login "$VAULT_EMAIL" "$BW_PASSWORD" --raw'
110 fi
111
112matches:
113 - regex: "(u|U)<(?P<item>.*)>" # fill a username with u<item_name> or U<item_name>
114 replace: "{{bw_usename}}"
115 vars:
116 - name: bw_usename
117 type: shell
118 params:
119 shell: zsh
120 cmd: |-
121 export BW_SESSION="{{bw_session}}"
122 bw list items --search "{{item}}" | jq -r '.[0] | select(.name | ascii_downcase) | .login.username'
123
124 - regex: "(p|P)<(?P<item>.*)>" # fill a password with p<item_name> or P<item_name>
125 replace: "{{bw_pass}}"
126 vars:
127 - name: bw_pass
128 type: shell
129 params:
130 shell: zsh
131 cmd: |-
132 export BW_SESSION="{{bw_session}}"
133 bw list items --search "{{item}}" | jq -r '.[0] | select(.name | ascii_downcase) | .login.password'
134
135 - regex: "(t|T)<(?P<item>.*)>" # fill a totp with t<item_name> or T<item_name>
136 replace: "{{bw_totp}}"
137 vars:
138 - name: id
139 type: shell
140 params:
141 shell: zsh
142 cmd: |-
143 export BW_SESSION="{{bw_session}}"
144 bw list items --search "{{item}}" | jq -r '.[0].id'
145
146 - name: bw_totp
147 type: shell
148 params:
149 shell: zsh
150 cmd: |-
151 export BW_SESSION="{{bw_session}}"
152 bw get totp "{{id}}"