/r/fishshell
A place for questions, projects, and ideas related to the Friendly Interactive Shell.
/r/fishshell
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?
I have a function that does a lot of ls $somedir
so I thought of changing them to echo $somedir/*
to make it faster (echo
is builtin while ls
is not), but when $somedir
is empty I get errors because of empty wildcard expansion.
Do you know if there's a way to allow empty wildcards locally (I like that it errors out in general) or some other way to list a directory without forking?
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?
When I change my shell from bash to fish, I lose the ability to edit and save some of my dot files and they become read only. What can I do to edit and save the files regardless of what shell I'm in? Or do I need to recreate all of my dot files while in the fish shell?
I used to use zsh, and didn't really like it. I switched to fish and I love it, but it really annoys me there is no !! command. So I made my own:
function !!
set _count_cmd 1
set _last_command (history -n 1)
while test "$_last_command" = "!!"
set _count_cmd (math $_count_cmd + 1)
set _history (history -n $_count_cmd)
set _last_command $_history[-1]
end
echo $_last_command
end
I really am proud of myself buy know you eg need to run sudo (!!)
to use it which can be annoying, I though about making a sudo function that checks if $argv[1] is !! and go further from there, but sudo isn't the only command you would want to run before sudo... is there a way to maybe make it a real command and not a script (like a file in /usr/bin) so I can just run echo !!
or sudo !!
without (!!)
I like the idea portrayed in https://fishshell.com/docs/current/cmds/cdh.html to have access to recently visited directories in addition to the fantastic completion that fish provides. I noticed that every time I close and reopen my terminal, the history of directories I've visited is flushed and I start from zero.
The history is stored in the dirprev and dirnext variables, which this command manipulates. If you make those universal variables, your cd history is shared among all fish instances.
Is the above section implying that creating universal variables would allow me to have a "history", that'll allow me to close all running terminals and when I open a new one, it'll remember previous directories?
To that end, I added the following to ~/.config/fish/config.fish
and I still seem to start from zero when all terminals are closed and then start with a new one. Does anyone know what I could be missing?
set -Ux dirprev
set -Ux dirnext
I've tried all mainstream distros and they all ship fish with unreadable blue color. Why? https://0x0.st/s/Fd91u_UFWu33xMyQLJg63g/XgEb.png
Hi,
I’m new to Linux, so please forgive me if I’m missing something basic. I've been trying to change the selection color in Fish, but I can't seem to get it to work. I'm referring to the yellow color seen in the screenshot below:
Initially, I thought I should change one of these values (based on set | grep fish_color
):
fish_color_search_match --background=FFCC66
fish_color_selection --background=FFCC66
I added the following lines to my config.fish
:
set -U fish_color_selection --background=545860
set -U fish_color_search_match --background=545860
The values output by set | grep fish_color
changed, but the actual selection color remained the same. After some more Googling, I found that this line added to config.fish
might be the solution:set -U fish_pager_color_selected_background 6F7D8B
However, this only partially works. The selection isn't yellow anymore, but it doesn't match the color I set either—it becomes transparent instead.
Could anyone help me understand how to change the selection color to what I want? I'd really appreciate any advice!
Thanks!