`fish` home | Main documentation page | Design document | Commands | FAQ | License

# Frequently asked questions

- Why does cd, pwd and other fish commands always resolve symlinked directories to their canonical path?
- Why does the cd command autocompletion list the subdirectories of my home directory as completions?
- I accidentally entered a directory path and fish changed directory. What happened?
- The open command doesn't work.
- How do I make fish my default shell?
- I'm seeing weird output before each prompt when using screen. What's wrong?
- How do I change the greeting message?
- Why doesn't history substitution ("!$" etc.) work?

## Why does cd, $PWD and and various fish commands always resolve symlinked directories to their canonical path?

For example if ~/images is a symlink to ~/Documents/Images, if I write 'cd images', my prompt will say ~/D/Images, not ~/images.

Because it is impossible to consistently keep symlinked directories unresolved. It is indeed possible to do this partially, and many other shells do so. But it was felt there are enough serious corner cases that this is a bad idea. Most such issues have to do with how '..' is handled, and are varitations of the following example:

Writing `cd images; ls ..` given the above directory structure would list the contents of ~/Documents, not of ~, even though using `cd ..` changes the current direcotry to ~, and the prompt, the pwd builtin and many other directory information sources suggest that the the current directory is ~/images and it's parent is ~. This issue is not possible to fix without either making every single command into a builtin, breaking Unix semantics or implementing kludges in every single command.

This issue can also be seen when doing IO redirection.

Another related issue is that many programs that operate on recursive directory trees, like the find command, silently ignore symlinked directories. For example, `find $PWD -name '*.txt'` silently fails in shells that don't resolve symlinked paths.

## Why does the cd command autocompletion list the subdirectories of my home directory as completions?

Because they are completions. In fish, if you specify a relative directory to the cd command, i.e. any path that does not start with either './' or '/', the environment variable CDPATH will be examined, and any directories in this path is used as a base direcotry. To disable this feature, write `set CDPATH .` on the commandline.

## I accidentally entered a directory path and fish changed directory. What happened?

If fish is unable to locate a command with a given name, fish will test if a directory of that name exists. If it does, it is implicitly assumed that you want to change working directory. For example, the fastest way to switch to your home directory is to simply press `~` and enter.

## The open command doesn't work.

The open command uses the mimetype database and the .desktop files used by Gnome and KDE to identify filetypes and default actions. If at least one of these two desktops are installed, but the open command is not working, this probably means that the relevant files are installed in a nonstandard location. Please contact the fish mailing list, and hopefully this can be resolved.

## How do I make fish my default shell?

If you installed fish manually (e.g. by compiling it, not by using a package manager), you first need to add fish to the list of shells by executing the following command (assuming you installed fish in /usr/local) as root:

`echo /usr/local/bin/fish >>/etc/shells`

If you installed a prepackaged version of fish, the package manager should have already done this for you.

In order to change your default shell, type:

`chsh -s /usr/local/bin/fish`

You may need to adjust the above path to e.g. /usr/bin/fish. Use the command `which fish` if you are unsure of where fish is installed.

Unfortunatly, there is no way to make the changes take effect at once, you will need to log out and back in again.

## I'm seeing weird output before each prompt when using screen. What's wrong?

Quick answer:

Run the following command in fish:

    echo 'function fish_title;end' > ~/.config/fish/config.fish

Problem solved!

The long answer:

Fish is trying to set the titlebar message of your terminal. While screen itself supports this feature, your terminal does not. Unfortuntaly, when the underlying terminal doesn't support setting the titlebar, screen simply passes through the escape codes and text to the underlying terminal instead of ignoring them. It is impossible detect and resolve this problem from inside fish since fish has no way of knowing what the underlying terminal type is. For now, the only way to fix this is to unset the titlebar message, as suggested above.

Note that fish has a default titlebar message, which will be used if the fish_title function is undefined. So simply unsetting the fish_title function will not work.

## How do I change the greeting message?

Change the value of the variable fish_greeting. For example, to remove the greeting use:

    set fish_greeting

## Why doesn't history substitution ("!$" etc.) work?

Because history substitution is an awkward interface that was invented before interactive line editing was even possible. Fish drops it in favor of perfecting the interactive history recall interface. Switching requires a small change of habits: if you want to modify an old line/word, first recall it, then edit. E.g. don't type "sudo !!" - first press Up, then Home, then type "sudo ".

Fish history recall is very simple yet effective:

- As in any modern shell, the Up arrow recalls whole lines, starting from the last line executed. A single press replaces "!!", later presses replace "!-3" and the like.
  - If the line you want is far back in the history, type any part of the line and then press Up one or more times. This will constrain the recall to lines that include this text, and you will get to the line you want much faster. This replaces "!vi", "!?bar.c" and the like.
- Alt+Up recalls individual arguments, starting from the last argument in the last line executed. A single press replaces "!$", later presses replace "!!:4" and the like.
  - If the argument you want is far back in history (e.g. 2 lines back - that's a lot of words!), type any part of it and then press Alt+Up. This will show only arguments containing that part and you will get what you want much faster. Try it out, this is very convenient!
  - If you want to reuse several arguments from the same line ("!!:3*" and the like), consider recalling the whole line and removing what you don't need (Alt+D and Alt+Backspace are your friends).

See documentation for more details about line editing in fish.