Log In  


Cart #picotron_utilities-2 | 2024-11-12 | Embed ▽ | License: CC4-BY-NC-SA
26

I made a handful of commandline utilities for picotron that you might find useful.

https://github.com/Rayquaza01/picotron-utilities

So far, Picotron Utilities has:

cat - print files
touch - create new files
tree - print tree view of a directory
wget - download a file using fetch()
grep - search in a file or recursively search through all files in a folder
frange - print a file or range w/ line numbers
pwd - print the current working directory
echo - print given arguments
fd - search for a file name
stat - print file status and metadata

Installing as a Yotta Package

You can install the utilities included in this cart with yotta util install #picotron_utilities

Installing as a Bundle Command

You can install this cartridge as a bundle command by saving it to your utility path.

load #picotron_utilities
save /appdata/system/util/busybox

Once installed, you can run a bundled command by passing that command as an argument, like busybox tree.

Installing Manually

You can copy the lua files from the repo to /appdata/system/util manually. These files are also inside the cartridge's exports folder.

Changelog

[2024-03-18]

  • Added pwd command (#2, thanks jesstelford!)
  • frange supports negative start values (e.g. frange file.txt -10 will print last 10 lines) (#3, thanks pancelor!)
    • This pr also changes the method frange uses to build it's output string. I've also added those changes to grep and tree
  • grep now supports lua patterns. See Programming in Lua 20.2 - Patterns
    • If you want to search for a character with a special meaning like ., you'll need to escape it with %.

[2024-03-22] - v1.0.0

  • Added a comment that points back to the repo to the top of every script.
  • Made an installable cartridge version.
    • If you have any trouble using either of the new installation methods, please let me know!

[2024-11-03] - v1.1.0

[2024-11-12] - v1.1.1

26


1

Cool, I was thinking that would need to write some of them, good to see that it's already done!

You could bundle them in a cart, similar to how git works (ie sh cat ... sh pwd).

Another option we could see if you can have carts download other carts (what could possibly go wrong!).


@Nunuvin I was thinking about making a yotta package to make it installable, but I was hesitant because the names of these utils are a little generic. (If someone else created a different version of cat, for instance, I wouldn't want my cart to overwrite that).

But bundling them all together under a single command name is an interesting idea! I'm probably going to try that out.


1

This is great! I've got these installed, thank you! As someone who daily-drives linux, though, I keep trying to make pipelines out of these... lol. I'll learn not to.

@arnaught I saw your concern about yotta overwriting files, and so I made some improvements in yotta v1.1 to how it handles such file conflicts during installation and uninstallation to give users some choice in either leaving, backing-up, or overwriting when such conflicts occur during install.

That being said.. the idea of a bundled option is cool, too. Busybox does this - on a lot of small embedded linux systems, you'll just be dropped to sh (not even bash!) and if you're lucky, common commands like you've made will be aliased to '/bin/busybox', which will determine which subcommand to run based on the invocation name... but often, you just have to know to invoke them 'under' busybox like /bin/busybox ls /path/to/dir. It is pretty easy to grow accustomed to :)


1

@ahrotahn I know what you mean with the pipelines lol. I have open aliased to vim because I keep accidentally trying to edit files with vim!

Good to hear yotta backs up files now. I'm planning on doing a hybrid approach. All the .lua utils will be stored in exports/appdata/system/util, so the cart will be installable with yotta.

But the cart itself will also be a bundled utility. So if you saved it as busybox.p64, for example, you could run a bundled command like busybox tree.

(And thanks for reminding me of busybox. Continuing in the pattern of copying linux command names, that'll be what I suggest saving the cart as if you want to install it as a bundled command.)


cat doesnt work with any .p64 files for some reason, is that the correct behavior?


@egordorichev Yes. .p64 and .p64.png files are treated as folders by Picotron, not files.

You can cat something inside a .p64, like cat cart.p64/main.lua, but you can't cat the .p64 itself.


can you call tree on a p64 cart?


@merwok yes, you can call tree on a .p64. Anywhere ls works, tree should also work.



[Please log in to post a comment]