Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Alt-n does not work after invoking atuin in Ghostty terminal (Fine with Kitty) #2611

Open
1 task done
seungjin opened this issue Mar 6, 2025 · 8 comments
Open
1 task done
Labels
bug Something isn't working

Comments

@seungjin
Copy link

seungjin commented Mar 6, 2025

What did you expect to happen?

Alt-n in Atuin Tui;
alt + 1 to alt + 9: Select item by the number located near it.

What happened?

Found that Alt-n in Atuin tui is not working on Ghostty terminal.
It works fine with Kitty though.
I am using Linux with Fish.

Atuin doctor output

Atuin Doctor
Checking for diagnostics


Please include the output below with any bug reports or issues

{
  "atuin": {
    "version": "18.4.0",
    "sync": {
      "cloud": true,
      "records": true,
      "auto_sync": true,
      "last_sync": "2025-03-06 6:10:48.051354792 +00:00:00"
    },
    "sqlite_version": "3.46.0"
  },
  "shell": {
    "name": "fish",
    "default": "fish",
    "plugins": [
      "atuin"
    ],
    "preexec": "built-in"
  },
  "system": {
    "os": "Fedora Linux",
    "arch": "x86_64",
    "version": "41",
    "disks": [
      {
        "name": "/dev/mapper/luks-HIDDEN",
        "filesystem": "btrfs"
      },
      {
        "name": "/dev/mapper/luks-HIDDEN",
        "filesystem": "btrfs"
      },
      {
        "name": "/dev/mapper/luks-HIDDEN",
        "filesystem": "btrfs"
      },
      {
        "name": "/dev/mapper/luks-HIDDEN",
        "filesystem": "btrfs"
      },
      {
        "name": "/dev/nvme0n1p2",
        "filesystem": "ext4"
      },
      {
        "name": "/dev/mapper/luks-HIDDEN",
        "filesystem": "btrfs"
      },
      {
        "name": "/dev/nvme0n1p1",
        "filesystem": "vfat"
      },
      {
        "name": "sysext",
        "filesystem": "overlay"
      }
    ]
  }
}

Code of Conduct

  • I agree to follow this project's Code of Conduct
@seungjin seungjin added the bug Something isn't working label Mar 6, 2025
@slamp
Copy link
Contributor

slamp commented Mar 9, 2025

@seungjin which version of fish are you using?

@matthewberryman
Copy link
Contributor

matthewberryman commented Mar 11, 2025

Have reproduced under fish v3.7.1 and fish v4.0.0 on Linux Ghostty v1.1.2, also atuin v18.4.0. Other shells e.g. bash are also affected. No problems with the macOS build of Ghostty v1.1.2 running fish v3.7.0 or fish v4.0.0 either directly on my Mac or via ssh to Linux boxes with either fish version. The issue seems specific to Ghostty on Linux with any shell and atuin. A workaround is to set ctrl_n_shortcuts = true in atuin's config.toml file ( ~/.config/atuin/config.toml )

@matthewberryman
Copy link
Contributor

matthewberryman commented Mar 11, 2025

showkey -a output under the default GNOME terminal with Ubuntu:

^[4 	 27 0033 0x1b
 	 52 0064 0x34
^[4 	 27 0033 0x1b
 	 52 0064 0x34
^[5 	 27 0033 0x1b
 	 53 0065 0x35

Ghostty prints nothing.

Turns out Ghostty maps alt+numbers onto its own tab switcher (e.g. alt+3 moves to the third tab, if present, on Linux).

This also affects other CLI tools like tmux, the solution is here: ghostty-org/ghostty#6084 (comment)

So either add the following to ~/.config/ghostty/config:

keybind=alt+one=unbind
keybind=alt+two=unbind
keybind=alt+three=unbind
keybind=alt+four=unbind
keybind=alt+five=unbind
keybind=alt+six=unbind
keybind=alt+seven=unbind
keybind=alt+eight=unbind
keybind=alt+nine=unbind

to preserve the default atuin behaviour (and lose the ability to switch tabs using alt+number)
or to ~/.config/atuin/config.toml add

ctrl_n_shortcuts = true

Since ghostty sets TERM=xterm-ghostty maybe atuin could detect this and either warn or use ctrl-number keybindings (my preference is to just warn for consitency's sake)? @ellie

@matthewberryman
Copy link
Contributor

I've opened atuinsh/docs#89 to address this issue. Once that is merged (if happy), I reckon the best place to give a warning is in the installer script and link to the updated docs. Most people who install via other means are more likely to read the docs (maybe I'm being a bit optimistic here) so I guess that's the best approach.

@seungjin
Copy link
Author

Yes. Mine is fish, version 4.0.0
Oh. I forgot.. ghostty is a sort of those "smarter" terminal emulators - even I use only very minimal way .
Yep. It has its own keybinding for many.
Excellent!
Thank you!

@seungjin
Copy link
Author

seungjin commented Mar 11, 2025

Oh.. In my case, I am running Tmux on Ghostty.
So my $TERM is tmux-256color.
ctrl_n_shortcuts = true is not working in that environment.
Since you pointed the reason why it happens, I can find my way of getting-this-around.

@seungjin
Copy link
Author

seungjin commented Mar 11, 2025

If any of us simply use Ghostty as a very minimal terminal emulator, we can do this to ignore Ghostty catching the Ctrl-N keybinding:

cat ~/.config/ghostty/config

keybind = alt+1=unbind
keybind = alt+2=unbind
keybind = alt+3=unbind
keybind = alt+4=unbind
keybind = alt+5=unbind
keybind = alt+6=unbind
keybind = alt+7=unbind
keybind = alt+8=unbind
keybind = alt+9=unbind

@seungjin
Copy link
Author

Oh.. Ignore my above comment. Actually @matthewberryman wrote it to Doc. I wrote it before I read his work.
Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants