Recommended way to process text/tags within a file? (ex. `cat file` which contains [B]text[/] )
MostHated opened this issue · comments
Hey there, I started playing around with this last night and wanted to use it to spruce up some of my terminal text that I have generated via Jobber (similar to cron) which gets output into files on a ram drive, then when I open the terminal it just does cat file
. I wanted to add some tags into the text for color and bold, etc to start out, but I was not able to get it to actually process those tags to display.
This is the overall setup:
# -- script to check for updates that runs every 10-15 minutes
if [[ $UPDATESTATUS == false ]]; then
echo 'UPDATE_COMPLETE=true' >/home/mosthated/.updatestatus
sudo apt-get update -qq
UPDATES=$(sudo apt-get dist-upgrade --simulate | grep Inst | awk '{print $2}')
COUNT=$(printf "%s\n" "$UPDATES" | grep -v "^$" | wc -l)
else
exit 0
fi
UPDATECOUNT="[bold green]${COUNT}[/] update(s) available"
kvset updates "${UPDATECOUNT}" # -- outputs the above string to ramdrive
Then in my .zshrc
I have:
cat /mnt/ramdisk/.kv/updates
The things I tried to do were as follows:
rich /mnt/ramdisk/.kv/updates --print # just printed out the path
cat /mnt/ramdisk/.kv/updates | rich - # displayed the text in the file, but just as plain text showing the [tags], not processing them
rich cat /mnt/ramdisk/.kv/updates --print
rich $(cat /mnt/ramdisk/.kv/updates) --print
Is there a proper way to accomplish this, or is this out of scope of the intended usage of the cli?
Thanks,
-MH
I think that the last example may work if you enclose it in quotes.
If it doesn't, it may be worth adding a switch that says print console markup from file. Will consider that for the next release.
I knew I should have tried that, lol. That seems to have done the job... for the most part?
Its working well, minus an emoji I tried to add just to see if it would work. I don't know if it should be working, I saw the Rich library had the capability on the python side, but not sure if that necessarily means it should be working with the CLI, too? I don't recall seeing it mentioned in the readme of this lib.
Did you add the --emoji
switch?
Oh, no, I didn't realize there was one. I searched the readme for 'emoji' and didn't see mention of anything, so I just figured that --print
would have worked. I added it now, and of course, it's working as expected. Thanks again. 👍