/r/fishshell

Photograph via snooOG

A place for questions, projects, and ideas related to the Friendly Interactive Shell.

/r/fishshell

5,621 Subscribers

8

fish-lsp is now available on vscode!

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

2 Comments
2025/02/03
22:20 UTC

3

tide prompt file icon ONLY missing when I'm on home directory

6 Comments
2025/02/01
22:38 UTC

3

Can my theme persist when using SSH?

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?

13 Comments
2025/02/01
05:16 UTC

6

Accept autocomplete suggestion via TAB or arrow-right?

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?

6 Comments
2025/01/29
08:26 UTC

5

A little understanding

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?

8 Comments
2025/01/28
19:52 UTC

0

i can't compile fish-git from the AUR

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

7 Comments
2025/01/27
08:30 UTC

5

Force tilde expansion of variable

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
~ >
6 Comments
2025/01/27
07:35 UTC

0

Is there some alternative to begin and end keywords?

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

21 Comments
2025/01/25
23:07 UTC

2

[Help] My font icons are not working for some reason

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'

https://preview.redd.it/dsoud0erhzee1.png?width=1864&format=png&auto=webp&s=54f2ba10b481df4b8f68901a7797ffcc27ec01a1

https://preview.redd.it/xb2hl0aphzee1.png?width=1088&format=png&auto=webp&s=fa663b7e5752368ded5553ada81453856ff8fa04

2 Comments
2025/01/24
18:23 UTC

3

Check if running inside NeoVim

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.

3 Comments
2025/01/22
12:50 UTC

6

How to ls while doing cd

I mean something like showing the files and folders while i'm doing cd

9 Comments
2025/01/17
18:22 UTC

8

binf - Easily Retrieve Key Info on brew Formulas (fish plugin)

Description:

This Fish plugin allows you to quickly display essential details about any brew formula, including.:

  • Description
  • Homepage URL
  • Current version
  • Installed version (if available)

Installation:

fisher install ltaupiac/binf

Alias

An alias is also available: ,bf (comma+bf)

Usage:

> ,bf git

or

> binf git

Ex:

https://preview.redd.it/7jm52zxaz5de1.png?width=419&format=png&auto=webp&s=b4be2483746b7fdfeaead764577f0bbfa309e24f

3 Comments
2025/01/15
14:16 UTC

6

Stripping dollar signs from pasted text?

Is there an easy and straight forward way to strip $s from the front of pasted commands?

2 Comments
2025/01/10
21:56 UTC

3

Can't remove fish greeting

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
7 Comments
2025/01/10
06:30 UTC

3

Use xdotool to auto cd after git clone

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
1 Comment
2025/01/09
05:26 UTC

5

How to create conditional aliases?

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..

10 Comments
2025/01/09
04:57 UTC

5

Creating Theme -- Command To Test Output of All Colors Parameters?

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.

6 Comments
2025/01/09
00:22 UTC

3

Allow No matches for wildcard (Globbing)?

❯ 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.

2 Comments
2025/01/08
09:26 UTC

3

argparse using a flag multiple times

function -d one -d two -d three

Is it possible using argparse to pass in the same flag multiple times with different values?

2 Comments
2025/01/06
17:30 UTC

5

Neofetch

How do I stop Neofetch from running when ever I start a terminal?

16 Comments
2025/01/05
17:36 UTC

4

set vs export

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="│"'
2 Comments
2025/01/02
09:23 UTC

2

argparse parameter values

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.

3 Comments
2024/12/25
14:34 UTC

3

Fish theme for root user on Mac

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.

https://preview.redd.it/frbe29kk568e1.png?width=1536&format=png&auto=webp&s=30d366dd4aa017feb1af4824310bb462522bedf5

4 Comments
2024/12/21
09:16 UTC

7

How do Asynchronous Prompts work?

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

3 Comments
2024/12/20
09:23 UTC

4

Does/Has fish shell have/ever had a try/catch feature?

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

2 Comments
2024/12/20
01:21 UTC

2

What is the difference between these two config.fish files?

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?

3 Comments
2024/12/19
02:18 UTC

0

Fish to Bash (with plugins): Is Fish still necessary?

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.

10 Comments
2024/12/18
08:27 UTC

Back To Top