Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

nushell/modules/start.nu

Raw
def resources [token: record] {
    if $token.text =~ '^[A-Za-z][A-Za-z0-9+.-]*://' or $token.text =~ '^(mailto|tel|data):' {
        []
    } else {
        # Nested completion spans are relative to this fragment, not the line.
        $token.text | commandline complete --type path --detailed | reject span
    }
}

# Opens the given resource in the operating systems preferred application.
export def main [
    ...rest: string@resources # Paths or URLs the OS should open for you.
] {
    if $env.WIN32 {
        $rest | each { |thing| ^start $thing}
    } else {
        $rest | each { |thing| ^xdg-open $thing }
    }
}