sayanarijit / xplr

A hackable, minimal, fast TUI file explorer
https://xplr.dev
MIT License
4.23k stars 80 forks source link

[complete newbie] struggling to read user input and execute command #734

Closed Houdiee closed 3 days ago

Houdiee commented 4 days ago

I'm trying to have an "open-with" functionality where I can specify an application to open a node. So far I have the following:

xplr.config.modes.custom.open_with = {
  name = "open with",
  key_bindings = {
    on_key = {
      ["tab"] = {
        help = "try complete",
        messages = {
          { CallLuaSilently = "builtin.try_complete_path" }
        }
      },

      ["enter"] = {
        help = "submit",
        messages = {
          BashExec0 = [===[
            ${XPLR_INPUT_BUFFER:?} ${XPLR_FOCUS_PATH:?}
          ]===],
          "PopMode"
        }
      }
    },

    default = {
      messages = {
        "UpdateInputBufferFromKey"
      }
    }
  }
}

but when i press enter nothing happens. this isnt even an issue I just need help :cry:

sayanarijit commented 3 days ago

You need to spawn the command as a background process, by appending & or using nohup.

Alternatively check out https://github.com/Junker/nuke.xplr

Houdiee commented 3 days ago

You need to spawn the command as a background process, by appending & or using nohup.

Alternatively check out https://github.com/Junker/nuke.xplr

unfortunately I can't get any command to work in my BashExec after pressing enter in my input buffer. I've even tried directly copying stupid simple BashExec's from the official example source configuration such as:

xplr.config.modes.builtin.default.key_bindings.on_key["X"] = {
  help = "open",
  messages = {
    {
      BashExecSilently0 = [===[
        xdg-open "${XPLR_FOCUS_PATH:?}"
      ]===],
    },
  },
}

But even though this works in modes.bulitin.default (by pressing X) I cant seem to get the exact same bash exec to work in my custom mode with the following:

xplr.config.modes.custom.open_with = {
  name = "open with",
  key_bindings = {
    on_key = {
      ["tab"] = {
        help = "try complete",
        messages = {
          { CallLuaSilently = "builtin.try_complete_path" }
        }
      },

      ["enter"] = {
        help = "submit",
        messages = {
          BashExec0 = [===[
            xdg-open "${XPLR_FOCUS_PATH}"
          ]===],
          "PopMode"
        }
      }
    },

    default = {
      messages = {
        "UpdateInputBufferFromKey",
      }
    }
  }
}

when I press enter still nothing happens? and I'm just all around very lost with this. And help would be greatly appreciated! :smiling_face_with_tear:

sayanarijit commented 3 days ago
      ["enter"] = {
        help = "submit",
        messages = {
          BashExec0 = [===[
            xdg-open "${XPLR_FOCUS_PATH}"
          ]===],
          "PopMode"
        }

->

      ["enter"] = {
        help = "submit",
        messages = {
          { BashExec0 = [===[ xdg-open "${XPLR_FOCUS_PATH}" ]===] },
          "PopMode",
        }
Houdiee commented 3 days ago

oh my :sob: was all i was missing those brackets. You truly are a wizard, than you