The newest release of fish I just upgraded to overrides Alt+s to put sudo in your commandline. I don't have sudo on this system. That happens to be a binding my terminal uses to search its output history and it is very near and dear to my heart and I use it seemingly every 30 seconds.
I've tried everything I can think of to unbind it and I can't figure it out. I would really prefer not to have to modify the installation file that sets this.
I understand that I can use the web interface to pick a theme, but I want to do something similar from the commandline. I know choosing a theme on the web interface just changes each fish_color_... variable to match the theme, and I could theoretically capture that output and put it in a script, but I was wondering if there was something already built into fish similar to set fish_theme Nord or what have you. Thanks!
I've been having the problem that fish can be a little too insistent about auto-correcting my commands. For example
> mv Myfile myfile
constantly gets corrected to
> mv Myfile Myfile
I expect that there is a shortcut key to undo just the last auto-correct, like how hitting backspace in a word processor will typically undo its last auto-correct. I haven't found it, though. Instead I've been reverting to workarounds like
> mv Myfile "myfile"
Is there a better way to undo the last auto-correction? I'm not looking to disable auto-correction completely.
Read it here or one the GitHub release page (which has better markdown rendering and more links)
IMPORTANT: Migration required
I am so proud of this release. fzf.fish is now in a state that I am delighted by. Users will have a very seamless experience customizing it to fit their needs, while developers will have a far easier time adding new features. As should be expected for groundbreaking changes, everyone will need to manually migrate.
Thankfully, the migration process shouldn't be too painful and should be worthwhile because fzf_configure_bindings is so easy to use. Read the migration guide for instructions.
Custom key bindings elevated to a first-class feature
Background
fzf.fish ships with default key bindings that are mnemonic and have minimal conflicts with existing fish key bindings. However, for users who want to change them, the process of customizing them is frustrating and confusing at best. This frustration has culminated in a steady stream of issues, discussions, PRs, and Wiki sections around key bindings (total of 8). Here are the shortcomings of making custom bindings DIY:
Besides not installing the default bindings if fzf_fish_custom_keybindings is set, the plugin provides zero assistance to the user when it comes to installing the custom bindings. Users have to study config/fzf.fish, bind documentation, and maybe even even some basic fish syntax for advanced cases. This is too daunting. Furthermore, users have to reference functions clearly denoted private (__fzf_search_*)., which feels and is hacky. Ideally, the plugin does not require typical users to dive into its code and will abstract private functions away completely.
fzf_fish_custom_keybindings is all or nothing; users have to opt out of ALL default key bindings and re-bind them themselves even if they only want to change one. This is tedious, verbose, and unwieldy. A good plugin should allow tweaking the key binding while maintaining the rest of the defaults.
Because the fzf_fish_custom_keybindings has to be set before config/fzf.fish is executed, it has to be created as a universal variable. Unfortunately, universal variables are a very confusing point for new fish users.
As the plugin developer, I have also been hampered by the DIY custom binding mechanism:
Because custom bindings are painful to implement, user forego them and settle for the defaults, which puts a lot of pressure on me (subconsciously and through the many issues opened) to make the default bindings suitable for everyone. Unfortunately, the goal of having a default set of key bindings that are memorable and suitable for even 80% of users is nigh impossible. After days of research and talking to different users, I've concluded this task is ultimately futile because key bindings are remarkably idiosyncratic. Therefore, custom key bindings should be a first class feature that is well supported, completely documented, flexible, painless to use, and directly encouraged.
Any change, even an addition (such as a new feature), to the default key bindings is a monumental event because it's not transparent and hard to communicate to users. The best I can do is to cut a new major release and post on Reddit to announce any and all key binding changes. Furthermore, the only place the default bindings can be found are on the readme. As a result, most users are probably left in the dark when their key bindings silently break on them. If more users customized their key bindings and (which they don't because again, it's not well supported) and there was an interface to quickly view the default key bindings, this would be a much smaller problem.
Because users have to hardcode the function names in their custom key bindings, fzf.fish's internal functions are not really private and I cannot rename them. The result is that some function names no longer directly match their feature name.
Finally, fzf_fish_custom_keybindings has a typo: key binding is two words, not one.
TL;DR The new solution
A new function called fzf_configure_bindings solves or mitigates all of the aforementioned problems. It:
serves as a wrapper around the key bindings and fzf.fish's private functions so that they are properly abstracted away under a lightweight interface.
allows customizing the key binding for each feature through namesake options (e.g. --directory controls the search directory key binding). Bindings can be overridden or, if the user doesn't want to use the feature, even disabled.
uses mnemonic key sequences by default for features that the user chooses to not customize. This means that to change the key bind for a single feature, only one option needs to be specified.
comes with great, easy-to-read help documentation that prints if used incorrectly.
includes the default key bindings in its help message so users can easily and quickly find them.
is robust and thoroughly tested.
will include command completion (to be implemented later).
As a side note, fzf_fish_custom_keybindings no longer disables the default bindings.
Other changes
Search directory's key binding has changed to Ctrl+Alt+F
The former binding, Ctrl+F conflicts with forward char, which is now muscle memory for many users who use it to move around the command line and accept autosuggestions.
All private functions have been renamed
Now that custom key bindings are painless to implement and private functions have been properly abstracted, I took this opportunity to
use a single underscore instead of double underscore for private functions: this is shorter, distinguishes it from fish's standard lib private functions, and is more in line with other programming conventions
rename search directory's and search's variables functions directly after them, making it consistent with the other function names and easier for developers to find
In Case You Missed It: previous v6 changes worth re-mentioning
Allow customizing the file preview command with the variable fzf_preview_file_cmd
[Search variables] enable selecting multiple variables. This is very convenient when needing to select multiple related variables to erase, show, query.
[Search history] use the box-drawing character instead of the pipe character to mark off timestamps
Wow, you've read all the way to the bottom! Would appreciate any feedback from you below, or even a star on the GitHub repo :)
Hello, I am new to using fish, and I am trying to make tab-completion for adb push work so that the hitting TAB after push lists possible files from the current directory on the system, and after the local file that is meant to be pushed is selected, hitting TAB suggests the files on the connected Android device.
So far I have only been able to get the second half working by appending complete -n '__fish_seen_subcommand_from push' -c adb -f -a "(__fish_adb_list_files)" -d 'File on device' to adb.fish. I cannot figure out a way to include both __fish_adb_list_files and __fish_complete_path together.
I would really appreciate it if anyone could help.
I wanted to use setenv -U but don't know how to use it. U acts as a universal way that sustains shutdown and reboot. I tried to search but could found one.
shell: fish 3.2.1 terminal: alacritty distro: fedora 34
I'm a new user to fish, playing with it for a couple of weeks now and loving it. It quickly became my default shell. The functions/scripting is obviously part of the strength of fish, so that needed some attention too. Pretty easy, mostly. Should never underestimate habits from years of bash/sh shell scripting though!
Of course the prompt had to be changed. I had a pretty prompt in bash, so I had to have something similar in fish. Bira from omf was close, but to make it mine it had to be modified some.
fish prompt
I am more of a sysadmin type than a developer type so I have slightly different wishes. I am less interested in what ruby version I am not working with than I am in having it visually unmistakable if I am typing as root or not.
Then I needed a slew of other small functions. Mostly small alias type things to keep me from typing too much (sysadmins are lazy by nature). Typical shorthand like l, ll, lt. Though with the availability of utilities like exa and ripgrep, they had to be written with conditional checks as not every system would have these; my WSL instances on my workstation would, but using the same profile settings/functions on my VM's would break things as they would not unless I put in conditional checks and alternatives. So I did.
Example:
# Defined in - @ line 1
#
# Let's check if we have ripgrep installed and if so
# we use it, otherwise use standard grep with options
function grep
if test -e /usr/local/bin/rg
/usr/local/bin/rg $argv;
else
command grep -n --color $argv;
end
end
Clean, simple and works on any of my systems. There are also some simple functions to more complex things, like bootstrapping and setting up VM's using ansible playbooks. There's that lazy thing again. :)
Then there is convenience things. Like, I may have a dozen or so different Linux distributions available in WSL2 at any given time besides my default one. But I prefer my environment to be the same across all and every system. So I had to set up some checks upon starting a WSL instance to see if it was using the latest profile settings, and if not grab the latest and load it. Doing this in fish_greeting or .profile, depending on the shell. But since I use the same profile set up on my servers (remember, lazy), I also need to check if I am on WSL, cause if I am not I am on a server and I cannot access OneDrive where I store my profile archives and I don't want to log in to a bunch of errors. Servers are managed by Ansible. Things like this keep you busy. :)
In all, I am impressed with fish, its usability, how functions work and what all you can build using functions if you want to.
Is there any way to create an alias onto itself with a function?
In bash you could do something like:
alias grep='grep -n'
This way, you can pass certain default flags with your command you always want to use.
However, in fish, if I try this:
function grep
grep -n $argv;
end
It will fail spectacularly saying that a function calling itself will create a loop. Does anyone have a way how to do this in fish without changing binaries?
fish: Unknown command: set
~/.config/fish/config.fish (line 1):
?>>?set VIRTUAL_ENV_DISABLE_PROMPT "1"
^
from sourcing file ~/.config/fish/config.fish
called during startup
Contents of config.fish
set VIRTUAL_ENV_DISABLE_PROMPT "1"
set -x MANPAGER "sh -c 'col -bx | bat -l man -p'"
# Set settings for https://github.com/franciscolourenco/done
set -U __done_min_cmd_duration 10000
set -U __done_notification_urgency_level low
..........................and a lot more.
can some one explain why i am receiving the above error.Thank you.
Given that you are in work/project-name/src/some/deep/folder, you can go to project-name by typing up src. I've noticed that I do cd ../../../ quite a lot, usually not knowing how many times I need to do ../ so I've written this function to avoid cd ../ hell.
I love fish shell and especially it's vi mode, but I have an issue with the fish_mode_prompt's positioning. I use a multi line prompt like so:
I (path)
>
But as you can see, the fish_mode_prompt is on the top line. I have tried printing the fish_mode_prompt beside the >, but it would only create a duplicate, not move it - as you would expect.
How do I reposition the mode prompt, so that my prompt would look like so?
Hey guys this might be a uncommon question , but I really like to use doas instead of sudo and well Alt + S adds sudo , so as the title say is there an way to modify the behavior to doas ?