Flyline: a Bash plugin to replace readline for a modern line editing experience: syntax highlighting, agent integration, rich prompts, tooltips, fuzzy history s
Flyline: a Bash plugin to replace readline for a modern line editing experience: syntax highlighting, agent integration, rich prompts, tooltips, fuzzy history s
When Bash prompts you for a command, a library called readline handles your keystrokes. Readline lacks many features users have come to expect. Flyline is a readline replacement that provides an enhanced line editing experience with:
Flyline is similar to ble.sh but is written in Rust and uses ratatui.rs to more easily draw complex user interfaces.
[!IMPORTANT] After installing, run
flyline run-tutorialand if you don't like the mouse capturing:flyline mouse --mode disabled
install.sh[!TIP] Run this command in bash to download flyline and update your
.bashrcto load the latest version. No need forsudo!
source /dev/null || enable -f /path/to/libflyline.so flyline
flyline run-tutorialClone the repo and run:
cargo build
enable flyline 2>/dev/null || enable -f /path/to/flyline_checkout/target/debug/libflyline.so flyline
flyline run-tutorialInstallation notes
Disable flyline with enable -d flyline.
Taken from https://www.gnu.org/software/bash/manual/bash.html:
The -f option means to load the new builtin command name from shared object filename, on systems that support dynamic loading. If filename does not contain a slash, Bash will use the value of the BASH_LOADABLES_PATH variable as a colon-separated list of directories in which to search for filename. The default for BASH_LOADABLES_PATH is system-dependent, and may include "." to force a search of the current directory.
Bash 4.4 introduced BASH_LOADABLES_PATH
Bash 5.2-alpha added a default value for BASH_LOADABLES_PATH.
Check your Bash version with: bash --version
So on Bash at least as recent as 5.2, if you install flyline to one of:
Then you can simply run enable flyline.
Flyline sets up its own tab completion
so you can type flyline in your shell to interactively browse and configure settings. Copy the commands into your .bashrc so they persist.
Explore this README and examples for what you can configure.
Flyline supports dynamic content in PS1, RPS1 / RPROMPT, PS1_FILL, PROMPT_RULER, and PS2.
The PS1 environment variable sets the left prompt just like normal. See Bash prompt documentation, Arch Linux wiki, or Starship for more information.
PS1='\\u@\h:\w$ '
PS1='\\u@\h:\w\n$ '
PS1='\e[01;32m\\u@\h\e[00m:\e[01;34m\w\e[00m\n$ '[!TIP] Do git metrics slow down your prompt loading time? See custom widget or example widgets for a solution.
The RPS1 / RPROMPT variable sets the right prompt similarly to Zsh.
RPS1='\t'
RPS1='\t\n\e[0m '
# Custom prompt prefix with line numbers
PS2='\e[2mline FLYLINE_PROMPT_LINE_NUMBER:\e[0m '
# If you do want the default '> ' prompt, then you want:
PS2='\e[0m> 'PS1_FINAL, RPS1_FINAL, PS1_FILL_FINAL, and PROMPT_RULER_FINAL let you configure transient prompts. When a command is submitted, Flyline performs a final redraw using these environment variables instead of their standard counterparts. This keeps your terminal scrollback history clean by replacing complex, multi-line prompts with a minimal version.
PS1_FINAL='Ran at \D{%Y-%m-%d %H:%M:%S}> '
RPS1_FINAL=''
PS1_FILL_FINAL=''
PROMPT_RULER_FINAL=''Flyline recognises the standard Bash time escape sequences and re-evaluates them on every prompt draw, so the time shown is always current:
| Sequence | Output |
|---|---|
\t |
24-hour time — HH:MM:SS |
\T |
12-hour time — HH:MM:SS |
\@ |
12-hour time with am/pm |
\A |
24-hour time — HH:MM |
\D{format} |
Custom format (see below) |
These can be placed in any of the supported prompt variables:
# Right prompt showing 24-hour time in green
RPS1='\e[01;32m\t\e[0m'
# Right prompt showing 12-hour am/pm time
RPS1='\e[01;34m\@\e[0m'\D{format}Use \D{format} with any Chrono format string to display the time exactly how you want it. This is similar to \D{format} in the Bash prompt documentation, but the format string is interpreted by Chrono rather than strftime.
# Show date and time
RPS1='\e[01;32m\D{%Y-%m-%d %H:%M:%S}\e[0m'
# Show only hours and minutes
RPS1='\D{%H:%M}'Create custom prompt widgets with flyline create-prompt-widget.
Flyline will replace strings in the prompt matching the widget name with the widget's output.
The available widget types are animation, mouse-mode, copy-buffer, custom, and last-command-duration.
Create your own animations with flyline create-prompt-widget animation --name [your animation name here] [FRAMES]....
Flyline will replace strings in the prompt matching the animation name with the animation:
More examples can be found in examples/animations.sh.
The block below is auto-generated from flyline create-prompt-widget animation --help:
…The block below is auto-generated from flyline create-prompt-widget mouse-mode --help:
…Render clickable text in your prompt that copies the current command buffer to the clipboard via OSC 52.
flyline create-prompt-widget copy-buffer '[copy]'
# Now use FLYLINE_COPY_BUFFER in your prompt:
RPS1=' FLYLINE_COPY_BUFFER'The block below is auto-generated from flyline create-prompt-widget custom --help:
…Show how long ago the flyline app last closed. The duration is displayed in a compact human-readable format, for example 9.2s, 1m23s, 1h02m03s, 1d20h43m.
flyline create-prompt-widget last-command-duration
# Now use FLYLINE_LAST_COMMAND_DURATION in your prompt:
RPS1=' FLYLINE_LAST_COMMAND_DURATION'Flyline can interact with your AI agent to suggest commands.
This allows you to write a command in plain English and your agent will convert it into a Bash command:
After setting up your agent with flyline, you can pass the buffer to your agent with Alt+Enter or simply Enter when your command starts with your trigger prefix (e.g. ai: list files older than three days).
See the examples for how to set this up. If agent mode is not configured yet, pressing Alt+Enter will prompt flyline to help configure it.
Flyline will syntax highlight the suggested commands and render markdown output.
Click to move your cursor, select suggestions, and hover for tooltips. Flyline must capture mouse events for the entire terminal, which isn't always desirable. For instance, you might want to select text above the current prompt with your mouse.
Flyline offers three mouse modes:
disabled: Never capture mouse eventssimple: Mouse capture is on by default; toggled when Escape is pressedsmart (default): Mouse capture is on by default with automatic management: disabled on scroll or when the user clicks above the viewport, re-enabled on any keypress or when focus is regained. You can also toggle it manually with EscapeI'd recommend setting up a mouse mode widget to know when mouse capture is enabled.
Flyline extends Bash's tab completion feature in many ways. Note that you will need to have set up completions in normal Bash first.
Flyline can automatically start tab completion suggestions as you type. This demo shows auto-started suggestions, confirming a suggestion, dismissing with Escape, and submitting the command. This is similar to inshellisense but uses Bash's completion system and runs in the same process as Bash.
When you're presented with suggestions, you can type to fuzzily search through the list:
You can customize the fuzzy matching behavior using the flyline suggestions set-fuzzy-mode command. It accepts three options:
all (default): Fuzzy matching is enabled for all completion suggestions.none: Fuzzy matching is disabled entirely (falling back to case-insensitive prefix matching).folder-prefixes: Folders are matched using case-insensitive prefix matching while remaining enabled for regular files and other suggestions.The last path segments from the cursor to the end will be fuzzily matched on the directory contents:
Flyline automatically previews and expands standard globs (*, ?, [...], [[:digit:]], {a,b}) and Bash extglobs:
@(pat1|pat2): Matches exactly one of the given patterns (e.g. ls @(Cargo.*|README*))!(pat1|pat2): Matches anything except the given patterns (e.g. ls !(*.rs))?(pat1|pat2): Matches zero or one occurrence of the patterns*(pat1|pat2): Matches zero or more occurrences of the patterns+(pat1|pat2): Matches one or more occurrences of the patterns (e.g. ls +([0-9]).txt)ls src/@(app|grammar)/*.rs[!TIP] Required Bash Settings:
shopt -s extglob # Enable extglob patternsOptional pattern matching settings:
shopt -s nocaseglob # Match filenames case-insensitively shopt -s globstar # Enable recursive ** matching shopt -s dotglob # Match hidden files with * and ?
Aliases are expanded before attempting tab completion so that Bash calls the desired completion function.
For instance, if gc aliases to git commit, gc --verbo will work as expected.
Flyline supports tab completions inside subshell, command substitution, and process substitution expressio
No open issues yet, or sync has not completed.