Skip to content

Feature request: Fish shell widget support #88

@noahgift

Description

@noahgift

Feature Request

Add fish-widget command for Fish shell integration.

Why Fish?

  • Fish has native autosuggestion support - can integrate seamlessly
  • Growing user base, especially among developers
  • Fish's commandline builtin makes implementation clean

Proposed Command

aprender-shell fish-widget >> ~/.config/fish/config.fish

Implementation

Fish is actually easier than ZSH/Bash because it has native suggestion support:

# aprender-shell Fish widget

function __aprender_suggest --on-event fish_preexec
    # Fish handles suggestions natively, we just need to hook
end

function aprender_suggest
    set -l cmd (commandline -b)
    if test (string length "$cmd") -ge 2
        aprender-shell suggest "$cmd" 2>/dev/null | head -1 | cut -f1
    end
end

# Override fish's default suggestion
set -g fish_autosuggestion_enabled 0

function fish_commandline_prepopulate --on-event fish_prompt
    set -l suggestion (aprender_suggest)
    if test -n "$suggestion"
        commandline -f repaint
    end
end

Alternative: Use Fish's __fish_complete_command integration:

function __fish_aprender_complete
    set -l cmd (commandline -cp)
    aprender-shell suggest "$cmd" 2>/dev/null | while read -l suggestion score
        echo $suggestion
    end
end

complete -f -c '*' -a '(__fish_aprender_complete)'

Priority

Medium - Fish has good native suggestions, but aprender's history-trained model could improve them.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions