Skip to content

Make fish_history have a single default value #7650

Closed
@etcusrvar

Description

@etcusrvar

fish 3.1.2
enhancement, change request

There are 3 different settings that the variable fish_history can have that all essentially mean the same thing (docs)--

  • fish_history is unset
  • $fish_history = default
  • $fish_history = fish

It would be nice if this was a single value.

Motivation: I've been writing snippets of code frequently such as

if set -q fish_history
    switch $fish_history
        case default fish
            set foo fish
        case \*
            set foo $fish_history
    end
else
    set foo fish
end
do-something-with $foo

This can be worked around easily enough with an --on-variable function, such as

> function _fish_history_value --on-variable fish_history
    test "$fish_history" = default && set -g fish_history fish
    not set -q fish_history && set -g fish_history fish
end
> _fish_history_value
> echo $fish_history 
fish
> set fish_history default; echo $fish_history
fish
> set -e fish_history; echo $fish_history
fish
> set fish_history foo; echo $fish_history
foo

I call a function like this at the top of my config.fish. And all is fine. But others I share functions or plugins or the like with may not have this workaround, or even want it.

This seems like it should be something that is handled in the fish_history variable itself.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions