Log In  

"Open in Terminal" in FileNav!

Here, you can see it big and clear, a "Open in Terminal" option in FileNav!

How did I do this?

By modifying "/system/apps/terminal.lua" and "/system/apps/filenav.p64", you can do this yourself!

Before modifying anything in "/system", if you want it to stay after reboot, check out my Localize System Tool!

NOTE: Localizing your system folder can be very dangerous. It can brick your Picotron installation, and even allow malicious carts to install themselves and harm your actual OS drive. This demonstration wont do as such, but be careful when installing untrusted carts. This will also keep your system at the same version that it was localized at, and you will need to unlocalize your system to update, and you will lose all of your changes

An alternative to localizing your system is sedish.
I don't have any experience with it and don't know how to go about using my Terminal and FileNav mods with it, but it seems like a much more safe (and slightly more update-friendly) way of installing my mods.

Terminal.lua

You can simply double-click this in FileNav, or manually open it in code editor to modify it.

Around Line 25 of terminal.lua, replace:
if (pwd() == "/system/apps") cd("/")
with:

cd(env().path)

local path0 = env().argv[1] or "."

path = fullpath(path0)

cd(path)

if (pwd() == "/system/apps") cd("/")

This simply allows the terminal command to either launch in the current directory, or the directory specified in argv! This is what my FileNav mod uses for "Open in Terminal"

FileNav.p64

FileNav is not as easy to modify. Open terminal, and use: load /system/apps/filenav.p64
Then, go to the code editor, and open it's "main.lua"

Around Line 69, (nice), insert:

menuitem{
    id="open_in_terminal",    
    label = "\^:7f7d7b7d7f083e00 Open in Terminal",
    action = function()
        create_process("/system/apps/terminal.lua", {path = pwd()})
    end
}

right under the other "menuitems"

Make sure to save your FileNav mod!

When you're done, you'll see the new option when you launch a new FileNav instance, or after you reboot.

P#150213 2024-06-21 15:25 ( Edited 2024-06-21 19:01)

EDIT: Now fully works, I just made a typo lol

I was able to get half of this to work using the sedish method. The open in terminal option is added and opens a terminal just fine, but it's always in root regardless of where I am when I open one. Here's my setup in startup.lua if anyone wants to take a shot at it.

include "sedish.lua"

sedish("/system/apps/terminal.lua", {
    {-- Mod: Add Open in Terminal to context menu
        [[if (pwd() == "/system/apps") cd("/")]],
        [[cd(env().path)

        local path0 = env().argv[1] or "."

        path = fullpath(path0)

        cd(path) 

        if (pwd() == "/system/apps") cd("/")]]
    }
})

sedish("/system/apps/filenav.p64/main.lua", {
    {-- Mod: Add Open in Terminal to context menu
    [[  -- Rename File, File Info: added by update_file_info_menu_item()]],
    [[
    menuitem{
        id="open_in_terminal",    
        label = "\^:7f7d7b7d7f083e00 Open in Terminal",
        action = function()
            create_process("/system/apps/terminal.lua", {path = pwd()})
        end
    }
        -- Rename File, File Info: added by update_file_info_menu_item()]]
    }
})
P#150234 2024-06-21 20:57 ( Edited 2024-06-23 06:52)

@Agent7 I think this is because you need to include the comment from terminal.lua!

Full replacement line should be: if (pwd() == "/system/apps") cd("/") -- start in root instead of location of terminal.lua

P#150236 2024-06-21 21:14

turns out I just made a typo in the filename, whoops

P#150241 2024-06-21 22:16

[Please log in to post a comment]