o
odin.langpkg.dev
packages / library / bifrost

bifrost

8df85fflibrary

quick navigate between stored directories

No license · updated 2 months ago

Bifrost

A quick project directory navigator

Motivation: dont navigate pathes, dont handle sessions. just jump from A to B. replaces the bash script that i used before. Might be extended in the future. Also a bit of playing around with Odin.

I know there are solutions for this.

Bifrost: is a burning bridge that reaches between Midgard (Earth) and Asgard, the realm of the gods. from north mythology Bifröst

Usage

bifrost add <projname> [dir]    # Add a new project bridge
bifrost <projname>              # Jump to project directory
bifrost ls                      # List all bridges
bifrost install                 # Add wrapper/PATH to shell config

since "change dir" within the project would only change the dir of the child process (and thus exit when the child process exits) bifrost "projname" can not "jump" to the proj path as a bash script could. Therefor the install command has to be run, which introduces a "change dir" wrapper around the jump

Initially my goal was to do the actual jump, but this turns out to be quit the hack. We could (on linux only) use ptrace IF we would be able to and used ptrace to inject a chdir sys call (whcih apparently requires CAP_SYS_PTRACE or specific /proc/sys/kernel/yama/ptrace_scope settings) $PWD would stay out of sync, we would be attaching to a live, busy process (would need to attach, stop, save all registers, allocate memory, inject syscall, restore...), and if any async stuff would happen (completion for example) this state could/would be broken. I still might dive into this at some point...