53
53
<key >vitoclose </key >
54
54
<false />
55
55
</dict >
56
+ <dict >
57
+ <key >destinationuid </key >
58
+ <string >ECACC8FF-09ED-4D32-8C85-947E65E0ACCD </string >
59
+ <key >modifiers </key >
60
+ <integer >524288 </integer >
61
+ <key >modifiersubtext </key >
62
+ <string ></string >
63
+ <key >vitoclose </key >
64
+ <false />
65
+ </dict >
56
66
</array >
57
67
<key >3CAD799C-0423-4214-B0BC-2BFE6B9B7E98 </key >
58
68
<array >
124
134
<key >escaping </key >
125
135
<integer >102 </integer >
126
136
<key >script </key >
127
- <string >FILE="ports"
137
+ <string >ALFRED_WORKFLOW_DATA="${alfred_workflow_data}"
138
+ FILE="${ALFRED_WORKFLOW_DATA}/ports"
128
139
INPUT="${currPort}" # take the input from command line argument
129
140
DEAFAULT_VALUE="${myPorts}"
130
141
142
+ if [ ! -d "${ALFRED_WORKFLOW_DATA}" ]; then
143
+ mkdir -p "${ALFRED_WORKFLOW_DATA}"
144
+ fi
131
145
132
146
# If the file does not exist, create it with initial value
133
147
if [ ! -f "$FILE" ]; then
134
- echo "$DEAFAULT_VALUE" > $FILE
148
+ _DEAFAULT_VALUE=$(echo "$DEAFAULT_VALUE" | tr -dc '0-9,')
149
+ echo "$_DEAFAULT_VALUE" > "$FILE"
135
150
fi
136
151
152
+ # If the file does not exist, create it with initial value
153
+ # if [ ! -f "$FILE" ]; then
154
+ # echo "$DEAFAULT_VALUE" > "$FILE"
155
+ # fi
156
+
137
157
if [ -z "$INPUT" ]; then
138
158
echo "Input is empty, no action performed."
139
159
exit 0
140
160
fi
141
161
142
162
# Check if the input already exists in the file
143
- if ! grep -q $INPUT $FILE; then
163
+ if ! grep -q " $INPUT" " $FILE" ; then
144
164
# If not, append the input to the file
145
- echo -n ",$INPUT" >> $FILE
165
+ echo -n ",$INPUT" >> " $FILE"
146
166
fi </string >
147
167
<key >scriptargtype </key >
148
168
<integer >1 </integer >
@@ -325,6 +345,54 @@ fi</string>
325
345
<key >version </key >
326
346
<integer >1 </integer >
327
347
</dict >
348
+ <dict >
349
+ <key >config </key >
350
+ <dict >
351
+ <key >concurrently </key >
352
+ <false />
353
+ <key >escaping </key >
354
+ <integer >102 </integer >
355
+ <key >script </key >
356
+ <string >ALFRED_WORKFLOW_DATA="${alfred_workflow_data}"
357
+ FILE="${ALFRED_WORKFLOW_DATA}/ports"
358
+ INPUT=$1
359
+
360
+ if [ ! -d "${ALFRED_WORKFLOW_DATA}" ]; then
361
+ echo "no this workflow folder"
362
+ exit 0
363
+ fi
364
+
365
+ # If the file does not exist, create it with initial value
366
+ if [ ! -f "$FILE" ]; then
367
+ echo "no user ports data file"
368
+ exit 0
369
+ fi
370
+
371
+ if [ -z "$INPUT" ]; then
372
+ echo "Input is empty, no action performed."
373
+ exit 0
374
+ fi
375
+
376
+
377
+ # remove the port
378
+ sed -i '' "s/[[:< :]]$INPUT[[:> :]]//g" "$FILE"
379
+
380
+ # remove consecutive or leading/trailing commas.
381
+ sed -i '' -e $'s/,,*/,/g;s/^,//;s/,$//' "$FILE" </string >
382
+ <key >scriptargtype </key >
383
+ <integer >1 </integer >
384
+ <key >scriptfile </key >
385
+ <string ></string >
386
+ <key >type </key >
387
+ <integer >0 </integer >
388
+ </dict >
389
+ <key >type </key >
390
+ <string >alfred.workflow.action.script </string >
391
+ <key >uid </key >
392
+ <string >ECACC8FF-09ED-4D32-8C85-947E65E0ACCD </string >
393
+ <key >version </key >
394
+ <integer >2 </integer >
395
+ </dict >
328
396
</array >
329
397
<key >readme </key >
330
398
<string >
@@ -355,6 +423,8 @@ fi</string>
355
423
</dict >
356
424
<key >205BBC80-E258-474A-AA68-9DDC4B2C8EA8 </key >
357
425
<dict >
426
+ <key >note </key >
427
+ <string >store port </string >
358
428
<key >xpos </key >
359
429
<real >695 </real >
360
430
<key >ypos </key >
@@ -370,9 +440,9 @@ fi</string>
370
440
<key >4D59CF3D-7FD5-417D-B25C-C5FEC1306A00 </key >
371
441
<dict >
372
442
<key >xpos </key >
373
- <real >700 </real >
443
+ <real >695 </real >
374
444
<key >ypos </key >
375
- <real >410 </real >
445
+ <real >390 </real >
376
446
</dict >
377
447
<key >7B64AF79-0000-4978-B325-3163AE16459A </key >
378
448
<dict >
@@ -381,6 +451,15 @@ fi</string>
381
451
<key >ypos </key >
382
452
<real >505 </real >
383
453
</dict >
454
+ <key >ECACC8FF-09ED-4D32-8C85-947E65E0ACCD </key >
455
+ <dict >
456
+ <key >note </key >
457
+ <string >remove port from cache </string >
458
+ <key >xpos </key >
459
+ <real >695 </real >
460
+ <key >ypos </key >
461
+ <real >540 </real >
462
+ </dict >
384
463
</dict >
385
464
<key >userconfigurationconfig </key >
386
465
<array />
0 commit comments