[GH-ISSUE #6409] End and Home buttons don't work in ollama in tmux #66064

Closed
opened 2026-05-03 23:50:14 -05:00 by GiteaMirror · 5 comments
Owner

Originally created by @yurivict on GitHub (Aug 19, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/6409

What is the issue?

Pressing End doesn't move the cursor to the end of line, and instead it enters the '~' character.
Same happens with the Home button.

These are TERM environment variables in tmux:

$ env | grep TERM
COLORTERM=truecolor
TERM_PROGRAM_VERSION=3.3a
TERM=tmux-256color
TERM_PROGRAM=tmux

Version: 0.3.6

OS

Linux

GPU

Nvidia

CPU

Intel

Ollama version

0.3.6

Originally created by @yurivict on GitHub (Aug 19, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/6409 ### What is the issue? Pressing End doesn't move the cursor to the end of line, and instead it enters the '~' character. Same happens with the Home button. These are TERM environment variables in tmux: ``` $ env | grep TERM COLORTERM=truecolor TERM_PROGRAM_VERSION=3.3a TERM=tmux-256color TERM_PROGRAM=tmux ``` Version: 0.3.6 ### OS Linux ### GPU Nvidia ### CPU Intel ### Ollama version 0.3.6
GiteaMirror added the bug label 2026-05-03 23:50:14 -05:00
Author
Owner

@rick-github commented on GitHub (Aug 19, 2024):

ollama uses a readline-like cli, home=ctrl-a, end=ctrl-e

<!-- gh-comment-id:2296037379 --> @rick-github commented on GitHub (Aug 19, 2024): ollama uses a readline-like cli, home=ctrl-a, end=ctrl-e
Author
Owner

@yurivict commented on GitHub (Aug 19, 2024):

@rick-github

When the ollama client is run in the KDE's konsole, in the Xfce terminal, in xterm - Home and End buttons work fine.

However, in tmux they don't work in ollama.

vim, and libedit examples do handle Home and End buttons correctly in the tmux terminal.

Only ollama seems to have problems with Home and End buttons in tmux.

<!-- gh-comment-id:2297143754 --> @yurivict commented on GitHub (Aug 19, 2024): @rick-github When the ollama client is run in the KDE's konsole, in the Xfce terminal, in xterm - Home and End buttons work fine. However, in tmux they don't work in ollama. vim, and [libedit](https://thrysoee.dk/editline/) examples do handle Home and End buttons correctly in the tmux terminal. Only ollama seems to have problems with Home and End buttons in tmux.
Author
Owner

@rick-github commented on GitHub (Aug 19, 2024):

ollama implements a subset of the readline library (not sure why they took this approach and just didn't use the readline library). tmux changes the codes that get sent for various keystrokes, so the ollama readline doesn't recognize them, it continues to use the default config of ctrl-a, ctrl-e. if you want full readline compatibility, you can wrap ollama in a program that implements full readline functionality.

First, install rlwrap. If you are using a debian based system:

apt install -y rlwrap

If you are using redhat or other, use yum/dnf/etc to find and install the program.
Now create an alias for ollama and save it in ~/.bash_aliases:

alias ollama='rlwrap -a /usr/local/bin/ollama'

In order for rlwrap to have access to the ollama history, create a symlink to the history file:

ln -s .ollama/history ~/.ollama_history

Now when you run ollama, the keyboard input is handled by rlwrap.

<!-- gh-comment-id:2297265873 --> @rick-github commented on GitHub (Aug 19, 2024): ollama implements a subset of the readline library (not sure why they took this approach and just didn't use the readline library). tmux changes the codes that get sent for various keystrokes, so the ollama readline doesn't recognize them, it continues to use the default config of ctrl-a, ctrl-e. if you want full readline compatibility, you can wrap ollama in a program that implements full readline functionality. First, install rlwrap. If you are using a debian based system: ``` apt install -y rlwrap ``` If you are using redhat or other, use yum/dnf/etc to find and install the program. Now create an alias for ollama and save it in ~/.bash_aliases: ``` alias ollama='rlwrap -a /usr/local/bin/ollama' ``` In order for rlwrap to have access to the ollama history, create a symlink to the history file: ``` ln -s .ollama/history ~/.ollama_history ``` Now when you run ollama, the keyboard input is handled by `rlwrap`.
Author
Owner

@yurivict commented on GitHub (Aug 19, 2024):

Thanks for the workaround with rlwrap.

I also tried ollama in the Rio terminal: https://raphamorim.io/rio/

The ollama client malfunctions in both tmux and Rio terminals, see the video screenshot for the Rio terminal (the behavior in tmux is the same).

I think that ollama should use libedit or readline, because this issue would keep coming up with more and more users from different backgrounds and environments.

<!-- gh-comment-id:2297325500 --> @yurivict commented on GitHub (Aug 19, 2024): Thanks for the workaround with rlwrap. I also tried ollama in the Rio terminal: https://raphamorim.io/rio/ The ollama client malfunctions in both tmux and Rio terminals, see the [video screenshot](https://freebsd.org/~yuri/video-screenshot-ollama-in-rio-bug-2024-08-19_12.40.56.mp4) for the Rio terminal (the behavior in tmux is the same). I think that ollama should use libedit or readline, because this issue would keep coming up with more and more users from different backgrounds and environments.
Author
Owner

@rick-github commented on GitHub (Aug 19, 2024):

The ollama cli is a convenience, if a user wants a full-blown text CLI, there are plenty of terminal integrations.

<!-- gh-comment-id:2297352871 --> @rick-github commented on GitHub (Aug 19, 2024): The ollama cli is a convenience, if a user wants a full-blown text CLI, there are plenty of [terminal integrations](https://github.com/ollama/ollama?tab=readme-ov-file#terminal).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#66064