A fish plugin that prepopulates the next prompt with the contents and cursor position of the previous prompt.
Say you wanted to search for several different things in a directory using grep
. Then you
would have to type out the command and press enter. To search for the next thing you would have
to press up in order to get the previous prompt. And then move your cursor to the previous
query, delete it and the retype it. This becomes tedious very quickly. But with again.fish
this
type of scenario can be handled effortlessly!
Say you had the following prompt, where the |
character is the cursor position.
grep --perl-regexp "|" **.fish
Press alt+a, and then type something like
grep --perl-regexp "set -g|" **.fish
Press enter to execute the prompt. Then the next prompt will already be prepulated like this
grep --perl-regexp "|" **.fish
Simply press alt+a to disable again when you are done.
fisher install kpbaks/again.fish
To make it easier to notice that the again "submode" has been activated I suggest you to configure your prompt to show this.
The plugin exposes a global exported variable called AGAIN_ENABLED
when the again "submode" is active.
starship
has a module for showing environment variables, dependent on whether
the variable is defined or not. Using the following snippet in ~/.config/starship.toml
format = """
${env_var.AGAIN_ENABLED}
... rest of your format string
"""
[env_var.AGAIN_ENABLED]
style = "bold fg:red"
default = ""
format = "[$env_value]($style)"
description = "again.fish"
disabled = false
adds the leftmost red segment, when again is active:
The following variables can be changed to customize the plugin:
Variable | Default | Description | Constraints |
---|---|---|---|
AGAIN_KEYBIND |
\ea alt+a |
The keybind used to toggle the again "submode" | Must match the keybind format expected by the bind builtin. |
AGAIN_ENABLED_MESSAGE |
again enabled ($AGAIN_KEYBIND to disable) |
The value of the $AGAIN_ENABLED variable, used to see if the again "submode" is enabled. The value is only relevant for any kind of prompt integration). |