Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Questions tagged [fish]

Fish is a unix shell with a clean design and a limited but powerful feature set.

Filter by
Sorted by
Tagged with
245 votes
12 answers
289k views

Execute a command once per line of piped input?

I want to run a java command once for every match of ls | grep pattern -. In this case, I think I could do find pattern -exec java MyProg '{}' \; but I'm curious about the general case - is there an ...
user avatar
  • 3,333
55 votes
3 answers
25k views

Does Bash have similar features such as Fish's autosuggestions and highlighting?

I recently noticed 2 features in Fish and was wondering if anyone knew if these were also available in Bash? Syntax highlighting Specifics: You'll quickly notice that fish performs syntax ...
user avatar
  • 345k
44 votes
3 answers
52k views

How to make zsh completion show the first guess on the same line (like fish's)?

In Fish when you start typing, autocompletion automatically shows the first autocompleted guess on the line itself. In zsh you have to hit tab, and it shows the autocompletion below. Is there anyway ...
user avatar
  • 1,701
29 votes
10 answers
4k views

Dealing with file names with special first characters (ex. ♫)

I have recently come across a file whose name begins with the character '♫'. I wanted to copy this file, feed it into ffmpeg, and reference it in various other ways in the terminal. I usually auto-...
user avatar
22 votes
6 answers
10k views

Share environment variables between bash and fish

bash and fish scripts are not compatible, but I would like to have a file that defines some some environment variables to be initialized by both bash and fish. My proposed solution is defining a ~/....
user avatar
  • 5,441
20 votes
2 answers
7k views

how do I reference a variable in fish shell with a default fallback

What is the fish shell equivalent to the following bash: echo ${TEST:-1} In bash this would print the value of TEST if there was one, or 1 if there was not.
user avatar
  • 301
17 votes
1 answer
8k views

How to change the default shell in NixOS?

At the moment I need to set the fish shell to be my default shell on NixOS and there is no official documentation on how to do that declaratively (not by running chsh) in NixOS.
user avatar
17 votes
1 answer
3k views

Run a command only if the previous command was successful in Fish (like && in bash)

Using Bash I've often done things like cd /study && ls -la I understand that the double ampersand is telling the terminal don't execute part two of this command unless part one completes ...
user avatar
  • 410
17 votes
5 answers
18k views

What's the easiest way to detect what signals are being sent to a process?

I'm trying to debug an issue with my shell (specifically, fish) sending signals to my background processes. I'd like to be able to recognize what signals a process is receiving. Ideally, I'd like ...
user avatar
15 votes
2 answers
7k views

Why can't I list a directory with read permissions?

I created a directory d and a file f inside it. I then gave myself only read permissions on that directory. I understand this should mean I can list the files (e.g. here), but I can't. will@wrmpb /p/...
user avatar
  • 837
13 votes
2 answers
11k views

Fish-Shell Will Not Save my Aliases

I do not know why, but after making a whole bunch of fish aliases. I'm assuming I have neglected one simple step after assigning them all but I cannot seem find the solution myself. Can anyone lend ...
user avatar
  • 609
13 votes
3 answers
6k views

How to access bash aliases in fish

I am missing my bash aliases in fish, and don't want to manually convert all of them to fish functions. How to get access to them all from within fish? Bonus points if: the solution supports an ...
user avatar
  • 389
10 votes
2 answers
27k views

How to edit the fish shell startup script?

Is there a way I can do something like run myscript.sh in fish ? I am using Arch Linux, and have installed the fish shell together with oh-my-fish Can someone tell me which file I must edit to add ...
user avatar
  • 203
10 votes
1 answer
7k views

How does history work in fish shell?

I'm a bash user, starting a new job at a place where people use fish shell. I'm looking at the history command which I often use in bash. When I use it in fish I get a long list of my history which ...
user avatar
9 votes
4 answers
8k views

fish: sudo: !!: command not found

I have fish installed in my Linux Mint DE. I really like how fish makes things easier and it looks so pretty although I haven't find a correct answer about why I can't execute: sudo: !!: command not ...
user avatar
  • 2,861
9 votes
2 answers
786 views

xtrace equivalent in the fish shell

Is there an equivalent of POSIX shells' set -x or set -o xtrace that cause the shell to display the commands being run in the fish shell?
user avatar
8 votes
3 answers
2k views

find -exec not working in fish

While using fish as my shell, i'm trying to set permissions on a bunch of c source files in current dir with find . -type f -name "*.c" -exec chmod 644 {} +; I get an error find: missing ...
user avatar
  • 199
8 votes
3 answers
8k views

fish shell : exec format error

On an Ubuntu ($ uname -a : Linux kumanaku 4.15.0-43-generic #46-Ubuntu SMP Thu Dec 6 14:45:28 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux), I just installed fish ($ fish --version : fish, version 2.7.1) ...
user avatar
8 votes
2 answers
4k views

In the Fish shell, how can I join an array with a custom separator?

I have an array whose elements may contain spaces: set ASD "a" "b c" "d" How can I convert this array to a single string of comma-separated values? # what I want: "a,b c,d" So far the closest I ...
user avatar
  • 5,041
8 votes
1 answer
5k views

Run fish script in background? [closed]

I'd like to always run a fish script in the background even if the user doesn't specify that. In bash, this can be done by surrounding the script with ( at the start and ) & at the end. Is there ...
user avatar
6 votes
1 answer
3k views

How can I check if a shell is login/interactive/batch in fish?

I want to be able to check if a fish shell is being run in login, interactive, or batch mode, and this question only discusses bash.
user avatar
  • 9,032
6 votes
1 answer
11k views

Why I can't add fish to /etc/shells?

I'm trying to use fish shell as my default shell on OSX. I have installed fish shell using brew and when I wanted to add it to /etc/shells I got this error: tee: /etc/shells: No such file or ...
user avatar
5 votes
1 answer
425 views

xargs | Use input as command

I would have assumed that following examples work perfectly fine. $ which -a python python3 pip | xargs -I {} {} --version No '{}' such file or folder $ which -a python python3 pip | xargs -I _ _ --...
user avatar
  • 623
5 votes
1 answer
697 views

Is there a command to move a file, and symlink it back to where it was?

I often find myself wanting to move a file, then create a symlink where it was. In doing this by hand I tend to twist my mind. (Esp after doing half a dozen files) Use cases: Moving all my "dot ...
user avatar
5 votes
1 answer
766 views

Why does the fish shell need to start a daemon process?

I just started playing with the fish shell, and I really like is so far. However, I can't figure out what the purpose of fishd is. So, why does fish need to start up a daemon process? What is the ...
user avatar
  • 437
5 votes
1 answer
1k views

Adding pass completion to fish shell

I'm trying to get the CLI password manager pass to work in my fish shell with auto completion. I've already found the necessary file, yet am having trouble finding out where to put it, or rather ...
user avatar
  • 177
5 votes
3 answers
3k views

Is it possible to exec some commands in a subshell without immediately exiting afterwards?

I use the fish shell and would like to be able to "source" some shell scripts written with sh-compatible syntax, which fish cannot read. For example lots of software expects you to source some shell ...
user avatar
  • 5,041
5 votes
1 answer
485 views

Shell that tab-completes prefix?

I would like tab completion to behave differently when the cursor is at the beginning of a word than when the cursor is at the end of a word. I've only ever seen shells that tab-complete the suffix, ...
user avatar
5 votes
1 answer
262 views

sudo and fish: no credential caching

I use fish as my standard shell. And I use sudo sometimes. But I'm having problems with credential caching. On an Ubuntu system, this works: niklas@Niklas-Mobil~> sudo true [sudo] password for ...
user avatar
  • 361
5 votes
1 answer
817 views

What's the fastest (CPU time) way to get my current git branch?

I'm trying to improve the performance of my fish prompt, and since my prompt includes my current git branch, I'm wondering if there may be a way to make it faster. Right now I'm using git symbolic-...
user avatar
4 votes
1 answer
1k views

Fish shell testing for existence of file in $PATH

I'm trying to test in a fish shell script for the existence of the figlet binary. Since I use Linux and OS X I cannot rely on the file being in the same location and need to resolve it dynamically. I'...
user avatar
4 votes
1 answer
1k views

Does one string contain another in fish shell?

I am working on my fish.config for using the fish shell. I am trying to compare strings using bash syntax but fish doesn't accept the syntax. There is clearly another way to do it. Any suggestions ...
user avatar
4 votes
5 answers
3k views

Get default ubuntu motd in fish shell

I would like to have Ubuntu's MOTD in the fish shell. Ubuntu's default is as follows: That is essentially what I would like to see when open up my terminal (terminator, which loads fishfish) As far ...
user avatar
  • 154
4 votes
1 answer
1k views

How to stop fish shell from underlining path?

The fish shell will underline a path given as an argument to a command such as ls. Is there a way to change that behavior since I find it very ugly? For example:
user avatar
  • 2,025
4 votes
1 answer
2k views

How to use booleans in fish shell?

I switched to fish shell and quite happy with it. I didn't get how can I handle booleans. I managed to write config.fish that executes tmux on ssh (see: How can I start tmux automatically in fish ...
user avatar
  • 487
4 votes
4 answers
5k views

How do I create a GUI application launcher for xfce4-terminal with fish but inheriting the environment variables from bash?

If I run fish from a bash prompt, it will inherit the environment variables I have set in my .bashrc and .profile files, including the important $PATH variable. So far so good. Now, I want xfce4-...
user avatar
  • 5,041
4 votes
2 answers
2k views

How to group multiple conditions in an if statement in fish

As is, the code below is invalid, because the brackets can not be used like that. if we remove them, it runs fine, and outputs: true true code: #!/usr/bin/fish if ( false ; and true ) ; or true ...
user avatar
  • 389
4 votes
1 answer
5k views

Converting bash script to fish

I'm trying to add the following bash scripts to fish, yet am having trouble getting the syntax in fish right. Here is the original script: export MINION_INSTALL=$HOME/minion export NOTES_HOME=$HOME/...
user avatar
  • 177
4 votes
1 answer
594 views

Print tab character in fish

In bash I could either do echo -e "a\tb" or echo a$'\t'b. How do you do this in fish?
user avatar
  • 5,441
4 votes
3 answers
788 views

fish: whitespace in alias

I am trying to alias an executable in a directory with a space in it. For example: alias myfile="/home/ben/test case/myfile" Now, this is not expanded the way I want (it thinks /home/ben/test is the ...
user avatar
  • 143
4 votes
1 answer
927 views

Bash's Process Substitution "<(command)" equivalent in fish shell

In bash, I usually do grep -f <(command) ... (I pick grep just for example) to mimic a file input. What is the equivalent in fish shell? I cannot find it in the documentation.
user avatar
  • 1,580
4 votes
1 answer
576 views

kill %1 equivalent in fish

In bash, if I run kill %1, it kills a backgrounded command in the current shell (the most recent one, I believe). Is there an equivalent of this in fish? I haven't been able to find it online in a bit ...
user avatar
  • 143
4 votes
1 answer
2k views

Is it possible to have comments in multiline commands in fish?

In bash it's possible to do my_function() { echo "hello" | #remove 'l' tr -d 'l' } but in fish ( http://fishshell.com ) I wasn't able to do the same: function my_function echo "hello" | \ ...
user avatar
4 votes
2 answers
2k views

How to use fish on remote servers that have it installed without changing login shell?

I regularly ssh on several different servers, some of which don't have fish installed, but many do. I'd like to get fish as shell if available (changing midway is always tedious, and you lose the ...
user avatar
4 votes
1 answer
2k views

command substitution handling in fish vs. other shells (sh, bash, zsh)

The program mc (Midnight Commander) is not intended to be used for command substitution, but I would like to know why different shells behave differently when this program (and it seems like other ...
user avatar
4 votes
0 answers
102 views

Tracing environment variable modification in the fish shell

There's one item I used to use in $PATH, which is ~/.workspace/bin. I can't figure out where it's coming from. I changed the user shell to /bin/sh, logged in from TTY, checked $PATH, and it was clear ...
user avatar
  • 223
3 votes
2 answers
728 views

Why doesn't set -x work within eval within a function in fish?

I ran into an issue trying to dynamically set some variables based on output of a program, in a fish function. I narrowed my issues down to a MWE: function example eval (echo 'set -x FOO 1;') ...
user avatar
3 votes
2 answers
227 views

Issue with type force PATH search

This is Bash. The behavior is similar in fish. $ which python /usr/bin/python $ alias py=python $ type py py is aliased to `python' ​And then, running type -P py prints nothing, where as I expected ...
user avatar
  • 167
3 votes
1 answer
2k views

How can I make xfce4-terminal start fish shell?

I want to use FISH shell. But I've read FISH is not a POSIX shell so setting it to default shell by chsh is not recommended. What I want is whenever I start xfce4-terminal I would like to start FISH ...
user avatar
3 votes
2 answers
5k views

Fish Shell: How to set multiple environment variables from a file using export

Is it possible to set environment variables with export in Fish Shell? I am working on a project that configures variables this way and it does not make sense to maintain a separate configuration ...
user avatar