/r/fishshell
A place for questions, projects, and ideas related to the Friendly Interactive Shell.
/r/fishshell
Hi everyone, I followed the official documentation to set up Docker completions for Fish shell:
docker completion fish > ~/.config/fish/completions/docker.fish
However, even after restarting Fish using exec fish
, no completions are provided for docker commands.
Interestingly, if I manually run:
source ~/.config/fish/completions/docker.fish
the completions work as expected.
Can someone help me understand why this happens and how to fix it?
I’m trying to set up autocompletion for uv in Fish shell while using Mise to manage my environment.
Mise has been installed correctly, and i'm using Fish as my terminal shell.
However, autocompletion for uv isn't working, and I can’t seem to figure out how to fix it.
What i did:
I installed Mise using the following command:
curl https://mise.run | sh
Installed uv within Mise:
mise use -g uv
I attempted to configure the autocompletion for uv by adding the following to my ~/.config/fish/config.fish file, like the documentation:
echo 'uv generate-shell-completion fish | source' >> ~/.config/fish/config.fish
Issue: When I open the terminal i get the following error:
Command 'uv' not found, but can be installed with:
sudo snap install astral-uv
~/.config/fish/config.fish (line 6):
uv generate-shell-completion fish | source
^^
from sourcing file ~/.config/fish/config.fish
called during startup
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
Additional Info:
Ubuntu 24.04 (WSL-2)
Windows 11
Windows Terminal
My config.fish:
if status is-interactive
# Commands to run in interactive sessions can go here
end
~/.local/bin/mise activate fish | source
uv generate-shell-completion fish | source
What am I doing wrong in setting up autocompletion for uv in Fish shell with Mise? When i open the terminal the uv works fine. For some reason uv isn't available at startup.
Is there any additional configuration or step I need to perform for autocompletion to work correctly?
I’m trying to set up an auto-start feature for tmux in Fish. Here's what I want it to do:
workspace
session if it doesn’t already exist.Here’s the code I’m using:
fishCopy code# Tmux auto-start
if status is-interactive
and not set -q TMUX
if not set -q DISPLAY
set -x DISPLAY :0
end
if not tmux has-session -t workspace 2>/dev/null
tmux new-session -d -s workspace
else if tmux list-sessions | grep -q "^workspace.*(attached)"
# Do nothing
else
tmux attach-session -t workspace
end
end
workspace
session.DISPLAY
as :0
. Is there a better way to handle this?I also added this to my config.fish
to run Neofetch only in the first terminal instance:
fishCopy code# Neofetch for first Fish instance
if not test -f /tmp/neofetch_first_terminal.txt
echo " "
neofetch
touch /tmp/neofetch_first_terminal.txt
end
But Neofetch doesn’t show up at all.
Any advice on fixing these issues?
I'm sorry if this has been asked before, I tried to search duckduckgo as well as here & came up empty...
I'm completely new to fish, still reading through the site and I wanted to know if there was any equivalent to zsh's "named dirs" aka hash -d?
I'm still a newbie to shells & after finding out my favorite zsh plugin creator mattmc3 owed his prowess to fish shell I just had to make the switch to help my education journey!
Anyway sorry again if this has been answered but ✿︎𝕋𝕙𝕒𝕟𝕜 𝕪𝕠𝕦✿︎ so much for any help you're willing to offer ( ⌯ᐢ ᵕ ᐢ⌯)
much love ya'll >ᢦ<ಣ
Greetings,
Is it possible to turn off abbreviation expansion by default? I think I read that ctrl+enter or something may work individually
After logging into a couple terminals and running several commands, I tried to ssh to my server which I log into everyday. Surprisingly, there was no shell completion for it, and in searching the history in that terminal could not find any match. So I went to my other open terminal and tried typing "ssh" where I did get my command completion and could see it in my history? Why is a command disappearing from the history of one fish session but not in the other?
Also, what is the default history size of fish and how to change it?
If there are already some characters typed, then pageUp is different.
I know that this a feature and not a bug.
Nevertheless, I would like that the fishshell ignores the characters I already typed and shows me the previous command.
Is there a way to configure that?
Newb question maybe. I set up quite alias over the years. In bash and shell you can see the value set for an alias can be printed by 'alias <alias name>' at the CLI . But I can't find a way to do the same in fish. I end up doing 'alias | grey < alias name>' . Anyone have any idea how to do this in fish ? Thanks
I am new to fish shell, I want to learn how people make their fish configs , maybe i found some hidden gems today
Fired up VSCode today after a few days away on my Ubuntu distro and was met with this:
Don't know where to start as it was working just the other day. I have not changed anything on my system since it last was working. Any suggestions?
___
Solution:
Finally figured it out, it appears after digging a little more in the vscode path, the OMF folder had been removed entirely. I navigated to /home/zach/.local/share/omf
and copied this folder over to /home/zach/snap/code/174/.local/share
and it is working again
Hey there Fish Shell community, I am new to fish shell and i am trying to set syslink lrwxrwxrwx 1 root root 13 Oct 31 01:58 /snap/bin/firefox -> /usr/bin/snap
to $PATH how can i do that please help, thank you
Hey fish folks! 👋
iTerm recently launched their AI feature where you can ask questions in natural language and get commands. But it only supports OpenAI's API, and I'm a Claude user. So I built a fish function that does the same thing!
> ask-claude "flush DNS cache on my Mac"
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
> ask-claude "find large files taking up space"
find . -type f -size +100M -exec ls -lh {} \;
Get a Claude API key from Anthropic Set these in your config.fish:
set -gx CLAUDE_MODEL "claude-3-sonnet-20240229"
set -gx CLAUDE_API_KEY "sk-ant-..."
Drop the function in your fish functions directory
Check it out on GitHub: [ask-claude] (https://github.com/MugunthKumar/ask-claude) PRs welcome! Planning to add support for more shells and Windows in the future.
I'm currently working on a small tool that unifies package managers that I use by mapping them to aliases that do as close to the same thing as possible across all package managers, and wanted to know if there's already an existing tool/framework or some documentation that would simplify my current writing process.
Something similar exists for web development called Mitosis which offers codegen for most frontend frameworks using their format, something like this but for shell scripts would be kind of neat if a little overkill.
At the moment all I do is write them by hand as I've used Bash and Zsh extensively, and recently moved over to Fish. I know Nushell exists and also plan to cover this too (all of which has been for fun), and I'm just wondering if such a tool already existed as it may be a fun project for me to delve into at some point™
On one hand, I have my own prompt, which I very much like. On the other hand, sometimes I like tide.
Is there an easy way to switch between them? I don't want tide to overwrite my own one or vv, and I probably need more than just the fish_prompt.fish as my own has a transient prompt via plugin, and tide has that built-in which may (or not?) cause issues.
I use stow to manage my dotfiles, so I could setup a separate fish config and disable one and enable the other to switch, but that also means I have to manage my functions in two locations which is not exactly ideal.
How do you guys manage switching things around when you feel like it, but don't want irreversibly change things? Maybe its not a big deal if you just use a prompt from like tide or omf/omp but I've put some work in writing my own so I don't just want to scrap it.
Currently, i am using the below in my fish config file
set --global hydro_symbol_prompt "><>"
set --global hydro_color_prompt "magenta"
Anyone have the issue where pasting a big chunk of text, let's say an x509 cert, or anything where it's a 80 line python file, the entire terminal goes blank?
Is there a fix or workaround?
Hi all,
In ZSH I can enable FZF ZSH integration and use cd **<Tab>
to bring up the fzf menu then select the directory to cd into.
It doesn't seem to work the same way in fish. Is there a way to enable this or similar behaviour?
When I use set_color -o normal
or set_color normal --bold
the bold command has no effect.
Why is that and how can I tell fish to make the normal color bold?
Hi, I'm a beginner and I'd like to use fish, but I'm struggling to get this config to work. It's taken from josean-dev/dev-environment-files/.zshrc, and I'd like the same or similar functionality in fish, especially the speed. When I've tried simply changing the syntax it doesn't do anything. How do I do this?
# --- FZF ---
# Set up fzf key bindings and fuzzy completion
eval "$(fzf --zsh)"
# --- setup fzf theme ---
fg="#f1eff8"
bg=""
bg_highlight="#383a62"
purple="#7aa5ff"
blue="#2de0a7"
cyan="#ae81ff"
export FZF_DEFAULT_OPTS="--color=fg:${fg},bg:${bg},hl:${purple},fg+:${fg},bg+:${bg_highlight},hl+:${purple},info:${blue},prompt:${cyan},pointer:${cyan},marker:${cyan},spinner:${cyan},header:${cyan}"
# --- Use fd instead of fzf ---
export FZF_DEFAULT_COMMAND="fd --hidden --strip-cwd-prefix --exclude .git"
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_COMMAND="fd --type=d --hidden --strip-cwd-prefix --exclude .git"
# Use fd (https://github.com/sharkdp/fd) for listing path candidates.
# - The first argument to the function ($1) is the base path to start traversal
# - See the source code (completion.{bash,zsh}) for the details.
_fzf_compgen_path() {
fd --hidden --exclude .git . "$1"
}
# Use fd to generate the list for directory completion
_fzf_compgen_dir() {
fd --type=d --hidden --exclude .git . "$1"
}
# source ~/fzf-git.sh/fzf-git.sh
show_file_or_dir_preview="if [ -d {} ]; then eza --tree --color=always {} | head -200; else bat -n --color=always --line-range :500 {}; fi"
export FZF_CTRL_T_OPTS="--preview '$show_file_or_dir_preview'"
export FZF_ALT_C_OPTS="--preview 'eza --tree --color=always {} | head -200'"
# Advanced customization of fzf options via _fzf_comprun function
# - The first argument to the function is the name of the command.
# - You should make sure to pass the rest of the arguments to fzf.
_fzf_comprun() {
local command=$1
shift
case "$command" in
cd) fzf --preview 'eza --tree --color=always {} | head -200' "$@" ;;
export|unset) fzf --preview "eval 'echo \${}'" "$@" ;;
ssh) fzf --preview 'dig {}' "$@" ;;
*) fzf --preview "$show_file_or_dir_preview" "$@" ;;
esac
}
Fish noobie here. From years of using bash, I've developed the habit of using a set of very hacky aliases:
alias q='cd ..'
alias qq='cd ../..'
alias qqq='cd ../../..'
alias qqqq='cd ../../../..'
alias qqqqq='cd ../../../../..'
...
You get the idea.
Now that I'm switching to this newer, much friendlier shell, I'm wondering if it's possible to recreate this behavior, essentially defining a function where the name itself is treated as a variable and can be interacted with. Any ideas?
EDIT: For anyone else wondering, this is the way. Huge thanks to u/_mattmc3_
function qcd
echo cd (string repeat -n (string length $argv) ../)
end
abbr -a qcd --position command --regex 'q+' --function qcd
in zsh i could do %F{$(($RANDOM%6+1))} %D{%H:%M} %f
and in bash $(tput setaf $((RANDOM%6+1))) \A $(tput sgr0)
but i can't find a similar solution for fish
i've been using perplexity to answer small questions like this but it fails miserably when it comes to customizing prompts, no matter which shell or extra prompt i want to get information on
searching the internet proper didn't yield any results either, i couldn't even get starship to play nice with random colors in the prompt, is this impossible or i'm just looking at the wrong places?
Hi, new to Fish but came from Bash to Zsh and haven't looked back since.
Big fan of how Fish is trying to reinnovate the shell to be more modern and user-friendly - a lot of things I had to rely on from Zsh plugins, Fish happens to support out of the box which I'm loving.
Is there an equivalent to zsh-you-should-use either as a built-in feature or a plugin? TL;DR it reminds you of aliases you've defined when you run a command that contains a set alias. Would love to know if there is. :)
There's also fish-abbreviation-tips which I prefer at the moment.
Just fluff.
I made a plugin to do a web search via Fish shell. It's inspired by the oh-my-zsh/web-search plugin, but tailored specifically for Fish. With this plugin, you can quickly perform searches across multiple websites directly from your terminal, without needing to open a browser and manually input search queries.
This plugin is open source and licensed under GNU GPLv3, so you're welcome to use it, customize it, and contribute if you’d like!
While trying to build a customized prompt, I came across an issue while setting a part of it to print in bold
My current prompt is this:
echo -s (set_color --bold) (prompt_login) ' ' $cwd_color (prompt_pwd) $vcs_color (fish_vcs_prompt) $normal ' ' $prompt_status
My expectation would be that prompt_login
which prints as username@hostname would be printed in bold letters, but only the username is shown as bold. Why is that and how do I fix this?
I already tried to use $user_color $USER@(Prompt_hostname)
instead, with set -l user_color (set_color brgreen --bold)
but then the entire prompt is printed green instead of using different colors for user and hostname, so now I am quite confused how this should work.
Hi,
I am developing a redistributable plugin, so I have my working directory with its 'functions' and 'conf.d' folders where I develop my scripts. My question is: how can I test the various functions I develop? It is not convenient to develop directly in the ~/.config/fish directory and neither to deploy the scripts every time to test a change.
Is there a best practice?
So I'm trying to integrate zellij with fish (decided to move off of zellij autolock for fun). I'm using the fish_preexec event to lock the current zellij session. The issue is that for some reason $argv[1] returns the whole argv
function fish_preexec --on-event fish_preexec
echo $argv[1]
end
If I enter a command then like ls <some_directory>
, I will get "ls <some_directory>" printed out. Am I missing something? Is $argv not a normal variable? Why can I not index it?