Log In  

Cart #picotron_utilities-0 | 2024-03-22 | Embed ▽ | License: CC4-BY-NC-SA
20

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

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!
P#143436 2024-03-17 04:12 ( Edited 2024-03-22 12:42)

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!).

P#143926 2024-03-20 06:13

@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.

P#143963 2024-03-20 17:37
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 :)

P#144087 2024-03-21 22:58
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.)

P#144103 2024-03-22 03:00

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

P#144291 2024-03-24 12:53

@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.

P#144295 2024-03-24 14:12

[Please log in to post a comment]