On iTerm2 load:

Last login: ... on ...
function: Illegal function name '-v'
~/.iterm2_shell_integration.fish (line 86):   function -v _ underscore_change
    if [ x$_ = xfish ]
from sourcing file ~/.iterm2_shell_integration.fish
    called on line 38 of file ~/.config/fish/config.fish

from sourcing file ~/.config/fish/config.fish
    called during startup

Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
⋊> ~ 


test -e {$HOME}/.iterm2_shell_integration.fish ; and source {$HOME}/.iterm2_shell_integration.fish

Fish shell version:

⋊> ~ fish -v
fish, version 2.5.0
  • 1
    While I use iTerm2 I don't use it's shell integration. However, as a core fish developer I can explain why you're seeing that error. The option parsing of the function builtin was rewritten last November to remove an ambiguity and fix a bug in how options are parsed (see commit 320cb6857). As part of that work we decided to mandate that the function name must appear first. Sorry about the trouble that has caused you. I'll check with the iTerm2 project to see if they have already adapted to that change in fish and work with them to do so if not. – Kurtis Rader Jun 6 '17 at 19:19
  • I believe my answer implies that re-running the iTerm2 integration set-up changed the order of parameters for defining that, and possibly other, functions, as I watched, which fixes the problem already. – Pysis Jun 7 '17 at 1:03
  • 1
    Yes, I checked the iTerm2 integration with fish and confirmed it is already fixed. – Kurtis Rader Jun 7 '17 at 18:11

You can input the following command, or use the more dynamic method which would do the same, or similar depending on updates, of:

  • Go into the application menu under iTerm2 > Install Shell Integration.
  • Go through the utility question dialog.
  • Go through dialog in order to run that command.
⋊> ~ curl -L https://iterm2.com/misc/install_shell_integration_and_utilities.sh | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2694  100  2694    0     0  16995      0 --:--:-- --:--:-- --:--:-- 16943
Make sure you have fish 2.2 or later. Your version is:
fish, version 2.5.0
Downloading script from https://iterm2.com/misc/fish_startup.in and saving it to /Users/jsmall/.iterm2_shell_integration.fish...
Checking if /Users/jsmall/.config/fish/config.fish contains iterm2_shell_integration...
Downloading imgcat...
Downloading it2dl...
Adding aliases...

The next time you log in, shell integration will be enabled.

You will also have these commands:
imgcat filename
  Displays the image inline.
it2dl filename
  Downloads the specified file, saving it in your Downloads folder.
⋊> ~
  • Reload iTerm2

No more error :)

Only very slightly related, but unnecessary link: GitHubGist - victor-torres/uninstall_shell_integration.sh

| improve this answer | |
  • This solved my problem, by updating the integration shell script, has described here. I don't know why someone downvoted it. – Jesper Grann Laursen May 20 '19 at 6:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.