/r/fishshell
A place for questions, projects, and ideas related to the Friendly Interactive Shell.
/r/fishshell
Just wanted to drop an update for anyone interested, since this seemed like a popular request on my last post here.
fish-lsp is now available on vscode!
Also, the newest release includes code-actions for things like generating completions based on argparse.
using argparse code-action to generate completions
Source code available here
What?
The Arch Linux icon shows but the file icon is missing when I'm in home directory.
When I cd to other directory it shows again, this is nuts.
I usually spend my day SSH'ed into endless backend servers and I've noticed after setting up fish and starship when I SSH into a remote host I loose all my colours and theme
Is there any way to make it persistent?
In Fish Shell you use arrow-right for accepting the suggested completion.
In vscode, chrome (addressbar) and other tools it is the TAB key.
I think my daily flow would be a bit more fluent, when using the same key in all applications.
Have you ever thought about that?
How do you handle that?
I've been running into this a couple of times now, and I always do it wrong first time and then spend some time trying to understand why because I forget...
When I do this:
if [ -n $var ]
execute commands
else
echo "variable not set"
end
If never works right. However, if I do this:
if [ -z $var ]
echo "variable not set"
else
execute commands
end
It does work. Why is this. For all intends and purposes, they should be the same thing. However, the first will always execute both the first commands and the ones after the else, while the second one always works as expected.
Can someone with a better brain explain to me why this is?
FAIL (6070 ms)
Tmpdir is /tmp/fishtest-ksdhg3jv
Failed tests:
checks/check-completions.fish
190/190 Test #190: cargo-test
99% tests passed, 1 tests failed out of 190
help
New fish user here, and my apologies if this has been asked before, but I've looked around for quiiiiite a long time now and can't find out how to force tilde expansion. In the example below, I get that the tilde is getting treated as a literal when part of the variable (but not when explicitly used in the call to ls), but how can I force the expansion?
In my use case, I am reading these tilde-filenames out of a file which is outside of my control, so I'm stuck trying to convert them to full paths (I'm the first person in my org to try using fish as their shell). How can I force tilde expansion on a string? One would think there would be a way to do it, since fish does the expansion in some contexts already. ¯\_(ツ)_/¯
~ > fish -v
fish, version 3.7.1
~ > ls somedir/
bar foo
~ > cat filelist.txt
~/somedir/foo
~/somedir/bar
~ > for myfile in foo bar
ls -l ~/somedir/$myfile
end
-rw-r--r--@ 1 bob staff 0 Jan 26 22:31 /Users/bob/somedir/foo
-rw-r--r--@ 1 bob staff 0 Jan 26 22:31 /Users/bob/somedir/bar
~ > for myfile in (cat filelist.txt)
ls -l $myfile
end
ls: ~/somedir/foo: No such file or directory
ls: ~/somedir/bar: No such file or directory
~ >
I like to use logical gate programming style like you can do in bash, but in fish it's harder to do because you have to type begin and end every time you have to open a statement, for example
test -e file and begin do this do that exit 1 end
I wood like that is only begin bracket in the bracket like { } so I don't have to type so much
I have a Nerd Font installed, the alias i am using.
Using iterm2 with shell integrations.
In my default terminal[OSX] this is not happening.
Only difference is I have powerlevel10k setup there.
Please help!
alias ls='lsd -alF'
How do I check if running inside NeoVim during initialization?
I have the following in my fish_variables
file and I'd like it to be set only when not running inside NeoVim... Is it possible?
SETUVAR fish_key_bindings:fish_vi_key_bindings
Basically I want vi key bindings only outside of NeoVim.
I mean something like showing the files and folders while i'm doing cd
Description:
This Fish plugin allows you to quickly display essential details about any brew formula, including.:
Installation:
fisher install ltaupiac/binf
Alias
An alias is also available: ,bf (comma+bf)
Usage:
> ,bf git
or
> binf git
Ex:
Is there an easy and straight forward way to strip $s from the front of pasted commands?
I added the following into the .config/fish/config.fish file. But nothing happens.
if status is-interactive
set -g fish_greeting
# Commands to run in interactive sessions can go here
end
Put this function in ~/.config/fish/config.fish
function auto_cd_xdotool --on-event fish_prompt
if test $status -eq 0
if string match -q "mkdir*" $history[1]
set -l splits (string split -n ' ' $history[1])
for i in $splits[-1..2]
if not string match -q -- "-*" $i
xdotool type --delay 100 "cd $i"
return
end
end
end
if string match -q "git clone*" $history[1]
set -l splits (string split -n ' ' $history[1])
for i in $splits[-1..3]
if string match -q "https://*" $i
set -l split1 (string split -n '/' $i)
xdotool type --delay 100 "cd $split1[-1]"
return
end
if string match -q "git@*.git" $i
set -l last (string split '/' $i)[-1]
set -l dir_name (string sub --end -4 $last)
xdotool type --delay 100 "cd $dir_name"
return
end
if not string match -q -- "-*" $i
xdotool type --delay 100 "cd $i"
return
end
end
end
end
end
I'm using webman to install alternatives to common GNU utilities.. so I want to alias various commands only if they exist. for instance i added
if command -q z
alias cd=z
end
if command -q lsd
alias ls=lsd
end
in $HOME/.config/fish/config.fish but when I re-login doesn't take..
I'm working on trying to create a fish shell theme for Everforest Dark Medium theme since I haven't been able to find one. I would love to be able to run a command that would just show a line by line output of all colors that are set. I feel like I'm missing some, e.g. when using yay to search for applications, some of the names for which branch (AUR/Extra/etc) the program is located don't seem to be the right color. Would love to see what colors I need to change and what parameters are being referenced. New to trying to make/adjust any themes.
❯ fd foo.*yaml
fish: No matches for wildcard 'foo.*yaml'. See `help wildcards-globbing`.
Is there a way to configure fish that it allows no matches?
BTW: I know that I could use fd 'foo.*yaml'
, but I would prefer to configure fish to allow no matches.
I have seen that it is in the FAQ
Background: I use Fish shell only interactively, not in scripts. It is perfectly fine, if things go wrong because foo-something.yaml
exists in my current directory.
function -d one -d two -d three
Is it possible using argparse to pass in the same flag multiple times with different values?
How do I stop Neofetch from running when ever I start a terminal?
Hello,
so on my fish.config i have set env for fzf, and one software maintainer in github said 'In fish its not recommended to use export you are suppose to use set'
So how do i set this in fish, i replace export
with set -gx
but error output.
#yt-x
export YT_X_FZF_OPTS=$FZF_DEFAULT_OPTS'
--color=fg:#e0def4,fg+:#e0def4,bg:#232136,bg+:#44415a
--color=hl:#3e8fb0,hl+:#9ccfd8,info:#f6c177,marker:#3e8fb0
--color=prompt:#eb6f92,spinner:#c4a7e7,pointer:#c4a7e7,header:#3e8fb0
--color=border:#44415a,label:#ea9a97,query:#f6c177
--border="rounded" --border-label="" --preview-window="border-rounded" --prompt="> "
--marker=">" --pointer="◆" --separator="─" --scrollbar="│"'
argparse -n function a/parma b/parmb c/parmc --$argv
Given the above
echo $_flag_parma
will print out '-a', but I want to retrieve the value of the parameter. Let's assume that I call the function with:
function -a 'My Parameter'
How do I retrieve the 'My Parameter' value and not the '-a' part in my fish script? My search efforts have failed and I did try before asking for help.
Just curious if there is a proper solution to this.
When I `sudo -s` the Fish theme colors are lost. You can see in the screenshot the blue, red and green are not the normal dark mode Catppuccin highlights and are a bit hard to read against the background. I read a post from 7 years ago that explained how root does not have access to the home directory of the user, but that was on Linux. Is there a proper way to have the Fish theme applied to root on Mac? To be honest, I have no business going root but I just so happened to notice this and got a bee in my bonnet about fixing it.
I was looking at prompt options and I found 2 famous asynchronous prompts...but how do they actually work? I did not get a lot of resouces on it, like does the prompt return to taking input before the command has completed executing, what would be the point? how is it faster? and are there any downsides?
These are some of the prompts
https://github.com/acomagu/fish-async-prompt\
https://github.com/IlanCosman/tide
ChatGPT was convinced that it had a try/catch feature added in version 3.3.0. I'm wondering where it got this idea from?
https://chatgpt.com/share/6764c559-fb1c-8008-a857-d8b502c528b1
There are at least two config.fish
files on my macOS:
one in $HOME/.config/fish
if status is-interactive
# Commands to run in interactive sessions can go here
end
and another in /opt/homebrew/etc/fish
# Put system-wide fish configuration entries here
# or in .fish files in conf.d/
# Files in conf.d can be overridden by the user
# by files with the same name in $XDG_CONFIG_HOME/fish/conf.d
# This file is run by all fish instances.
# To include configuration only for login shells, use
# if status is-login
# ...
# end
# To include configuration only for interactive shells, use
# if status is-interactive
# ...
# end
What is the difference between them?
Been a Fish user for a while, but I've recently switched to Bash with a bunch of plugins (zoxide, fzf, bat, lsd). Combined with GitHub Copilot in the CLI and fzf-git integration, I'm finding Bash surprisingly powerful. Does Fish still offer significant advantages these days (except syntax highlighting)? Curious to hear others' thoughts.