GDB-FZF enhances the GDB command line by integrating fzf, the powerful command-line fuzzy finder. It provides a fast and intuitive way to search command history, discover commands, and navigate tab completions.
| Disable Help Preview | Enable Help Preview |
|---|---|
![]() |
![]() |
| Disable Longest Common Prefix Completion | Enable Longest Common Prefix Completion |
|---|---|
![]() |
![]() |
| Disable Only List Completion Field | Enable Only List Completion Field |
|---|---|
![]() |
![]() |
| GDB Command Help with Pager (Ctrl-v) |
|---|
![]() |
- History Search (
Ctrl-r): Instantly fuzzy search your entire GDB command history with fzf. - Command Search (
Ctrl-t): Find any GDB command without knowing its exact name. - Tab Completion (
Tab): Enhances GDB's native completion. It first completes the longest common prefix, and if multiple options remain, it opens an fzf menu to interactively filter and select the final choice. - Live Command Preview: When searching commands, an optional preview window displays the GDB help text for the highlighted item.
- GDB with Python 3 support.
- fzf installed and available in your system's
PATH. - Dynamically Linked Readline: The script requires access to GDB's readline symbols, which is standard for most GDB builds.
-
Save the Script: Save the code as
gdb-fzf.pyin your GDB configuration directory (e.g.,~/.gdb/gdb-fzf.py). -
Load in GDB: Add the following line to your
~/.gdbinitfile. This is the recommended way to load it automatically.source ~/.gdb/gdb-fzf.py(Replace
~/.gdb/gdb-fzf.pywith the actual path if you saved it elsewhere.)
Once loaded, the following keybindings are active in the GDB prompt:
| Keybinding | Action |
|---|---|
Ctrl-r |
Open fzf to search command history. |
Ctrl-t |
Open fzf to search all available GDB commands. |
Tab |
Trigger GDB's completion. If multiple options exist, fzf will open. |
Once fzf startup, the following keybindings are active in the FZF prompt:
| Keybinding | Action |
|---|---|
Tab |
Move selection down |
Shift-Tab |
Move selection up |
Ctrl-v |
Show GDB command help in pager view |
In the fzf window, type to filter, use Enter to select, and Esc to cancel. For advanced search patterns, see the official fzf search syntax guide.
You can customize behavior by editing the global variables at the top of gdb-fzf.py:
-
READLINE_LONGEST_COMMON_PREFIX_COMPLETION: Set toFalseto disable longest common prefix completion.READLINE_LONGEST_COMMON_PREFIX_COMPLETION = True
-
FZF_PREVIEW: Set toFalseto disable the command help preview window.FZF_PREVIEW = True
-
FZF_ONLY_LIST_COMPLETION_FIELD: Set toFalseto disable only list completion filed in fzf.FZF_ONLY_LIST_COMPLETION_FIELD = True
-
FZF_HELP_PAGER: Configures the pager used to display GDB command help documentation.FZF_HELP_PAGER = "less -i"
-
FZF_ARGS: A list of command-line arguments passed to fzf. Modify this to change fzf's appearance or behavior (e.g.,--height,--layout).FZF_ARGS = [ 'fzf', '--height=40%', # ... other args ]
-
gdb-fzf: ... Is fzf installed and in your PATH?Ensure thefzfexecutable is installed and its location is in your$PATH. -
Failed to resolve the following required symbols: ...This script requires a dynamically linked GDB to access readline functions. This error is rare but may occur with custom or static GDB builds. -
Keybindings do not work:
- Check for error messages when GDB starts to see if the script failed to load.
- Ensure other GDB scripts are not overriding the
Ctrl-rorCtrl-tbindings.
This project is forked and improved from plusls/gdb-fzf. Please refer to the original repository for license details.






