Hacker News new | past | comments | ask | show | jobs | submit login
fish shell (fishshell.com)
122 points by atldev on Aug 16, 2013 | hide | past | favorite | 75 comments



The fact that you cannot redirect stderr to stdout and pipe to another command is a bit of a stumbling point for me. When I saw the bug[1] for the first time I thought that it must be some strange corner case, but it turns out it is a real bug. After reading the bug report I started to wonder if there were any other other unixy features that were missing. I/O redirection is a core unix concept in my opinion.

[1] "Redirect stderr to stdout and pipe doesn't work as expected" https://github.com/fish-shell/fish-shell/issues/110


It doesn't have process redirection either, and that's one I use a fair bit. For example

    paste <(hquery -q '//a/@href' x) <(hquery -q '//a' x)
Where hquery is one of my utilities for running xpath queries over loosely parsed HTML. This would produce a tab-delimited list of link urls to link text.


Try piping into psub, as in

    paste (hquery -q '//a/@href' x | psub) (hquery -q '//a' x | psub)
http://ridiculousfish.com/shell/user_doc/html/commands.html#...


It actually made me switch back to zsh. Pipe not working is just a no go for me. But overall, this is a great shell, very accessible compared to bash/zsh, I particularly appreciated the configuration mechanism.


What made me finally stop trying to use it is that you can't modify the environment of a command like so: HOWDY=pardner env.


I've been using fish for a while now. Overall it's pretty great.

Here's my fish config if you want to see an example: https://bitbucket.org/sjl/dotfiles/src/tip/fish/config.fish


Gotta say, this one is my favorite:

    112 function hey_virtualbox_shut_down_or_i_will_fucking_cut_you
    113     VBoxManage controlvm $argv poweroff
    114 end


I've always been a fan of die_you_gravy_sucking_pig_dog() from the FreeBSD source.

http://www.freebsd.org/cgi/cvsweb.cgi/~checkout~/src/sbin/sh...


A powerful demonstration of self-documenting code. I applaud the application.


For someone calling fish 'pretty great' I sure see a lot of angst towards fish in that config file! Thanks for the post though.


This config file is glorious. Every other line is just pure gold.

   function fish_user_keybindings
       jesus_fucking_christ_bind_the_fucking_keys_fish
   end


Thanks for posting your config. I've learned a lot from it. In return, here is my Fish config. https://github.com/jramnani/dotfiles/tree/master/fish

As you'll see, I like the way Fish automatically loads functions from, "$HOME/.config/fish/functions/". It keeps my config.fish file pretty lean.


For people looking for a more generic start https://github.com/bpinto/oh-my-fish might be a good hint, too


Previous discussions:

    https://news.ycombinator.com/item?id=5723235
    https://news.ycombinator.com/item?id=5567639
    https://news.ycombinator.com/item?id=4073162


I tried fish, last time it was posted. I quickly abandoned it though.

One of my main commandline utilities is git in combination with git-flow(amazing). I found the normal git completion lacking. I believe branches didn't get completed correctly in combination with some commands. The git-flow completion was non existent.

When that changes I might try it again. But for a shell that has tabcompletion as a selling point I was very unimpressed.


One of my favourite features: a single configuration file. No more .bashrc and .bash_profile .

However, it seems like Fish is not fully POSIX-compatible, therefore you can face weird problems in Vim plugins, for example.


I just leave bash as my system shell and just configure my terminal emulator to start with fish.


In your .vimrc, insert at the top:

set shell=/bin/sh

No more problems with plugins in fish.


For people that just don't care about advanced features or gotchas, fish seems fine.

For people that exploit redirection, file handle rewiring, here docs and such... consider zsh with https://github.com/sorin-ionescu/prezto


I like the features it has, but every time someone post a link to fish shell, I wonder why I would switch from bash or zsh. Will this really be THAT MUCH BETTER? Will I just run into weird errors? Is it totally sh compliant? These are important things to know and should be on the homepage.


I am a year-or-two-old fishshell convert who is reasonably well versed in bash and tried using zsh and bash with a big .bashrc.

A few things stand out to me as huge pluses:

- It has a lot of cool functionality out of the box such as highlighting, smarter autocomplete (type in a partial word at the prompt and hit up instead of the cumbersome bash ctrl r/s history prompt that loves to beep at you), directory history (alt left-arrow and alt right-arrow), and more.

- You don't need a 10k .bashrc or 1k .zshrc to unlock most of that cool functionality, it's just enabled by default. So anywhere you have fishshell installed, you get 95% of what you're used to, no need to git clone or scp over your .bashrc.

- Startup time is _very_ quick compared to bash or zsh with said 10k .bashrc or 1k .zshrc, and is comparable to bash or zdh with no startup file.

The only weird error I ever ran into was with an older version of fish shell complaining about missing directories in your PATH every time there was an automatic completion available. I have not run into that issue with newer releases.

It is not sh-compliant, which will occasionally wreck havoc when you have a program that shells out without explicitly using sh. I remember running into this issue specifically with vim and emacs on more than one occasion, but truth-be-told I consider this a bug with those programs rather than a fault with fish.

There's also the matter of it not being installed on some machines, but I've used bash for so many years now that my brain flips back into bash-mode anytime I see that familiar colorless prompt with a dollar sign at the end.

It's not an essential upgrade. I also wouldn't bother using it for shell scripts either. But I'd say give it a boy scout try for interactive usage and see how you like it.


I fully agree: The sensible and intuitive defaults (ie. arrow up/down for history; tab/rightarrow for autocompletion) and simply so much which just works out of the box (beautiful styled completion list with program descriptions in it, colors, sensible help) made me instantly fall in love with fish.

Be sure to try Fish 2.0 which is even much more awesome than the older version.


I just want to throw in that you can get that nice up-arrow-history in bash too. It's the first thing I put in a new bash environment:

  bind '"\e[A":history-search-backward'
  bind '"\e[B":history-search-forward'


Do you know anyone with a 10k .bashrc?


My apologies, I was being a little facetious. Just a little. :)

The size difference was based on my intuition that when I maintained my own .bashrc and .zshrc, I was able to "get away" with fewer total lines in my .zshrc than my .bashrc. I remember my .bashrc being dozens of pages, my .zshrc was only a couple.

Compare that to my fish init file...all it does is set a few paths and aliases and turn off the greeting, because everything else just works out of the box for me.


I just checked, for fun:

    $ ls -lh .bashrc
    -rw-r--r--    1 <me>    <me>         10k Jul 26 13:31 .bashrc
Yep.

It's also remarkably fast because I took great effort to optimize the parts that happen the most. Shell is actually pretty fast if you don't fork and exec all the time...


What do you have in it that takes up so much space? FYI: I'm not being argumentative, I am genuinely curious.


Well, it's about 400 lines total. Roughly 40% of that is PATH handling functions: add_to, append_to, replace_in, remove_from, prefix and unprefix. They're used like:

    add_to PATH /usr/sbin
prefix and unprefix are a macro for a bunch of standard replace_in/remove_froms:

    prefix() {
        replace_in PATH "$1/bin"
        replace_in PATH "$1/sbin"
        replace_in PATH "$1/lib/ccache"
        replace_in MANPATH "$1/share/man"
        replace_in MANPATH "$1/man"
        replace_in PKG_CONFIG_PATH "$1/lib/pkgconfig"
    ...etc.
So that later I can do stuff like:

    prefix /usr/local
    prefix /usr/local/brew
    prefix /usr/local/ports
...All of which are managed by different package managers (stow, brew, ports).

All that stuff is the part I optimized so that it only uses bash built-ins and never execs. Converting that away from sed/perl shaved about 8 seconds off my startup time (it's now so fast I don't notice it).

The next 20% is interactive stuff. Setting up the prompt, aliases, stty, etc. This is generally more complicated than it technically needs to be because it's cross platform so it'll run on any unix-y thing with no changes.

Then remaining 40% is a big chunk of shell functions that are mostly unused in my day-to-day life, but kept there to jog my memory if I need to do a certain task.

That adds up to 100%, but it's also worth noting that 27% of that is blank lines and comments.


I know people with well more than that, particularly when you factor in 'oh my zsh' and its ilk.


I am not sure I would include oh-my-zsh as someone's personal zshrc. Moreover I thought OP had made a distinction between bash (10k) and zsh (1k) so I am not sure how o-m-z counts as a bashrc? I will take your word for it but I cant imagine what people put in there bashrc to get to 10k. The entire bash-it repository is 8,588 and over a third of it is bash completions which seems to duplicate the majority of what is already provided by bash-completion. And I am not sure that bash-completion is really "my .bashrc."

  $ cd bash-it
  $ sloccount ./ 
  ...SNIP...
  SLOC    Directory       SLOC-by-Language (Sorted)
  3198    completion      sh=3198
  3168    plugins         sh=3168
  1081    themes          sh=1081
  748     lib             sh=748
  242     aliases         sh=242
  135     top_dir         sh=135
  16      template        sh=16
  0       custom          (none)


  Totals grouped by language (dominant language first):
  sh:            8588 (100.00%)

Are there some big bashrc customizations that I might be overlooking?

edited to reflect distinction between parent and grandparent comment


Sorry, I'm not the parent commenter.


The thing that's stalled me out from using fish before is that it's different enough from the Bourne shell that it seriously interrupts my day to day usage; but it's TOO similar, with the horrible shell semantics. So it's never really been worth it to me.


Take a look at the concept of status quo bias.

What I do is spawn fish at the end of my .zshrc that way I can just exit if I run into something that doesn't work with fish.

The biggest plus for me is that the default auto complete in fish is twice as smart as the other ones.


It is NOT totally sh compliant. Intentionally.


I really liked fish, but as someone who is still learning bash/cli scripting, it makes things difficult when instructions from programs come only in Bash syntax, which does not work well with fish (some things with homebrew were an absolute nightmare to install).


It definitely makes following instructions a little more complex, but in most instances when a line doesn't work I've found that a quick switch over to bash to run that line and back proves to be sufficient.

Of course I'm also very new to bash/cli so I'm just happy if I can get things done and haven't yet gotten to the stage where I'm worrying about if it's the proper way to go about doing things.


How I installed Homebrew from fish: bash ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"


I've been using fish for a while and have generally been very happy, I'm even working on creating a set of functions for ROS to integrate with fish the way it currently does with bash and zsh. My one tiny gripe is the way that if I

  set foo this that "the other"
then

  echo $faux; echo $faux[1]
doesn't produce anything, but

  echo $foo[4]
gives me an error message that I can't just pipe to /dev/null

Also, writing autocompletes for functions is both far simpler than in bash, but I'm also missing some of tools that bash provides.


That's very interesting, especially for people interested in using ROS as an educational platform.

It would be pretty amazing, considering the file resolution properties of ROS. I actually love it since I don't have to be in the same directory and it's easy to go through many projects.

Just curious what sort of work are you doing on ROS. Earlier this year I was working on simulation stuff in Gazebo.


I'm a robotics software engineer at Vecna, working on our QC Bot[1]. We use a combination of ROS and our own Java stuff for the robot system, and since I'm a long time fish user I started doing the port for my own use. I've been working on getting the patch into shape for actually going upstream in the 4 hours per week we get for community service, contributing to open source, etc.

[1]https://www.vecna.com/solutions/hospital-delivery


Why is this interesting when we have zsh?

https://github.com/robbyrussell/oh-my-zsh?source=cc


Others may say say why is zsh interesting when we have rc? Or why is rc interesting when we have bash? Others may ask why is bash interesting when we have tcsh or pdksh?

I would like to know what is interesting about a world with one shell for every user?


zsh is really just fancy bash. fish feels like a brand new shell, and in my opinion, what a shell should be


Why is zsh interesting, when you can have a friendly shell out of the box

https://github.com/bpinto/oh-my-fish

I tried to get started with both. For me fish was by far the easier & more friendly starter. For shell powerusers zsh might be offer more options and less pitfalls.



One thing I have found with prezto (as well as oh-my-zsh) is that over time, starting up a new terminal window can take a while. On the other hand, when I tried fish, I found certain aspects of it to be sluggish (autocomplete, for example).


Fish is a great interactive shell. I've been using it for some time now.

A few things I occasionally run into: You can't just paste somebodies setup instructions into your shell anymore (you can temporarily invoke bash for that though). And when writing setup instructions yourself, sh is still pretty much the standard. VirtualEnv generates an activate.fish out of the box - nice! I still occasionally type !grep by accident. And I do miss &&.


I defined the following function to convert my bash aliases to fish functions, which eased my switchover a bit. I saved it as ~/.config/fish/functions/import_bash_aliases.fish

  function import_bash_aliases --description 'bash aliases to .fish function files.'
      for a in (cat ~/.bashrc  | grep "^alias")
          set aname (echo $a | grep -Eoe "[a-z0-9]+=" | sed 's/=//')
          set command (echo $a | sed 's/^alias .*=//' \
            | sed 's/^ *\'//' | sed 's/\' *$//' )
          echo "Processing alias $aname as $command"
          if test -f ~/.config/fish/functions/$aname.fish
              echo Function $aname is already defined. Skipping...
          else
              alias $aname $command
              funcsave $aname
          end
      end
  end


I have been using fish for a few months exclusively on my Mac. I really miss a few bashisms: mostly pressing esc-. inserts the last part of the last command. I have not changed the shell on my server, somehow I am afraid of breaking things... (bad shell scripts that don't have correct shebang line).


esc-. is my biggest miss as well. There are discussions on this but still havent been able to fix it on osx in iterm2 myself. Did get option-. to work for now but esc-. has 20+ years of pure reflex action burned into my brain.


Can you post your solution (or give a pointer)?


function fish_user_key_bindings bind \e. 'history-token-search-backward' end

There is a thread about it here

https://github.com/fish-shell/fish-shell/issues/89


Not successful yet on the Mac Terminal.app command line... Thanks anyway.


In fish it's simple enough to start typing the command you want and then hit arrow right to autocomplete. If you have a couple often commands that start the same way just arrow up or down to cycle through them, then arrow right to put them on the command line.


Simplified example: mkdir foo, cd foo. I type in mkdir foo then press enter, type "cd esc-.". Doesn't work. Command completion in fish doesn't help here. In real life this is of course mostly more complicated than a simple "foo".


I use zsh and for this use case I typically use "mkdir foo" followed by "cd $!".


function mkcd () { mkdir -p "$1" && cd "$1" }


as I wrote: this is a simplified example ...


I just took fish for a quick spin, and... wow -- I am impressed. It really feels "interactive". I don't think I'll replace my battle tested zsh, but even as a "grumpy old man": you should at least try it. It feels really... fresh.


One thing I missed in fish was bash's sudo !! to quickly re-execute a command.

A replacement is easy enough though and is in my config here: https://github.com/dmotz/dotfiles/blob/master/functions/sudo...

Beyond a few other syntax incompatibilities, I've enjoyed using it.


Gave fish a shot for a week or so. It gives some "oohs and ahs" right off the bat, but in the long term, not something that I could use.

Maybe if it was at least somewhat bash or POSIX compatible I would be on board, but the developers don't even seem to want to help us out in that regard.


I've been using fish for about 3 months now and I love it. Switched from bash.

Here's a presentation I gave to my local coder community on fish: http://www.youtube.com/watch?v=SWmKfb2jQhU


"Finally, a command line shell for the 90s"

Now that's an odd slogan. Is it trying to make the point that the competition is even older? Appeal to old-school hackers? Subtly tell me that the project hasn't been updated in a while?


It's satire.


See it in action here: http://youtu.be/MVw8N3hTfCI?t=56s


the developer should provider a converter tool to convert .bashrc/.zshrc to fish config


it looks like a NP-Complete problem


A solution that converted as many easy things as possible and then output anything it couldn't figure out somewhere so you could convert that by hand would still probably be rather useful.


Agreed. And from what I understand it's how the python 2 -> 3 transition was dealt with.


fish: the shell for people who want to use multi-line echo instead of here-docs.


Oooh, it's like a MUD!


I like auto-complete in web-browsers, but I can't see a single use for it in my terminals. After all, what Linux-user hasn't automated their terminal input to some degree? Nah, I'll stick with my [TAB]...


You can't see a single use for auto-complete in your terminal so you'll stick to your key invoking auto-complete in your terminal?


You could just try it instead of speculating


I tried it for a while and I just can't work with it. I'm back to fish 1.23 for now, and I don't know what I'll do when that becomes unmaintainable. I might just have some personal patches, I really wish they included an option to disable it.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: