Questions tagged [fish]
Fish is a unix shell with a clean design and a limited but powerful feature set.
236
questions
274
votes
13
answers
323k
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 ...
62
votes
3
answers
35k
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 ...
50
votes
3
answers
59k
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 ...
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-...
25
votes
7
answers
12k
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 ~/....
25
votes
5
answers
25k
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 ...
22
votes
1
answer
15k
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.
21
votes
2
answers
8k
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.
18
votes
3
answers
9k
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 ...
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 ...
16
votes
2
answers
11k
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/...
15
votes
2
answers
35k
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 ...
14
votes
2
answers
13k
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 ...
12
votes
5
answers
10k
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 ...
11
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 ...
11
votes
2
answers
11k
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 ...
9
votes
2
answers
952
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?
8
votes
3
answers
11k
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) ...
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 ...
8
votes
1
answer
6k
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 ...
7
votes
1
answer
5k
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.
7
votes
1
answer
16k
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 ...
7
votes
1
answer
2k
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.
7
votes
2
answers
2k
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 ...
7
votes
4
answers
4k
views
shell command `tmux` throws `can't use /dev/tty` error
I just switched from using terminator to termite today. I also Installed Fish and oh my fish, Spent a couple hours configuring everything, but when I went to start a tmux session to get some work ...
6
votes
1
answer
790
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 _ _ --...
6
votes
1
answer
2k
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:
6
votes
1
answer
661
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?
5
votes
1
answer
4k
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 ...
5
votes
4
answers
6k
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-...
5
votes
1
answer
741
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 ...
5
votes
1
answer
841
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 ...
5
votes
1
answer
2k
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 ...
5
votes
3
answers
4k
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 ...
5
votes
1
answer
564
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, ...
5
votes
1
answer
360
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 ...
5
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" | \
...
5
votes
1
answer
903
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-...
5
votes
3
answers
4k
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 ...
5
votes
0
answers
289
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 ...
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'...
4
votes
1
answer
2k
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 ...
4
votes
5
answers
4k
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 ...
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
...
4
votes
1
answer
3k
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 ...
4
votes
3
answers
963
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 ...
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/...
4
votes
1
answer
5k
views
Using ~/.dircolors in fish shell
I just recently switched to the fish shell from bash and I am having trouble sourcing my dircolors template file to get custom colors to appear for certain file extensions.
In bash, I was sourcing a ...
4
votes
3
answers
6k
views
How can I start tmux automatically in fish shell while connecting to remote server via ssh
I switched from bash to fish shell. I liked it and decided to use it on my servers also. How can I start tmux automatically on ssh connection? I followed this instruction for bash but fish shell is ...
4
votes
1
answer
145
views
Fish equivalent of Bash / readline's Ctrl-O "operate-and-get-next"
Readline and therefore Bash have a very useful command called operate-and-get-next, bound by default to Ctrl-O, that executes the current line, after selecting it from the history, and advances the ...