Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

5 votes
4 answers
6647 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 history of what you already typed), but changing the default shell is not a good idea, as: - there...
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 history of what you already typed), but changing the default shell is not a good idea, as: - there are many different machines that I would need to change; - on many other I'm logged in through LDAP, and changing my shell as stored on LDAP would break on machines where fish is not available; - in general, as fish is not POSIX-sh compatible putting it as default shell may break commands executed by scripts through ssh; - finally, there are a few machines where the user is shared with other people (or, where I have to login another user), so changing the default shell is not a good idea. So, ideally I'd like to have a command like ssh that automagically starts fish if available, or just leave whatever default shell is provided otherwise.
Matteo Italia (534 rep)
Oct 17, 2018, 07:57 PM • Last activity: Jul 27, 2025, 10:33 AM
-1 votes
1 answers
105 views
Fish shell : characters not displayed correctly in prompt
I'm moving from bash to fish, and I've installed [ilancosman/tide prompt][1]. However, Some characters are not displayed correctly (cf. right part): [![Prompt with character display bug][2]][2] What I've done : - Install MesloLGS fonts by putting `*.ttf` files in `/usr/local/share/fonts` and running...
I'm moving from bash to fish, and I've installed ilancosman/tide prompt . However, Some characters are not displayed correctly (cf. right part): Prompt with character display bug What I've done : - Install MesloLGS fonts by putting *.ttf files in /usr/local/share/fonts and running fc-cache -fv which outputs /usr/local/share/fonts: caching, new cache contents: 4 fonts, 0 dirs - Install powerline and fonts-powerline : sudo apt install powerline fonts-powerline - Checked that my $LANG uses UTF-8 : echo $LANG outputs fr_FR.UTF-8 What can I do to have characters displayed correctly? Thanks The buggy character seems to be git-related as the current working directory was created while performing a git clone ... and it precedes a version number. I have not modified fish prompt in any way, except by installing Fish tide: https://github.com/IlanCosman/tide I think I understood the problem, even if it is still unsolved. I copied my prompt inside libreoffice, set the font as the one supposed to be used by the tide prompt (MesloLGS), and got the following result (I manually yellowed the differences spotted with my prompt) : Prompt in libreoffice So, as I understand, the problem resides in the fact that my prompt is not using the right font. Still investigating on it.
John Kravicz (23 rep)
Jun 11, 2025, 09:42 AM • Last activity: Jun 11, 2025, 11:20 AM
2 votes
1 answers
795 views
Fish shell, disable pager navigation through Tab / Shift Tab
Fish is a great shell (the best?) but its completion interface has a particular quirk that I personally don't like and would like to disable. It's expressed by this sentence in the tutorial: > Hit tab again to cycle through the possibilities. This means that, after hitting tab to complete the longes...
Fish is a great shell (the best?) but its completion interface has a particular quirk that I personally don't like and would like to disable. It's expressed by this sentence in the tutorial: > Hit tab again to cycle through the possibilities. This means that, after hitting tab to complete the longest common prefix (behavior A) and showing a menu of further entries, if you hit Tab again you start cycling through the entries (behavior B). If there a way to disable behavior B of the Tab key, or bind it to a different key, while keeping behavior A?
Tobia (739 rep)
Jan 31, 2020, 10:31 PM • Last activity: May 15, 2025, 11:33 AM
5 votes
0 answers
690 views
Command line history in the fish shell suffering from short term memory issues
Over the last few months, I've been trying out the `fish` shell as my interactive shell. One issue that somewhat irritates me is that the shell occasionally forgets recent commands from its command line history. Let's say I have a personal script in my `$PATH` called `mail-get.sh`. I can run it by t...
Over the last few months, I've been trying out the fish shell as my interactive shell. One issue that somewhat irritates me is that the shell occasionally forgets recent commands from its command line history. Let's say I have a personal script in my $PATH called mail-get.sh. I can run it by typing its name on the command line and then recall the command at a later time by just typing get and pressing Up-arrow. Sometimes (a few times a day), the recall fails, and instead, I get _older_ commands that happen to contain the string get. The older command may be _several months_ older than the most recent invocation of my mail-get.sh script. Using history merge at that point always resolves the issue. Unfortunately, I can't reproduce the issue on purpose. I have not changed how fish should manage its history. My home directory is not network-mounted. I run several shell sessions in different tmux panes at the same time. I'm most heavily using fish version 3.5.1 on FreeBSD. My question is whether this is something that other users of the shell experience too, and whether it has a known cause and a convenient solution, or whether I should report it as a bug to the fish shell project. --- 2025 update: This is just to say that version 3.7.1 on Alpine Linux (the system I'm using the shell on most often nowadays) still exhibits the same behaviour. I see there are newer versions, 4.0.2 being the most recent. It will be interesting to test that once that version trickles down to the Unix I'm using.
Kusalananda (354171 rep)
Sep 8, 2022, 06:59 AM • Last activity: May 5, 2025, 05:44 PM
17 votes
1 answers
3687 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 without errors. My question is, Having just moved to the Fish shell and trying the same command I get an error...
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 without errors. My question is, Having just moved to the Fish shell and trying the same command I get an error stating I can't use && and instructing me to use a single & which I believe backgrounds the task which isn't what I want. Can anyone tell me the correct syntax to run my old Bash command in the Fish shell?
Nathaniel (440 rep)
Feb 10, 2016, 04:16 AM • Last activity: Apr 22, 2025, 08:03 PM
-2 votes
1 answers
38 views
Where to store a file with abbr statements that is sourced from config.fish?
I have fish started from zsh. In my `config.fish` there is a line ``` source ~/.config/fish/easy-tor.fish ``` `easy-tor.fish` is simply a bunch of `abbr` statements to quickly turn command-line Tor and SOCKS5 proxy on and off. What is the correct place to store this file? Does fish provide an offici...
I have fish started from zsh. In my config.fish there is a line
source ~/.config/fish/easy-tor.fish
easy-tor.fish is simply a bunch of abbr statements to quickly turn command-line Tor and SOCKS5 proxy on and off. What is the correct place to store this file? Does fish provide an official advice where to store files that doesn't contain functions?
jsx97 (1347 rep)
Mar 20, 2025, 02:59 PM • Last activity: Mar 20, 2025, 09:08 PM
0 votes
1 answers
30 views
Fish Plugin: How to define variables and import them in a different file
I want to define the following variables: URL, Username and Password in variables.fish and then import and use it. Since this way I would just need to configure it at one place instead of modifying each and every app I'm stumped on how to do this File structure is currently like this ``` └── functio...
I want to define the following variables: URL, Username and Password in variables.fish and then import and use it. Since this way I would just need to configure it at one place instead of modifying each and every app I'm stumped on how to do this File structure is currently like this
└── functions
    │── variables.fish
    │   └── variables like URL, username and password
    │── proxy.fish
    │   └── handler function
    │── apps
    │   └── all the app specific logic goes here
    └── utils 
        └── helper functions: pretty printing etc.
Any pointers would be appreciated thanks!
rakim0 (3 rep)
Mar 15, 2025, 07:54 AM • Last activity: Mar 15, 2025, 03:33 PM
1 votes
3 answers
223 views
Fish: To match only files or only folders
In Zsh, to match only non-directory files or only regular files or only directory files, I can use `*(^/)`, `*(.)` and `*(/)` (or `*(^/D)`, `*(.D)` and `*(/D)`, if I need to include hidden ones). Is it possible to match only files or only folders in Fish?
In Zsh, to match only non-directory files or only regular files or only directory files, I can use *(^/), *(.) and *(/) (or *(^/D), *(.D) and *(/D), if I need to include hidden ones). Is it possible to match only files or only folders in Fish?
jsx97 (1347 rep)
Jul 28, 2024, 11:55 AM • Last activity: Mar 14, 2025, 05:19 PM
2 votes
1 answers
362 views
How is "set -g" really different from "set" on fish shell?
I am trying to understand how the `set` command works [on fish shell][1]. For example, to remove the greeting message, the [fish manual suggests][2] to: > To empty the text, with the default greeting function: > > set -U fish_greeting > > or `set -g fish_greeting` in config.fish. But why it is sugge...
I am trying to understand how the set command works on fish shell . For example, to remove the greeting message, the fish manual suggests to: > To empty the text, with the default greeting function: > > set -U fish_greeting > > or set -g fish_greeting in config.fish. But why it is suggested to use set -g fish_greeting in config.fish instead of just set fish_greeting? What is the practical purpose of -g here?
jsx97 (1347 rep)
Mar 5, 2025, 07:58 AM • Last activity: Mar 5, 2025, 04:36 PM
1 votes
1 answers
253 views
Remove certain path from $PATH
To add something to $PATH in fish, I use ``` fish_add_path -a ~/foo/bar ``` Then fish adds `~/foo/bar` to my `~/.config/fish/fish_variables`: ``` SETUVAR fish_user_paths:/Users/john/foo/bar ``` Then, is it correct to say that to remove `/Users/john/foo/bar` from $PATH, I have two options: - to edit...
To add something to $PATH in fish, I use
fish_add_path -a ~/foo/bar
Then fish adds ~/foo/bar to my ~/.config/fish/fish_variables:
SETUVAR fish_user_paths:/Users/john/foo/bar
Then, is it correct to say that to remove /Users/john/foo/bar from $PATH, I have two options: - to edit the fish_variables file - to use the following function:
// https://github.com/fish-shell/fish-shell/issues/8604#issuecomment-1169638533 
  function remove_path
    if set -l index (contains -i "$argv" $fish_user_paths)
      set -e fish_user_paths[$index]
      echo "Removed $argv from the path"
    end
  end
And the second part of the question: How to properly use that function? I saved it as remove_from_path.fish, executed as remove_from_path.fish "/Users/john/foo/bar", but it doesn't seem to remove /Users/john/foo/bar from $PATH. What I'm doing wrong?
jsx97 (1347 rep)
Mar 5, 2025, 01:20 PM • Last activity: Mar 5, 2025, 02:28 PM
0 votes
1 answers
450 views
`Sessions should be nested with care. Unset $TMUX to force.` using Byobu and Fish load on boot
Since upgrading my server to Ubuntu 24.04 I keep being instantly logged out. When I connect with SSH, it just states `[exited]`. There seems to be no way of logging into my account anymore. It is a separate account to root - logging in as root seems to be fine. My account has Byobu and Fish shell se...
Since upgrading my server to Ubuntu 24.04 I keep being instantly logged out. When I connect with SSH, it just states [exited]. There seems to be no way of logging into my account anymore. It is a separate account to root - logging in as root seems to be fine. My account has Byobu and Fish shell set up to autoload on login. Restarting the virtual machine makes no difference, so it is not like another session exists. Is there anyway to resolve this?
ckhatton (101 rep)
Feb 27, 2025, 12:12 AM • Last activity: Mar 3, 2025, 09:59 PM
-1 votes
1 answers
61 views
zsh alias causes error if used in fish
I have the following aliases in my zsh: ``` alias -- -='cd -' alias ..='cd ..' alias ...='cd ../..' ``` When I switch to fish, by manually typing `fish` and pressing Return, the first alias causes an error: ``` - (line 1): function: -: invalid function name function - --description 'alias -=cd -'; c...
I have the following aliases in my zsh:
alias -- -='cd -'
alias ..='cd ..'
alias ...='cd ../..'
When I switch to fish, by manually typing fish and pressing Return, the first alias causes an error:
- (line 1): function: -: invalid function name
function -  --description 'alias -=cd -';  cd - $argv
How to workaround this?
jsx97 (1347 rep)
Mar 1, 2025, 07:11 PM • Last activity: Mar 1, 2025, 07:32 PM
2 votes
3 answers
1954 views
How do I add multiple fish functions in a single script?
I'm trying to shift to fish from zsh. As I've seen, load time of fish increases if I use **alias**. So I'd like to convert all of my alias into functions, but the thing is creating a function script for every alias is a bit hectic. So how do I add those alias in a single function script?
I'm trying to shift to fish from zsh. As I've seen, load time of fish increases if I use **alias**. So I'd like to convert all of my alias into functions, but the thing is creating a function script for every alias is a bit hectic. So how do I add those alias in a single function script?
fahimscirex (31 rep)
Aug 18, 2021, 02:56 PM • Last activity: Feb 22, 2025, 04:30 PM
1 votes
2 answers
191 views
How to expand stdin in fish?
In kakoune (vim-like editor) I can press pipe, type a command, press enter, and it will run the command using the current selection as input, and replace that selection with the output of the command ran. For example, `|jq `, where ` ` is the Enter key, will format a json selection. Sometimes though...
In kakoune (vim-like editor) I can press pipe, type a command, press enter, and it will run the command using the current selection as input, and replace that selection with the output of the command ran. For example, |jq, where `` is the Enter key, will format a json selection. Sometimes though, I'd rather have the selection used as part of the command, instead of as the input. For example if I want to use cat to replace a file name with its content. Within Kakoune there's a handy shortcut to paste the current selection in the command prompt, but it doesn't work with multi-selection (running the same command multiple times with different i/o). **The solution I settled for is to expand the stdin using $(cat). For the previous example, I would press |cat $(cat).** This use of $(cat) seems to rely on the specific (and degenerate?) way bash handles expansions and sub-process. For example, it doesn't work on zsh or fish where the expansion happens immediately and the input of cat is the output of the terminal, or I guess of whatever launched the command. Instead, in bash, the input of cat is the output of the command before the pipe. I use this pattern outside of kakoune as well, for example:
pgrep code | ps -p $(cat) -O [options]
to use pgrep to search processes and use ps to format the informations I want to display (better than with pgrep -a), but kakoune pipe command is the one use case where I cannot use the more robust and maybe more idiomatic:
ps -p $(pgrep code) -O [option]
Kakoune defaults to sh which most often means bash or dash, so I'm fine, but since I primarily use fish as my interactive shell, I am still very curious about achieving something similar in fish. Namely: **How to expand stdin from a previously piped command, or how to generate and execute a command depending on stdin ?** I'm also curious about cleaner ways in bash. One thing I love aobut interactive shell languages (as opposed to most programming language, or even to Nu) is the flexibility in the flow of information. For example, because I used to do them separately and in that order, pgrep code | ps -p $(cat) makes some sense to me, more than starting with ps, and I love having the choice. As for kak, short of writing down scripts or writing to temporary files, the pipe command does impose a constraint, which turns out rather strong despite being very reasonable.
4xel (46 rep)
Aug 9, 2024, 11:04 AM • Last activity: Jan 29, 2025, 06:48 PM
0 votes
1 answers
96 views
Inheriting path modifications vs. Inheriting aliases
My login shell is zsh. I have added the following two lines to my `.zprofile` file: ``` path+=$HOME/foobar123 alias foo='echo bar' ``` Then, if I switch to bash or fish, by typing `bash` or `fish` and pressing Return, `echo $PATH` will continue to show me the `foobar123` part, but the `foo` alias wo...
My login shell is zsh. I have added the following two lines to my .zprofile file:
path+=$HOME/foobar123
alias foo='echo bar'
Then, if I switch to bash or fish, by typing bash or fish and pressing Return, echo $PATH will continue to show me the foobar123 part, but the foo alias won't work. Why is that? Why aliases and path modifications are treated differently?
jsx97 (1347 rep)
Dec 18, 2024, 06:18 PM • Last activity: Dec 18, 2024, 08:37 PM
4 votes
2 answers
1664 views
'exec fish' at the very bottom of my '.zshrc' - is it possible to bypass it?
I prefer to use the fish shell on macOS most of the time, but refrain to make it the login shell, because I think sometimes it may cause problems. So, I simply added `exec fish` at the very bottom of my `.zshrc`, and that's it. Which means my login shell is still zsh, and my `$PATH` modifications ar...
I prefer to use the fish shell on macOS most of the time, but refrain to make it the login shell, because I think sometimes it may cause problems. So, I simply added exec fish at the very bottom of my .zshrc, and that's it. Which means my login shell is still zsh, and my $PATH modifications are still in .zprofile, but when I open the terminal, I don't have to switch to fish manually. Works fine for me. But then, what if I nevertheless want to switch from fish to zsh for some specific reason? Is it possible somehow? (Because if I simply type zsh and press Return, I will be immediately switched back to fish, of course.) **update:** There is a workaround to use zsh -c, but it works with some commands only.
jsx97 (1347 rep)
Dec 16, 2024, 11:22 AM • Last activity: Dec 16, 2024, 06:45 PM
0 votes
1 answers
202 views
Trying to set a keyboard shortcut to the fish shell desktop application
How can one open the **fish terminal** with a keyboard shortcut like `ctl-alt-t` in the **gnome desktop environment** running on **debian**? Steps I have taken: 1. Installed the **fish shell** and run it from **gnome-terminal**. 2. Successfully run the **fish shell terminal gui** from the **applicat...
How can one open the **fish terminal** with a keyboard shortcut like ctl-alt-t in the **gnome desktop environment** running on **debian**? Steps I have taken: 1. Installed the **fish shell** and run it from **gnome-terminal**. 2. Successfully run the **fish shell terminal gui** from the **applications** list in settings>applications. 3. Checked the **fish.desktop** file in /usr/share/applications to find the exec command
[Desktop Entry]
Version=1.0
Type=Application
Terminal=true
# This file is for use in appimages, which rewrite the path.
# Other uses would have to replace these with the correct path.
Exec=fish
Name=fish
Comment=The user-friendly command line shell
Icon=fish
# "Shell" would be the proper category, but it's reserved so we can't use it.
Categories=ConsoleOnly;System;
4. Created a keyboard shortcut under Settings>Keyboard>Keyboard Shortcuts>View And Customize Shortcuts>Custom Shortcuts>Set Custom Shortcut enter image description here But pressing ctl-alt-t doesn't open the fish terminal.
Sven Voigt (23 rep)
Dec 3, 2024, 11:02 PM • Last activity: Dec 4, 2024, 05:04 AM
0 votes
0 answers
180 views
Fish shell: Completion: how to define command sub-argument completion?
I would like if it is possible to define completion for sub arguments in fish Best explained w/ an example: $ somecmd -k foo[arg1,arg2,..argK,.,argN] -----------------------------^^^^ Cpmpletions for the arg1, arg2 ... argN ? Possible? How would you do it? The general interesting case for me is that...
I would like if it is possible to define completion for sub arguments in fish Best explained w/ an example: $ somecmd -k foo[arg1,arg2,..argK,.,argN] -----------------------------^^^^ Cpmpletions for the arg1, arg2 ... argN ? Possible? How would you do it? The general interesting case for me is that argN takes it values in a finite list (depending on K and foo) N is variable I have imagined some things with matching list of regexes => tedious at best Have looked under /usr/local/share/fish/completions/*, found nothing resembling (ignoring the fact that '[' is a shell special char, in a first attempt ) Thanks very much in advance for any hints!
StephPe71 (1 rep)
Oct 14, 2024, 11:56 AM
3 votes
1 answers
1074 views
How can I send stdout to multiple commands in fish shell?
Same question as [https://unix.stackexchange.com/questions/28503/how-can-i-send-stdout-to-multiple-commands][1] but for fish shell. [1]: https://unix.stackexchange.com/questions/28503/how-can-i-send-stdout-to-multiple-commands
user699151 (31 rep)
Jul 1, 2017, 12:39 AM • Last activity: Oct 5, 2024, 09:54 AM
0 votes
0 answers
97 views
All commands need Ctrl-c in Linux terminal
Each time I type a command in Linux terminal, the cursor doesn't go to a newline and I have to Ctrl-c in order to get a newline. I already tried the reset command but it doesn't work. This happened since I typed cd (as a habit) while the terminal was still loading when I start it.
Each time I type a command in Linux terminal, the cursor doesn't go to a newline and I have to Ctrl-c in order to get a newline. I already tried the reset command but it doesn't work. This happened since I typed cd (as a habit) while the terminal was still loading when I start it.
JEMEL ELYES (1 rep)
Sep 20, 2024, 12:34 PM
Showing page 1 of 20 total questions