Skip to content

Commit

Permalink
fix: Correct syntax error with more complicated tips due to sed
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleGospo committed Jan 29, 2024
1 parent cced226 commit 68c5d6a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion usr/libexec/ublue-motd
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
#!/usr/bin/bash
escape() {
sed 's/[&/\]/\\&/g' <<< "$1"
}

TIP_FILE=$(ls "/usr/share/ublue-os/motd/tips/"*".md" | shuf -n 1)
if [[ -f "$TIP_FILE" ]]; then
IMAGE_INFO="/usr/share/ublue-os/image-info.json"
IMAGE_NAME=$(jq -r '."image-name"' < $IMAGE_INFO)
IMAGE_NAME_ESCAPED=$(escape "$IMAGE_NAME")
IMAGE_TAG=$(jq -r '."image-tag"' < $IMAGE_INFO)
IMAGE_TAG_ESCAPED=$(escape "$IMAGE_TAG")
TIP=$(shuf -n 1 "$TIP_FILE")
sed -e "s/%IMAGE_NAME%/$IMAGE_NAME/g" -e "s/%IMAGE_TAG%/$IMAGE_TAG/g" -e "s/%TIP%/$TIP/g" /usr/share/ublue-os/motd/bluefin.md | /usr/bin/glow -s auto -
TIP_ESCAPED=$(escape "$TIP")
sed -e "s/%IMAGE_NAME%/$(escape $IMAGE_NAME_ESCAPED)/g" -e "s/%IMAGE_TAG%/$IMAGE_TAG_ESCAPED/g" -e "s/%TIP%/$TIP_ESCAPED/g" /usr/share/ublue-os/motd/bluefin.md | /usr/bin/glow -s auto -
fi
2 changes: 1 addition & 1 deletion usr/share/ublue-os/motd/bluefin.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
| `ujust toggle-user-motd` | Toggle this banner on/off |
| `ujust bluefin-cli` | Configure the terminal (Alpha) |

*Tip: %TIP%*
Tip: %TIP%

- 󰊤 [Issues](https://issues.projectbluefin.io)
- 󰈙 [Documentation:](http://docs.projectbluefin.io/)
Expand Down

0 comments on commit 68c5d6a

Please sign in to comment.