How do I add new commands or modify existing ones?

I am trying to customize nyxt with new functions but I can’t figure out how. The manual shows an example command being defined #, but does not say WHERE it should be defined. Using the repl works but the changes aren’t persisted. I tried defining a new command in numerous files but none worked. I tried also modifying the copy-url function slightly to give it a new name in the buffer.lisp file, but those changes where not picked up either.

So, suppose I want a new command that copies both url and title to the clipboard together, where should I define that command? And, if I want to modify the current copy-url command, how should I do that? I spent hours reading the manual but made no progress.

I installed nyxt from the arch repo.

New or modified versions of commands need to be added to your config file, which is located at ~/.config/nyxt/config.lisp. If you read the manual from Nyxt itself (visit URL nyxt:manual#configuration), you’ll find this information in detail.

To modify an existing command, you just need to define it with the same name. Example:

(define-command copy-url ()
  "Save current URL to clipboard."
  (echo "I am a modified version of the copy-url command."))

All feedback on the manual is welcome and I’d like to encourage you to open a PR so that we improve it together. Thanks!

Ah yes that does the trick. I was flicking between the manual in nyxt and the webpage and assumed they where the same, but I will take another look and see if a PR is in order. Cheers!

They’re the same, and they’re always in sync. But when you open Nyxt browser: Documentation you’ll see that the the excerpt Any settings can be overridden manually by /home/doe/.config/nyxt/config.lisp differs from what you see from Nyxt. I.e. “doe” is replaced by your system’s account name. It may confuse some people.

Do you know why I can fuzzy search existing commands, so I can type copy- in the command buffer and copy-url and copy-title show up, but to find my new command I have to type it’s whole name: copy-url-and-title, and then it shows as a lisp expression.

I can’t reproduce the issue.

You need to show me how you have defined the command.

Adding (define-command hello-world () "Test" (echo "Hello!")) to the config, allows you to call the command hello-world when you invoke execute-command.

Using your example (and having an otherwise empty config), I have to type the whole hello-world for it to show up, and it then shows under Lisp expression. I just wondered why the difference with other commands which allow partial matching?

@thomasthomas I get it, but unfortunately I can’t reproduce it…

I assume that you do not see what is depicted below.

I installed 3.9.0 from guix, too, in addition to the aur version but it’s the same.

Well, I can’t tell what the issue is, but it’s certainly coming from your side. I have no other explanation.

Aren’t you defining it with defun instead of define-command?

I just copied it exactly as below into an empty config.lisp

(define-command hello-world () “Test” (echo “Hello!”))

I’m seeing those quotes again…

@thomasthomas actually I know why the command isn’t listed.

You need to define it via (define-command-global hello-world () "Test" (echo "Hello!")). Notice define-command-global instead of define-command.

It’s a mystery to me why I was able to append the command to my config file via define-command and it worked… Sorry about that.

Beautiful, thanks.

As to those curly quotes, that is bizare, I just double checked my clipboard history and they are straight quotes.

(define-command hello-world () “Test” (echo “Hello!”))

edit - it’s the forum.

Thank you @thomasthomas I see now the problem, and have changed it in the settings "this" should work now.