tangled
alpha
login
or
join now
dunkirk.sh
/
dots
3
fork
atom
Kieran's opinionated (and probably slightly dumb) nix config
3
fork
atom
overview
issues
pulls
pipelines
feat: add machine name setting
dunkirk.sh
8 months ago
584bc622
cd999304
verified
This commit was signed with the committer's
known signature
.
dunkirk.sh
SSH Key Fingerprint:
SHA256:DqcG0RXYExE26KiWo3VxJnsxswN1QNfTBvB+bdSpk80=
+410
-402
1 changed file
expand all
collapse all
unified
split
home-manager
app
shell.nix
+410
-402
home-manager/app/shell.nix
···
5
5
...
6
6
}:
7
7
{
8
8
-
programs.oh-my-posh = {
9
9
-
enable = true;
10
10
-
enableZshIntegration = true;
11
11
-
settings = {
12
12
-
upgrade = {
13
13
-
notice = false;
14
14
-
interval = "2w";
15
15
-
auto = false;
16
16
-
};
17
17
-
version = 2;
18
18
-
final_space = true;
19
19
-
console_title_template = "{{ .Shell }} in {{ .Folder }}";
20
20
-
blocks = [
21
21
-
{
22
22
-
type = "prompt";
23
23
-
alignment = "left";
24
24
-
newline = true;
25
25
-
segments = [
26
26
-
{
27
27
-
type = "path";
28
28
-
style = "plain";
29
29
-
background = "transparent";
30
30
-
foreground = "blue";
31
31
-
template = "{{ .Path }} ";
32
32
-
properties = {
33
33
-
style = "full";
34
34
-
};
35
35
-
}
36
36
-
{
37
37
-
type = "git";
38
38
-
style = "plain";
39
39
-
foreground = "p:grey";
40
40
-
background = "transparent";
41
41
-
template = "{{if not .Detached}}{{ .HEAD }}{{else}}@{{ printf \"%.7s\" .Commit.Sha }}{{end}}{{ if .Staging.Changed }} ({{ .Staging.String }}){{ end }}{{ if .Working.Changed }}*{{ end }} <cyan>{{ if .BranchStatus }}{{ .BranchStatus }}{{ end }}</>";
42
42
-
properties = {
43
43
-
branch_icon = "";
44
44
-
branch_identical_icon = "";
45
45
-
branch_gone_icon = "";
46
46
-
branch_ahead_icon = "⇡";
47
47
-
branch_behind_icon = "⇣";
48
48
-
commit_icon = "@";
49
49
-
fetch_status = true;
50
50
-
};
51
51
-
}
8
8
+
config = {
9
9
+
programs.oh-my-posh = {
10
10
+
enable = true;
11
11
+
enableZshIntegration = true;
12
12
+
settings = {
13
13
+
upgrade = {
14
14
+
notice = false;
15
15
+
interval = "2w";
16
16
+
auto = false;
17
17
+
};
18
18
+
version = 2;
19
19
+
final_space = true;
20
20
+
console_title_template = "{{ .Shell }} in {{ .Folder }}";
21
21
+
blocks = [
22
22
+
{
23
23
+
type = "prompt";
24
24
+
alignment = "left";
25
25
+
newline = true;
26
26
+
segments = [
27
27
+
{
28
28
+
type = "session";
29
29
+
background = "transparent";
30
30
+
foreground = "yellow";
31
31
+
template = "{{ if .SSHSession }}{{.HostName}} {{ end }}";
32
32
+
}
33
33
+
{
34
34
+
type = "path";
35
35
+
style = "plain";
36
36
+
background = "transparent";
37
37
+
foreground = "blue";
38
38
+
template = "{{ .Path }} ";
39
39
+
properties = {
40
40
+
style = "full";
41
41
+
};
42
42
+
}
43
43
+
{
44
44
+
type = "git";
45
45
+
style = "plain";
46
46
+
foreground = "p:grey";
47
47
+
background = "transparent";
48
48
+
template = "{{if not .Detached}}{{ .HEAD }}{{else}}@{{ printf \"%.7s\" .Commit.Sha }}{{end}}{{ if .Staging.Changed }} ({{ .Staging.String }}){{ end }}{{ if .Working.Changed }}*{{ end }} <cyan>{{ if .BranchStatus }}{{ .BranchStatus }}{{ end }}</>";
49
49
+
properties = {
50
50
+
branch_icon = "";
51
51
+
branch_identical_icon = "";
52
52
+
branch_gone_icon = "";
53
53
+
branch_ahead_icon = "⇡";
54
54
+
branch_behind_icon = "⇣";
55
55
+
commit_icon = "@";
56
56
+
fetch_status = true;
57
57
+
};
58
58
+
}
59
59
+
];
60
60
+
}
61
61
+
{
62
62
+
type = "rprompt";
63
63
+
overflow = "hidden";
64
64
+
segments = [
65
65
+
{
66
66
+
type = "executiontime";
67
67
+
style = "plain";
68
68
+
foreground = "yellow";
69
69
+
background = "transparent";
70
70
+
template = "{{ .FormattedMs }}";
71
71
+
properties = {
72
72
+
threshold = 3000;
73
73
+
};
74
74
+
}
75
75
+
{
76
76
+
type = "nix-shell";
77
77
+
style = "plain";
78
78
+
foreground = "red";
79
79
+
background = "transparent";
80
80
+
template = ''{{if ne .Type "unknown" }} {{ .Type }}{{ end }}'';
81
81
+
}
82
82
+
];
83
83
+
}
84
84
+
{
85
85
+
type = "prompt";
86
86
+
alignment = "left";
87
87
+
newline = true;
88
88
+
segments = [
89
89
+
{
90
90
+
type = "text";
91
91
+
style = "plain";
92
92
+
foreground_templates = [
93
93
+
"{{if gt .Code 0}}red{{end}}"
94
94
+
"{{if eq .Code 0}}magenta{{end}}"
95
95
+
];
96
96
+
background = "transparent";
97
97
+
template = "❯";
98
98
+
}
99
99
+
];
100
100
+
}
101
101
+
];
102
102
+
transient_prompt = {
103
103
+
foreground_templates = [
104
104
+
"{{if gt .Code 0}}red{{end}}"
105
105
+
"{{if eq .Code 0}}magenta{{end}}"
52
106
];
53
53
-
}
54
54
-
{
55
55
-
type = "rprompt";
56
56
-
overflow = "hidden";
57
57
-
segments = [
58
58
-
{
59
59
-
type = "executiontime";
60
60
-
style = "plain";
61
61
-
foreground = "yellow";
62
62
-
background = "transparent";
63
63
-
template = "{{ .FormattedMs }}";
64
64
-
properties = {
65
65
-
threshold = 3000;
66
66
-
};
67
67
-
}
68
68
-
{
69
69
-
type = "nix-shell";
70
70
-
style = "plain";
71
71
-
foreground = "red";
72
72
-
background = "transparent";
73
73
-
template = ''{{if ne .Type "unknown" }} {{ .Type }}{{ end }}'';
74
74
-
}
75
75
-
];
76
76
-
}
77
77
-
{
78
78
-
type = "prompt";
79
79
-
alignment = "left";
80
80
-
newline = true;
81
81
-
segments = [
82
82
-
{
83
83
-
type = "text";
84
84
-
style = "plain";
85
85
-
foreground_templates = [
86
86
-
"{{if gt .Code 0}}red{{end}}"
87
87
-
"{{if eq .Code 0}}magenta{{end}}"
88
88
-
];
89
89
-
background = "transparent";
90
90
-
template = "❯";
91
91
-
}
92
92
-
];
93
93
-
}
94
94
-
];
95
95
-
transient_prompt = {
96
96
-
foreground_templates = [
97
97
-
"{{if gt .Code 0}}red{{end}}"
98
98
-
"{{if eq .Code 0}}magenta{{end}}"
99
99
-
];
100
100
-
background = "transparent";
101
101
-
template = "❯ ";
102
102
-
};
103
103
-
secondary_prompt = {
104
104
-
foreground = "p:gray";
105
105
-
background = "transparent";
106
106
-
template = "❯❯ ";
107
107
-
};
108
108
-
palette = {
109
109
-
grey = "#6c6c6c";
107
107
+
background = "transparent";
108
108
+
template = "❯ ";
109
109
+
};
110
110
+
secondary_prompt = {
111
111
+
foreground = "p:gray";
112
112
+
background = "transparent";
113
113
+
template = "❯❯ ";
114
114
+
};
115
115
+
palette = {
116
116
+
grey = "#6c6c6c";
117
117
+
};
110
118
};
111
119
};
112
112
-
};
113
120
114
114
-
programs.zsh = {
115
115
-
enable = true;
116
116
-
enableCompletion = true;
117
117
-
syntaxHighlighting.enable = true;
121
121
+
programs.zsh = {
122
122
+
enable = true;
123
123
+
enableCompletion = true;
124
124
+
syntaxHighlighting.enable = true;
118
125
119
119
-
shellAliases = {
120
120
-
lazygit = "gitui";
121
121
-
cat = "bat";
122
122
-
ls = "eza";
123
123
-
ll = "eza -l";
124
124
-
la = "eza -la";
125
125
-
gc = "git commit";
126
126
-
gp = "git push";
127
127
-
rr = "rm -Rf";
128
128
-
ghrpc = "gh repo create -c";
129
129
-
goops = "git commit --amend --no-edit && git push --force-with-lease";
130
130
-
chngwall = "~/.config/hypr/randomize.sh";
131
131
-
vi = "nvim";
132
132
-
vim = "nvim";
133
133
-
};
134
134
-
initContent = ''
135
135
-
#ssh auto reconnect
136
136
-
assh() {
137
137
-
local host=$1
138
138
-
local port=$2
139
139
-
while true; do
140
140
-
ssh -p $port -o "BatchMode yes" $host || sleep 1
141
141
-
done
142
142
-
}
143
143
-
# hackatime summary
144
144
-
summary() {
145
145
-
local user_id=$1
146
146
-
curl -X 'GET' \
147
147
-
"https://waka.hackclub.com/api/summary?user=''${user_id}&interval=month" \
148
148
-
-H 'accept: application/json' \
149
149
-
-H 'Authorization: Bearer 2ce9e698-8a16-46f0-b49a-ac121bcfd608' | jq '. + {
150
150
-
"total_categories_sum": (.categories | map(.total) | add),
151
151
-
"total_categories_human_readable": (
152
152
-
(.categories | map(.total) | add) as $total_seconds |
153
153
-
"\($total_seconds / 3600 | floor)h \(($total_seconds % 3600) / 60 | floor)m \($total_seconds % 60)s"
154
154
-
),
155
155
-
"projectsKeys": (
156
156
-
.projects | sort_by(-.total) | map(.key)
157
157
-
)
158
158
-
}'
159
159
-
}
126
126
+
shellAliases = {
127
127
+
lazygit = "gitui";
128
128
+
cat = "bat";
129
129
+
ls = "eza";
130
130
+
ll = "eza -l";
131
131
+
la = "eza -la";
132
132
+
gc = "git commit";
133
133
+
gp = "git push";
134
134
+
rr = "rm -Rf";
135
135
+
ghrpc = "gh repo create -c";
136
136
+
goops = "git commit --amend --no-edit && git push --force-with-lease";
137
137
+
chngwall = "~/.config/hypr/randomize.sh";
138
138
+
vi = "nvim";
139
139
+
vim = "nvim";
140
140
+
};
141
141
+
initContent = ''
142
142
+
#ssh auto reconnect
143
143
+
assh() {
144
144
+
local host=$1
145
145
+
local port=$2
146
146
+
while true; do
147
147
+
ssh -p $port -o "BatchMode yes" $host || sleep 1
148
148
+
done
149
149
+
}
150
150
+
# hackatime summary
151
151
+
summary() {
152
152
+
local user_id=$1
153
153
+
curl -X 'GET' \
154
154
+
"https://waka.hackclub.com/api/summary?user=''${user_id}&interval=month" \
155
155
+
-H 'accept: application/json' \
156
156
+
-H 'Authorization: Bearer 2ce9e698-8a16-46f0-b49a-ac121bcfd608' | jq '. + {
157
157
+
"total_categories_sum": (.categories | map(.total) | add),
158
158
+
"total_categories_human_readable": (
159
159
+
(.categories | map(.total) | add) as $total_seconds |
160
160
+
"\($total_seconds / 3600 | floor)h \(($total_seconds % 3600) / 60 | floor)m \($total_seconds % 60)s"
161
161
+
),
162
162
+
"projectsKeys": (
163
163
+
.projects | sort_by(-.total) | map(.key)
164
164
+
)
165
165
+
}'
166
166
+
}
167
167
+
168
168
+
tangled() {
169
169
+
# Configuration variables - set these to your defaults
170
170
+
local default_plc_id="did:plc:krxbvxvis5skq7jj6eot23ul"
171
171
+
local default_github_username="taciturnaxolotl"
172
172
+
local extracted_github_username=""
160
173
161
161
-
tangled() {
162
162
-
# Configuration variables - set these to your defaults
163
163
-
local default_plc_id="did:plc:krxbvxvis5skq7jj6eot23ul"
164
164
-
local default_github_username="taciturnaxolotl"
165
165
-
local extracted_github_username=""
174
174
+
# Check if current directory is a git repository
175
175
+
if ! git rev-parse --is-inside-work-tree &>/dev/null; then
176
176
+
echo "Not a git repository"
177
177
+
return 1
178
178
+
fi
166
179
167
167
-
# Check if current directory is a git repository
168
168
-
if ! git rev-parse --is-inside-work-tree &>/dev/null; then
169
169
-
echo "Not a git repository"
170
170
-
return 1
171
171
-
fi
180
180
+
# Get the repository name from the current directory
181
181
+
local repo_name=$(basename "$(git rev-parse --show-toplevel)")
172
182
173
173
-
# Get the repository name from the current directory
174
174
-
local repo_name=$(basename "$(git rev-parse --show-toplevel)")
183
183
+
# Check if origin remote exists and points to ember
184
184
+
local origin_url=$(git remote get-url origin 2>/dev/null)
185
185
+
local origin_ember=false
175
186
176
176
-
# Check if origin remote exists and points to ember
177
177
-
local origin_url=$(git remote get-url origin 2>/dev/null)
178
178
-
local origin_ember=false
187
187
+
if [[ -n "$origin_url" ]]; then
188
188
+
# Try to extract GitHub username if origin is a GitHub URL
189
189
+
if [[ "$origin_url" == *"github.com"* ]]; then
190
190
+
extracted_github_username=$(echo "$origin_url" | sed -E 's/.*github\.com[:/]([^/]+)\/.*$/\1/')
191
191
+
# Override the default username with the extracted one
192
192
+
default_github_username=$extracted_github_username
193
193
+
fi
179
194
180
180
-
if [[ -n "$origin_url" ]]; then
181
181
-
# Try to extract GitHub username if origin is a GitHub URL
182
182
-
if [[ "$origin_url" == *"github.com"* ]]; then
183
183
-
extracted_github_username=$(echo "$origin_url" | sed -E 's/.*github\.com[:/]([^/]+)\/.*$/\1/')
184
184
-
# Override the default username with the extracted one
185
185
-
default_github_username=$extracted_github_username
195
195
+
if [[ "$origin_url" == *"ember"* ]]; then
196
196
+
origin_ember=true
197
197
+
echo "✅ Origin remote exists and points to ember"
198
198
+
else
199
199
+
echo "⚠️ Origin remote exists but doesn't point to ember"
200
200
+
fi
201
201
+
else
202
202
+
echo "⚠️ Origin remote doesn't exist"
186
203
fi
187
204
188
188
-
if [[ "$origin_url" == *"ember"* ]]; then
189
189
-
origin_ember=true
190
190
-
echo "✅ Origin remote exists and points to ember"
205
205
+
# Check if github remote exists
206
206
+
local github_exists=false
207
207
+
if git remote get-url github &>/dev/null; then
208
208
+
github_exists=true
209
209
+
echo "✅ GitHub remote exists"
191
210
else
192
192
-
echo "⚠️ Origin remote exists but doesn't point to ember"
211
211
+
echo "⚠️ GitHub remote doesn't exist"
193
212
fi
194
194
-
else
195
195
-
echo "⚠️ Origin remote doesn't exist"
196
196
-
fi
197
213
198
198
-
# Check if github remote exists
199
199
-
local github_exists=false
200
200
-
if git remote get-url github &>/dev/null; then
201
201
-
github_exists=true
202
202
-
echo "✅ GitHub remote exists"
203
203
-
else
204
204
-
echo "⚠️ GitHub remote doesn't exist"
205
205
-
fi
214
214
+
# Fix remotes if needed
215
215
+
if [[ "$origin_ember" = false || "$github_exists" = false ]]; then
216
216
+
echo "Setting up remotes..."
206
217
207
207
-
# Fix remotes if needed
208
208
-
if [[ "$origin_ember" = false || "$github_exists" = false ]]; then
209
209
-
echo "Setting up remotes..."
218
218
+
# Prompt for PLC identifier if needed
219
219
+
local plc_id=""
220
220
+
if [[ "$origin_ember" = false ]]; then
221
221
+
echo -n "Enter your PLC identifier [default: $default_plc_id]: "
222
222
+
read plc_input
223
223
+
plc_id=''${plc_input:-$default_plc_id}
224
224
+
fi
210
225
211
211
-
# Prompt for PLC identifier if needed
212
212
-
local plc_id=""
213
213
-
if [[ "$origin_ember" = false ]]; then
214
214
-
echo -n "Enter your PLC identifier [default: $default_plc_id]: "
215
215
-
read plc_input
216
216
-
plc_id=''${plc_input:-$default_plc_id}
217
217
-
fi
226
226
+
# Prompt for GitHub username with default from origin if available
227
227
+
local github_username=""
228
228
+
if [[ "$github_exists" = false ]]; then
229
229
+
echo -n "Enter your GitHub username [default: $default_github_username]: "
230
230
+
read github_input
231
231
+
github_username=''${github_input:-$default_github_username}
232
232
+
fi
218
233
219
219
-
# Prompt for GitHub username with default from origin if available
220
220
-
local github_username=""
221
221
-
if [[ "$github_exists" = false ]]; then
222
222
-
echo -n "Enter your GitHub username [default: $default_github_username]: "
223
223
-
read github_input
224
224
-
github_username=''${github_input:-$default_github_username}
225
225
-
fi
234
234
+
# Set up origin remote if needed
235
235
+
if [[ "$origin_ember" = false && -n "$plc_id" ]]; then
236
236
+
if git remote get-url origin &>/dev/null; then
237
237
+
git remote remove origin
238
238
+
fi
239
239
+
git remote add origin "git@ember:''${plc_id}/''${repo_name}"
240
240
+
echo "✅ Set up origin remote: git@ember:''${plc_id}/''${repo_name}"
241
241
+
fi
226
242
227
227
-
# Set up origin remote if needed
228
228
-
if [[ "$origin_ember" = false && -n "$plc_id" ]]; then
229
229
-
if git remote get-url origin &>/dev/null; then
230
230
-
git remote remove origin
243
243
+
# Set up GitHub remote if needed
244
244
+
if [[ "$github_exists" = false && -n "$github_username" ]]; then
245
245
+
git remote add github "git@github.com:''${github_username}/''${repo_name}.git"
246
246
+
echo "✅ Set up GitHub remote: git@github.com:''${github_username}/''${repo_name}.git"
231
247
fi
232
232
-
git remote add origin "git@ember:''${plc_id}/''${repo_name}"
233
233
-
echo "✅ Set up origin remote: git@ember:''${plc_id}/''${repo_name}"
248
248
+
else
249
249
+
echo "Remotes are correctly configured"
234
250
fi
251
251
+
}
235
252
236
236
-
# Set up GitHub remote if needed
237
237
-
if [[ "$github_exists" = false && -n "$github_username" ]]; then
238
238
-
git remote add github "git@github.com:''${github_username}/''${repo_name}.git"
239
239
-
echo "✅ Set up GitHub remote: git@github.com:''${github_username}/''${repo_name}.git"
253
253
+
# Post AtProto status updates
254
254
+
now() {
255
255
+
local message=""
256
256
+
local prompt_message=true
257
257
+
local account1_name=""
258
258
+
local account2_name=""
259
259
+
local account1_jwt=""
260
260
+
local account2_jwt=""
261
261
+
262
262
+
# Load account information from agenix secrets
263
263
+
if [[ -f "/run/agenix/bluesky" ]]; then
264
264
+
source "/run/agenix/bluesky"
265
265
+
else
266
266
+
echo "Error: Bluesky credentials file not found at /run/agenix/bluesky"
267
267
+
return 1
240
268
fi
241
241
-
else
242
242
-
echo "Remotes are correctly configured"
243
243
-
fi
244
244
-
}
245
269
246
246
-
# Post AtProto status updates
247
247
-
now() {
248
248
-
local message=""
249
249
-
local prompt_message=true
250
250
-
local account1_name=""
251
251
-
local account2_name=""
252
252
-
local account1_jwt=""
253
253
-
local account2_jwt=""
270
270
+
# Parse arguments
271
271
+
while [[ $# -gt 0 ]]; do
272
272
+
case "$1" in
273
273
+
-m|--message)
274
274
+
message="$2"
275
275
+
prompt_message=false
276
276
+
shift 2
277
277
+
;;
278
278
+
*)
279
279
+
echo "Usage: now [-m|--message \"your message\"]"
280
280
+
return 1
281
281
+
;;
282
282
+
esac
283
283
+
done
254
284
255
255
-
# Load account information from agenix secrets
256
256
-
if [[ -f "/run/agenix/bluesky" ]]; then
257
257
-
source "/run/agenix/bluesky"
258
258
-
else
259
259
-
echo "Error: Bluesky credentials file not found at /run/agenix/bluesky"
260
260
-
return 1
261
261
-
fi
285
285
+
# Prompt for message if none provided
286
286
+
if [[ "$prompt_message" = true ]]; then
287
287
+
echo -n "$ACCOUNT1 is: "
288
288
+
read message
262
289
263
263
-
# Parse arguments
264
264
-
while [[ $# -gt 0 ]]; do
265
265
-
case "$1" in
266
266
-
-m|--message)
267
267
-
message="$2"
268
268
-
prompt_message=false
269
269
-
shift 2
270
270
-
;;
271
271
-
*)
272
272
-
echo "Usage: now [-m|--message \"your message\"]"
290
290
+
if [[ -z "$message" ]]; then
291
291
+
echo "No message provided. Aborting."
273
292
return 1
274
274
-
;;
275
275
-
esac
276
276
-
done
293
293
+
fi
294
294
+
fi
295
295
+
296
296
+
# Generate JWT for ACCOUNT1
297
297
+
local account1_response=$(curl -s -X POST \
298
298
+
-H "Content-Type: application/json" \
299
299
+
-d '{
300
300
+
"identifier": "'$ACCOUNT1'",
301
301
+
"password": "'$ACCOUNT1_PASSWORD'"
302
302
+
}' \
303
303
+
"https://bsky.social/xrpc/com.atproto.server.createSession")
277
304
278
278
-
# Prompt for message if none provided
279
279
-
if [[ "$prompt_message" = true ]]; then
280
280
-
echo -n "$ACCOUNT1 is: "
281
281
-
read message
305
305
+
account1_jwt=$(echo "$account1_response" | jq -r '.accessJwt')
282
306
283
283
-
if [[ -z "$message" ]]; then
284
284
-
echo "No message provided. Aborting."
307
307
+
if [[ -z "$account1_jwt" || "$account1_jwt" == "null" ]]; then
308
308
+
echo "Failed to authenticate account $ACCOUNT1"
309
309
+
echo "Response: $account1_response"
285
310
return 1
286
311
fi
287
287
-
fi
288
312
289
289
-
# Generate JWT for ACCOUNT1
290
290
-
local account1_response=$(curl -s -X POST \
291
291
-
-H "Content-Type: application/json" \
292
292
-
-d '{
293
293
-
"identifier": "'$ACCOUNT1'",
294
294
-
"password": "'$ACCOUNT1_PASSWORD'"
295
295
-
}' \
296
296
-
"https://bsky.social/xrpc/com.atproto.server.createSession")
313
313
+
# Generate JWT for ACCOUNT2
314
314
+
local account2_response=$(curl -s -X POST \
315
315
+
-H "Content-Type: application/json" \
316
316
+
-d '{
317
317
+
"identifier": "'$ACCOUNT2'",
318
318
+
"password": "'$ACCOUNT2_PASSWORD'"
319
319
+
}' \
320
320
+
"https://bsky.social/xrpc/com.atproto.server.createSession")
297
321
298
298
-
account1_jwt=$(echo "$account1_response" | jq -r '.accessJwt')
322
322
+
account2_jwt=$(echo "$account2_response" | jq -r '.accessJwt')
299
323
300
300
-
if [[ -z "$account1_jwt" || "$account1_jwt" == "null" ]]; then
301
301
-
echo "Failed to authenticate account $ACCOUNT1"
302
302
-
echo "Response: $account1_response"
303
303
-
return 1
304
304
-
fi
324
324
+
if [[ -z "$account2_jwt" || "$account2_jwt" == "null" ]]; then
325
325
+
echo "Failed to authenticate account $ACCOUNT2"
326
326
+
echo "Response: $account2_response"
327
327
+
return 1
328
328
+
fi
305
329
306
306
-
# Generate JWT for ACCOUNT2
307
307
-
local account2_response=$(curl -s -X POST \
308
308
-
-H "Content-Type: application/json" \
309
309
-
-d '{
310
310
-
"identifier": "'$ACCOUNT2'",
311
311
-
"password": "'$ACCOUNT2_PASSWORD'"
312
312
-
}' \
313
313
-
"https://bsky.social/xrpc/com.atproto.server.createSession")
330
330
+
# Post to ACCOUNT1 as a.status.updates
331
331
+
local account1_post_response=$(curl -s -X POST \
332
332
+
-H "Content-Type: application/json" \
333
333
+
-H "Authorization: Bearer $account1_jwt" \
334
334
+
-d '{
335
335
+
"collection": "a.status.update",
336
336
+
"repo": "'$ACCOUNT1'",
337
337
+
"record": {
338
338
+
"$type": "a.status.update",
339
339
+
"text": "'"$message"'",
340
340
+
"createdAt": "'$(date -u +"%Y-%m-%dT%H:%M:%SZ")'"
341
341
+
}
342
342
+
}' \
343
343
+
"https://bsky.social/xrpc/com.atproto.repo.createRecord")
314
344
315
315
-
account2_jwt=$(echo "$account2_response" | jq -r '.accessJwt')
316
316
-
317
317
-
if [[ -z "$account2_jwt" || "$account2_jwt" == "null" ]]; then
318
318
-
echo "Failed to authenticate account $ACCOUNT2"
319
319
-
echo "Response: $account2_response"
320
320
-
return 1
321
321
-
fi
322
322
-
323
323
-
# Post to ACCOUNT1 as a.status.updates
324
324
-
local account1_post_response=$(curl -s -X POST \
325
325
-
-H "Content-Type: application/json" \
326
326
-
-H "Authorization: Bearer $account1_jwt" \
327
327
-
-d '{
328
328
-
"collection": "a.status.update",
329
329
-
"repo": "'$ACCOUNT1'",
330
330
-
"record": {
331
331
-
"$type": "a.status.update",
332
332
-
"text": "'"$message"'",
333
333
-
"createdAt": "'$(date -u +"%Y-%m-%dT%H:%M:%SZ")'"
334
334
-
}
335
335
-
}' \
336
336
-
"https://bsky.social/xrpc/com.atproto.repo.createRecord")
345
345
+
if [[ $(echo "$account1_post_response" | jq -r 'has("error")') == "true" ]]; then
346
346
+
echo "Error posting to $ACCOUNT1:"
347
347
+
echo "$account1_post_response" | jq
348
348
+
return 1
349
349
+
fi
337
350
338
338
-
if [[ $(echo "$account1_post_response" | jq -r 'has("error")') == "true" ]]; then
339
339
-
echo "Error posting to $ACCOUNT1:"
340
340
-
echo "$account1_post_response" | jq
341
341
-
return 1
342
342
-
fi
351
351
+
# Post to ACCOUNT2 as normal post
352
352
+
local account2_post_response=$(curl -s -X POST \
353
353
+
-H "Content-Type: application/json" \
354
354
+
-H "Authorization: Bearer $account2_jwt" \
355
355
+
-d '{
356
356
+
"collection": "app.bsky.feed.post",
357
357
+
"repo": "'$ACCOUNT2'",
358
358
+
"record": {
359
359
+
"$type": "app.bsky.feed.post",
360
360
+
"text": "'"$message"'",
361
361
+
"createdAt": "'$(date -u +"%Y-%m-%dT%H:%M:%SZ")'"
362
362
+
}
363
363
+
}' \
364
364
+
"https://bsky.social/xrpc/com.atproto.repo.createRecord")
343
365
344
344
-
# Post to ACCOUNT2 as normal post
345
345
-
local account2_post_response=$(curl -s -X POST \
346
346
-
-H "Content-Type: application/json" \
347
347
-
-H "Authorization: Bearer $account2_jwt" \
348
348
-
-d '{
349
349
-
"collection": "app.bsky.feed.post",
350
350
-
"repo": "'$ACCOUNT2'",
351
351
-
"record": {
352
352
-
"$type": "app.bsky.feed.post",
353
353
-
"text": "'"$message"'",
354
354
-
"createdAt": "'$(date -u +"%Y-%m-%dT%H:%M:%SZ")'"
355
355
-
}
356
356
-
}' \
357
357
-
"https://bsky.social/xrpc/com.atproto.repo.createRecord")
366
366
+
if [[ $(echo "$account2_post_response" | jq -r 'has("error")') == "true" ]]; then
367
367
+
echo "Error posting to $ACCOUNT2:"
368
368
+
echo "$account2_post_response" | jq
369
369
+
return 1
370
370
+
fi
358
371
359
359
-
if [[ $(echo "$account2_post_response" | jq -r 'has("error")') == "true" ]]; then
360
360
-
echo "Error posting to $ACCOUNT2:"
361
361
-
echo "$account2_post_response" | jq
362
362
-
return 1
363
363
-
fi
372
372
+
echo "done"
373
373
+
}
364
374
365
365
-
echo "done"
366
366
-
}
375
375
+
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
376
376
+
zstyle ':completion:*' list-colors "''${(s.:.)LS_COLORS}"
377
377
+
zstyle ':completion:*' menu no
378
378
+
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'ls --color $realpath'
379
379
+
zstyle ':fzf-tab:complete:__zoxide_z:*' fzf-preview 'ls --color $realpath'
367
380
368
368
-
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
369
369
-
zstyle ':completion:*' list-colors "''${(s.:.)LS_COLORS}"
370
370
-
zstyle ':completion:*' menu no
371
371
-
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'ls --color $realpath'
372
372
-
zstyle ':fzf-tab:complete:__zoxide_z:*' fzf-preview 'ls --color $realpath'
381
381
+
eval "$(terminal-wakatime init)"
382
382
+
'';
383
383
+
history = {
384
384
+
size = 10000;
385
385
+
path = "${config.xdg.dataHome}/zsh/history";
386
386
+
ignoreDups = true;
387
387
+
ignoreAllDups = true;
388
388
+
ignoreSpace = true;
389
389
+
expireDuplicatesFirst = true;
390
390
+
share = true;
391
391
+
extended = true;
392
392
+
append = true;
393
393
+
};
373
394
374
374
-
eval "$(terminal-wakatime init)"
375
375
-
'';
376
376
-
history = {
377
377
-
size = 10000;
378
378
-
path = "${config.xdg.dataHome}/zsh/history";
379
379
-
ignoreDups = true;
380
380
-
ignoreAllDups = true;
381
381
-
ignoreSpace = true;
382
382
-
expireDuplicatesFirst = true;
383
383
-
share = true;
384
384
-
extended = true;
385
385
-
append = true;
386
386
-
};
395
395
+
oh-my-zsh = {
396
396
+
enable = true;
397
397
+
plugins = [
398
398
+
"git"
399
399
+
"sudo"
400
400
+
"docker"
401
401
+
"git"
402
402
+
"command-not-found"
403
403
+
"colored-man-pages"
404
404
+
];
405
405
+
};
387
406
388
388
-
oh-my-zsh = {
389
389
-
enable = true;
390
407
plugins = [
391
391
-
"git"
392
392
-
"sudo"
393
393
-
"docker"
394
394
-
"git"
395
395
-
"command-not-found"
396
396
-
"colored-man-pages"
408
408
+
{
409
409
+
# will source zsh-autosuggestions.plugin.zsh
410
410
+
name = "zsh-autosuggestions";
411
411
+
src = pkgs.fetchFromGitHub {
412
412
+
owner = "zsh-users";
413
413
+
repo = "zsh-autosuggestions";
414
414
+
rev = "v0.7.0";
415
415
+
sha256 = "sha256-KLUYpUu4DHRumQZ3w59m9aTW6TBKMCXl2UcKi4uMd7w=";
416
416
+
};
417
417
+
}
418
418
+
{
419
419
+
# will source zsh-sytax-highlighting
420
420
+
name = "zsh-sytax-highlighting";
421
421
+
src = pkgs.fetchFromGitHub {
422
422
+
owner = "zsh-users";
423
423
+
repo = "zsh-syntax-highlighting";
424
424
+
rev = "0.8.0";
425
425
+
sha256 = "sha256-iJdWopZwHpSyYl5/FQXEW7gl/SrKaYDEtTH9cGP7iPo=";
426
426
+
};
427
427
+
}
428
428
+
{
429
429
+
# fzf tab completion
430
430
+
name = "fzf-tab";
431
431
+
src = pkgs.fetchFromGitHub {
432
432
+
owner = "aloxaf";
433
433
+
repo = "fzf-tab";
434
434
+
rev = "v1.1.2";
435
435
+
sha256 = "sha256-Qv8zAiMtrr67CbLRrFjGaPzFZcOiMVEFLg1Z+N6VMhg=";
436
436
+
};
437
437
+
}
397
438
];
398
439
};
399
440
400
400
-
plugins = [
401
401
-
{
402
402
-
# will source zsh-autosuggestions.plugin.zsh
403
403
-
name = "zsh-autosuggestions";
404
404
-
src = pkgs.fetchFromGitHub {
405
405
-
owner = "zsh-users";
406
406
-
repo = "zsh-autosuggestions";
407
407
-
rev = "v0.7.0";
408
408
-
sha256 = "sha256-KLUYpUu4DHRumQZ3w59m9aTW6TBKMCXl2UcKi4uMd7w=";
409
409
-
};
410
410
-
}
411
411
-
{
412
412
-
# will source zsh-sytax-highlighting
413
413
-
name = "zsh-sytax-highlighting";
414
414
-
src = pkgs.fetchFromGitHub {
415
415
-
owner = "zsh-users";
416
416
-
repo = "zsh-syntax-highlighting";
417
417
-
rev = "0.8.0";
418
418
-
sha256 = "sha256-iJdWopZwHpSyYl5/FQXEW7gl/SrKaYDEtTH9cGP7iPo=";
419
419
-
};
420
420
-
}
421
421
-
{
422
422
-
# fzf tab completion
423
423
-
name = "fzf-tab";
424
424
-
src = pkgs.fetchFromGitHub {
425
425
-
owner = "aloxaf";
426
426
-
repo = "fzf-tab";
427
427
-
rev = "v1.1.2";
428
428
-
sha256 = "sha256-Qv8zAiMtrr67CbLRrFjGaPzFZcOiMVEFLg1Z+N6VMhg=";
429
429
-
};
430
430
-
}
431
431
-
];
432
432
-
};
441
441
+
programs.zoxide = {
442
442
+
enable = true;
443
443
+
enableZshIntegration = true;
444
444
+
};
433
445
434
434
-
programs.zoxide = {
435
435
-
enable = true;
436
436
-
enableZshIntegration = true;
437
437
-
};
438
438
-
439
439
-
programs.fzf = {
440
440
-
enable = true;
441
441
-
enableZshIntegration = true;
442
442
-
colors = {
443
443
-
bg = lib.mkForce "";
446
446
+
programs.fzf = {
447
447
+
enable = true;
448
448
+
enableZshIntegration = true;
449
449
+
colors = {
450
450
+
bg = lib.mkForce "";
451
451
+
};
444
452
};
445
445
-
};
446
453
447
447
-
programs.atuin = {
448
448
-
enable = true;
449
449
-
settings = {
450
450
-
auto_sync = true;
451
451
-
sync_frequency = "5m";
452
452
-
sync_address = "https://api.atuin.sh";
453
453
-
search_mode = "fuzzy";
454
454
-
#session_path = config.age.secrets."atuin-session".path;
455
455
-
#key_path = config.age.secrets."atuin-key".path;
456
456
-
update_check = false;
457
457
-
style = "auto";
458
458
-
sync.records = true;
459
459
-
dotfiles.enabled = false;
454
454
+
programs.atuin = {
455
455
+
enable = true;
456
456
+
settings = {
457
457
+
auto_sync = true;
458
458
+
sync_frequency = "5m";
459
459
+
sync_address = "https://api.atuin.sh";
460
460
+
search_mode = "fuzzy";
461
461
+
#session_path = config.age.secrets."atuin-session".path;
462
462
+
#key_path = config.age.secrets."atuin-key".path;
463
463
+
update_check = false;
464
464
+
style = "auto";
465
465
+
sync.records = true;
466
466
+
dotfiles.enabled = false;
467
467
+
};
460
468
};
461
469
};
462
470
}