broot icon indicating copy to clipboard operation
broot copied to clipboard

Broot throws an error when trying to remap `:cd`

Open cheap-glitch opened this issue 3 years ago • 1 comments

Describe the bug I wanted to "inverse" the mappings to open/enter directories, so I tried to remap :cd. The following error occurred:

Bad configuration: not a known internal: cd
Full log
08:27:28.977 [INFO] cli_log: Starting broot v1.2.8 with log level DEBUG
08:27:28.978 [DEBUG] broot::cli: Conf::from_default_location() took 86.003µs
08:27:28.978 [DEBUG] broot::cli: config: Conf {
    files: [
        "/home/florent/.config/broot/conf.hjson",
    ],
    default_flags: None,
    date_time_format: None,
    verbs: [
        VerbConf {
            invocation: None,
            internal: Some(
                ":cd",
            ),
            external: None,
            execution: None,
            cmd: None,
            cmd_separator: None,
            key: Some(
                "enter",
            ),
            keys: [],
            shortcut: None,
            leave_broot: None,
            from_shell: None,
            apply_to: Some(
                "directory",
            ),
            set_working_dir: None,
            description: None,
        },
    ],
    skin: None,
    special_paths: {},
    search_modes: None,
    disable_mouse_capture: None,
    cols_order: None,
    show_selection_mark: None,
    ext_colors: {},
    syntax_theme: None,
    true_colors: None,
    icon_theme: None,
    modal: None,
    max_panels_count: None,
}
08:27:28.979 [WARN] broot: Error: Bad configuration: not a known internal: cd
08:27:28.979 [INFO] broot: bye

To Reproduce Setup a config file with the following contents:

{
	verbs: [
		{
			apply_to: directory
			key:      enter
			internal: ":cd"
		}
	]
}

Expected behavior The :cd verb should be remapped to Enter.

Configuration

  • broot version: 1.2.8
  • OS: ArchLinux
  • Version: latest

Side note: broot is amazing, keep up the good work!

cheap-glitch avatar Mar 20 '21 07:03 cheap-glitch

I confirm the problem.

Here's a workaround:

	{
		apply_to: directory
		key: "enter"
		external: "cd {file}"
		from_shell: true
	}

Canop avatar Mar 20 '21 08:03 Canop

I tried the above workaround and it works. However, apparently I can't map enter with any modifier while also keeping the enter shortcut. If I map ctrl-enter the above shortcut will not be triggered (only the default enter which I'd like to keep).

sztomi avatar Mar 15 '23 10:03 sztomi

@sztomi you have another problem here: many key combinations can't be received by a terminal application. The exact list depends on the OS, terminal, and their settings. You can use a program like print_key to find usable shortcuts. For example, this should work:

{
	apply_to: directory
	key: "alt-u"
	external: "cd {file}"
	from_shell: true
}

Canop avatar Mar 15 '23 10:03 Canop

@Canop thank you! That's indeed what the issue was.

sztomi avatar Mar 15 '23 10:03 sztomi

Coming back to this issue, I think using external: "cd {file}" is the right and most versatile way to define a change directory alternative. So closing as "works as intended".

Canop avatar Mar 23 '23 15:03 Canop

The original issue persists, i am unable to remap the internal command :cd in broot 1.25.0

Schweber avatar Sep 20 '23 16:09 Schweber

@Schweber Can you use external: "cd {file}" ?

Canop avatar Sep 20 '23 17:09 Canop

Yes but i don't think that this is "works as intended". If that were the case, the documentation or at least the error message should reflect that in my opinion.

Presently, the documentation lists :cd as an internal but broot reports Bad configuration: not a known internal: cd. This is not the end of the world of course but it confused me, until i found this issue.

Schweber avatar Sep 20 '23 22:09 Schweber

Yes, the documentation is wrong. My question was just a question, not a rebuff: I'll dive again into this problem.

Canop avatar Sep 21 '23 05:09 Canop

Thank you!

I don't know if this is a problem with broot or with my local setup/shell but when i use e.g. { key: "enter", from_shell: true, execution: "cd {directory}" }, then broot exits and the cwd is changed (i can see it when entering pwd) but the prompt of my shell is not updated to reflect that. Only after i e.g. run a command is the prompt updated with the new cwd.

I am using the fish shell with the tide prompt with broot 1.25 on NixOS and launch broot with the br shell wrapper.

Schweber avatar Sep 21 '23 07:09 Schweber

@Schweber Can you please create another issue with this tide related problem ?

Canop avatar Sep 22 '23 19:09 Canop