32 ms·
Fish shell 3.0
- robin_reala 8y agoApart from the other good stuff in this release, I think this will make a lot of things much easier: fish now supports && (like and), || (like or), and ! (like not), for better migration from POSIX-compliant shells
- binaryanomaly 8y agoOh yes
- hak8or 8y agoThis is absolutely thrilling! I often have to flip between bash and fish due to some archaic tools we wrote relying on bash in wierd ways, and the swap between how both handled logic like this was cumbersome. Glad to see one less potential reason my team won't use fish.
- aequitas 8y agoThough I've really grown toward the 'everything as a function' pattern that Fish is trying to do, this is definitely a step back in the right direction. I might even wish for `$()` to be supported as well to allow even better copy pastable oneliners from Bash.
- OJFord 8y agoI thought it was to be included in 3.0, there's certainly an issue on it.
- e12e 8y agoYour quoting is a bit confusing, as "`cmd...`" and "$(cmd...)" are similar,, while backtick-dollar-paranthesis is just asking for trouble... ;) I take it fish didn't / doesn't support either?
- sitharus 8y agoFish uses parentheses for command expansion, so backticks aren’t supported and the dollar sign is only for variable substitution.
- ElijahLynn 8y agoFish just uses (cmd), no $.
- e12e 8y agoAh, which I guess is why no subshell support?
- cormacrelf 8y agoThere are other ways to do subshells than using the same syntax, just that the Fish developers never did it, maybe because it's not requested enough. I think it's still the most annoying thing about Fish, and the most convincing reason to switch away again. I frequently drop into bash to do (cd subdirectory && command --that might.fail) && run --command-in-original-dir --only-if-subshell-succeeded ... and expect to still be in the original dir when it's done. Any solution in Fish using "&& cd -" at the end of a block AFTER a maybe-failing command is just wrong, and there seriously isn't any way except saving and restoring $PWD every time you want subshell functionality, or using "; cd -" and manually saving the $status, which is equally as frustrating. There are some non-syntactic suggestions in https://github.com/fish-shell/fish-shell/issues/1439 https://github.com/fish-shell/fish-shell/issues/1439
- aequitas 8y agoSorry for the confusion, I'm to used to `` as code style for markdown, forgot HN doesn't support it. I'm glad Fish doesn't support the backtick syntax :). Like others mention it just drops the dollar from a 'regular' parenthesis expansion.
- giancarlostoro 8y agoAwesome! I remember bumping into the github issue over it but I guess I didn't read far enough (or maybe it was long ago) to see that they were finally going to support && and || instead.
- maxfurman 8y agoFinally! Fish 2.x shows you a message along the lines of "use `and` instead of `&&`", which is infuriating - it clearly knows what I want to do, and refuses to do it. I love fish and use it as my default shell, but I'm glad to see the fish team take a few steps towards bash compat.
- Buttons840 8y agoJust because a language knows what you mean to do and can give a specific error messagr doesn't mean that, in general, and specifically, the developers want to commit to supporting && as valid syntax forever. Perhaps the language creators have plans for future syntax that would not allow what you want. Even if for now the language evidently knows what you mean from the error message. In this specific case, the developers of fish apparently decided && was good to add.
- zorked 8y agoThat reminds me of the very specific nag messages I get from Python 3 when I don't write parens around parameters for print... do what I want already.
- robdachshund 8y agoIf print() is a function why should you be able to call it like that? Python 3 was just fixing that inconsistency. Functions have their arguments inside of parentheses. Should we be able to call "requests.post url, data"? It sounds like you are upset with the language for resolving something that never made sense to begin with.
- pseudalopex 8y agoWhat does someone want if they write "bar = print foo,"? Is it the same if "print" isn't the built-in function?
- shaki-dora 8y agoOperator precedence isn't really a new concept, and Python relies on it in plenty other situations: bar = 1 + 1 I do believe Python made the right call, actually: print needed to be unified with functions, and dropping the requirement for parenthesis for function calls would have introduced so much incompatibility as to make the Python 2 -> 3 transition far more difficult. But ignoring the legacy issue, there is a better way to do function calls, and it is ruby.
- phirschybar 8y agoawesome! can't tell you the number of times I have slammed into this when copy/pasting.
- hinkley 8y agoThat’s new? Suddenly I feel less guilty about dodging coworkers who have been trying for years to get other people to try fish. But maybe now it’s getting closer to production readiness.
- faho 8y agoFish uses (and still supports) `command1; and command2` instead of `command1 && command2` (and similarly for `||`/`or` and `!`/`not`). The syntax is different, the semantics are the same.
- StavrosK 8y agoThe fact that it doesn't support your particular preferred syntax doesn't mean it's not production-ready.
- jhardy54 8y ago> your particular preferred syntax I think it's called POSIX.
- pstadler 8y agoI‘m not switching to fish because of its lack of POSIX compliancy. This is a valid complaint.
- faho 8y agoIt is! But calling it "getting closer to production readiness" feels a tad insulting. It's probably just a bit of snark, so it's not worth getting up in arms about, but it's not really friendly phrasing.
- eberkund 8y agoI upgraded with homebrew to v3.0 but the && syntax still doesn't work, do I have to do something special to enable it?
- robin_reala 8y agoClose your shell and open it (or run fish again). You’re probably still in the original fish 2.7 that had previously launched. fish --version should show 3.0.0 (edit: yeah, that’s not going to work).
- therealdrag0 8y ago`fish --version` showed 3.0.0, after brew update but without closing terminal, but `ls && echo finally` still didn't work. However, closing and re-opening terminal, it now works.
- faho 8y ago`fish --version` starts a new fish that prints _its_ version. You were still running the old version, and `echo $version` would have told you.
- robin_reala 8y agoHah, oops, should have realised that.
- cies 8y agoBecause you still run the old version as your shell, from which you run the new version merely to have it print its version.
- lachlantula 8y agolooks like i'm switching back to it again from zsh
- duckerude 8y ago>? as a glob (wildcard) is deprecated and will be removed in the future (https://github.com/fish-shell/fish-shell/issues/4520 https://github.com/fish-shell/fish-shell/issues/4520) This surprised me, but maybe it's for the best. It got in my way more often than I used it. I'll still miss it.
- ComputerGuru 8y agoIt makes pasting unescaped data (read: URLs) and writing raw regexes easier (esp because ^ is no longer a reserved character as well).
- djsumdog 8y agohuh ... interesting. I missed that. I often quote URLs when running wget because of question marks, and I guess I don't have to now.
- aequitas 8y agoYou still have to watch out for ampersands though.
- hestefisk 8y agoLong time zsh user here. Any reason one should try out fish?
- giancarlostoro 8y agoI'm not sure how nice zsh is by default, but out of the box Fish is nice, it's just not compatible with bash scripts. I think of it as a really nice shell for terminal use, I wouldn't write "fish" scripts personally, not as portable. I mostly like that it tells me when my commands are wrong or when it autocompletes (usually hints are based on the directory you're in which is nice). I tried zsh ages back and if I remember correctly you had to configure it yourself to get to such a point. Note I only install fish in systems I fully own, I rather not confuse coworkers by using another shell. Also forces me to be more careful when in a production system.
- lghh 8y agoThere is basically no configuration. It's set it and forget it.
- aequitas 8y agoComing from ZSH, Fish is a shell that just worked out of the box for me. It did everything ZSH did but I didn't have to touch a single configuration file to make it work. With ZSH I was forced to find all the options I wanted enabled and tuned or had to resort oh-my-zsh or templates from others to get all the good stuff. Managing dotfiles across workstations and servers. With Fish about the only thing I do after installing is set a theme with Git status.
- hjek 8y ago> It did everything ZSH did ... and some additional things that you can't do in zsh without plugins, such as autosuggestions[0]. [0]: https://github.com/zsh-users/zsh-autosuggestions https://github.com/zsh-users/zsh-autosuggestions
- cpach 8y ago”Fish is a shell that just worked out of the box for me” Same here. Fish’s configuration defaults are very well thought out and incredibly smooth. My config.fish is only nine lines.
- CJefferson 8y agoThe one thing I miss most in fish is subshells, because I love writing things like ( (cd $dir && ./run_prog && cd PKG && ./do_stuff) & ), to run a series of things in the background. Is there any way to do something similar in fish?
- faho 8y agoWhat this does is two things: - It keeps the state separate from the main shell, including $PWD (so the `cd` doesn't affect the main execution "thread") - It executes some script in the background Fish's backgrounding is currently limited to single external commands (not even functions). That's https://github.com/fish-shell/fish-shell/issues/238 https://github.com/fish-shell/fish-shell/issues/238. It also doesn't have the capability to keep $PWD separate, though other variables can of course be declared locally. That's https://github.com/fish-shell/fish-shell/issues/1439 https://github.com/fish-shell/fish-shell/issues/1439. The workaround is, if you actually need this, to run it inside `fish -c`. Which is essentially what this syntax is doing in the background anyway (it needs to fork off because `chdir` applies to the entire process). (Disclosure: I'm a fish developer)
- SomeHacker44 8y agoForking off a subshell is very different, I would think, than forking and execing a new shell, both from a resource standpoint and an open file standpoint.
- faho 8y agoNot really from a usage perspective though, and resources often don't matter. If you're doing something like this in the background, then that usually means it takes a "long" time (or you'd just wait for it). So the overhead of starting an additional shell simply isn't important. Not that it's always irrelevant, but that's why the issues are still open.
- SomeHacker44 8y agoAgreed, resources often don't matter. But I do often do something like: ( cd somewhere ; do_something ) just so I can avoid having to do pushd somewhere ; do_something ; popd (or the equivalent).
- rbosinger 8y agoSo weird. Last night I ran a bunch of updates and spent some time cleaning up and configuring my laptop. Preparing for the New Year. I tried to upgrade Fish and saw that it hadn't had an update since this time last year. I ended up looking through the release logs and just reading the Fish docs a bit. I never do this. Now, this morning, this is on Hacker News.
- hnarn 8y agoIt's not weird, it's a cognitive bias: Frequency illusion (or Baader–Meinhof effect): The illusion in which a word, a name, or other thing that has recently come to one's attention suddenly seems to appear with improbable frequency shortly afterwards. https://en.wikipedia.org/wiki/List_of_cognitive_biases https://en.wikipedia.org/wiki/List_of_cognitive_biases
- phirschybar 8y agoI think it's more like a productive time of year for hackers to get things done :). The week between xmas and new years is always super productive and creative for me... it's quiet and there is a subconscious urge to wrap things up before year end.
- rbosinger 8y agoYeah, I was thinking that too but I look at Hacker News daily and at least once a week a coworker bugs me about using Fish. So it's not like the idea or thought is new to me. In particular this one was weird because I was not only thinking about Fish but checking specifically for an upgrade which I've never cared much about before.
- man-and-laptop 8y agoFish Shell has been having some problems implementing process substitution. Last I checked, they tried two approaches: * piping to FIFO files, but it throws an error if you pump too much data into them * waiting until one process finishes before starting another. That's not a correct implementation either Bash apparently resorts to black-magic.
- yorwba 8y agoThe Bash manual seems to imply that they use /dev/fd to implement process substitution like regular pipes, but passing the pipe file descriptor as its filename under /dev/fd. https://www.gnu.org/software/bash/manual/html_node/Process-Substitution.html https://www.gnu.org/software/bash/manual/html_node/Process-S...
- deleted 8y ago[deleted]
- mlrtime 8y agoTo install on ubuntu if you don't want to build: sudo apt-add-repository ppa:fish-shell/release-3 sudo apt-get update sudo apt-get install fish https://launchpad.net/~fish-shell/+archive/ubuntu/release-3 https://launchpad.net/~fish-shell/+archive/ubuntu/release-3
- ElijahLynn 8y agoTo install on Arch (w/yay), `yay -S fish`. (just a plug for how easy it is to install packages on Arch)
- thiagowfx 8y agoAdding the usual disclaimer that yay is an AUR helper and thus not officially supported by Arch. Arch users are advised to read https://wiki.archlinux.org/index.php/Arch_User_Repository https://wiki.archlinux.org/index.php/Arch_User_Repository instead. If you know what you're doing, of course using yay should be fine as well.
- doubleunplussed 8y agoIt should be noted that adding a PPA is equally unsupported, so in both cases you're trusting a third party. Despite all the disclaimers (or perhaps because of them), the AUR is IMHO one of the more safe and well-thought-out ways of including third-party stuff. It's relatively simple to verify that the package is installing what it says it is, because you can check the PKGBUILD file, which is short and simple to read. I would have no idea how to go about verifying that a .deb file was what it said it was.
- zapzupnz 8y ago`dpkg -L filename.deb` provides a list of files to be installed.
- mlrtime 8y agoDoes yay come default on arch linux?
- jacobherrington 8y agoI loved Fish while I used it. I recently stopped using it because I'm writing a lot of documentation. I prefer to do thing using bash or zsh now so I can be sure it will work for others.
- jonathankoren 8y agoI run tcsh. It won’t.
- naniwaduni 8y agoYou know you run tcsh. fish users usually know they run fish. You don't expect to be able to run arbitrary copy-pasted shell snippets in the first place.
- beatgammit 8y agoI try to run my scripts on /bin/sh (on a system where that's not just a symlink to a fancier shell) before posting them. That means it's more portable, but still not universal. I don't typically have bash on my BSD systems, and when I do, they're not installed to /bin, so this is also somewhat out of self interest as well.
- jeffbax 8y agoI've been happily using fish for maybe two years now, just as a default shell and not doing anything fancy. Out of the box it is great. I'm not sure how to feel about only now learning its indexes start at a [1] though (╯°□°)╯︵ ┻━┻ Love it otherwise.
- nerdponx 8y agoStarting at 1 is good for non-programmers, who IMO could benefit the most from switching to Fish. I would love to see a distro using Fish as the default shell for non-root users.
- AnthonBerg 8y agoWhen I’ve been teaching people to program, explaining [0] has been a tragic experience. Starting at [0] is not objectively better than [1]. I actually believe it is objectively worse.
- explainplease 8y agohttps://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/E...
- StavrosK 8y agoI would like to hear your counterarguments to https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/E..., which seems to me like a compelling argument.
- saagarjha 8y agoIt is a compelling argument for calculating ranges, where the subscript is the offset into the range, which is useful when your data structure has properties like being backed by continuous memory and being passed around as a pointer to the first element. But when treating subscripting as “give me the nth element” it doesn’t really make sense.
- linsomniac 8y agoI made fish my default shell for around a month, and I really liked the smart suggestions of what command I was going for when I started typing. But the "vi" mode had enough incompatibilities that it really irritated me, it was extremely incomplete. Discussions of it with devs went nowhere. Plus, there were incompatibilities in the language that I could never bring myself to commit to memory; I might have if the vi mode were better but as it was I didn't want to get any further invested in it than I was. In the end I switched back to zsh and enabled "zsh-autosuggestions", which gave me the thing I loved most about fish, without any of the parts that I didn't. There's also some other extensions I'd like to try that enhance history like "McFly" ( https://github.com/cantino/mcfly https://github.com/cantino/mcfly ), based on this previous zsh-histdb discussion: https://news.ycombinator.com/item?id=15041772 https://news.ycombinator.com/item?id=15041772
- dmix 8y agoZSH seems to have broader community support and there's a plugin for basically everything. This is why I chose to stick with it over Fish. If I just wanted a very simple shell, with good defaults, I'd choose Fish. But much like why I use (Neo)Vim I prefer the DIY approach and have gotten my ZSH to the point over the years (and a hundred scripts later) where I love it. But ZSH the language is pretty awful and non-intuitive (although way better than bash when you dig into it). Even though I've been writing it for years I still get it mixed up often. My hope is that Evlish shell will be mature enough soon to use day-to-day, which is the only one I've seen with a modern scripting language (written in Go) and is 10x faster than my ZSH (which is very noticeable): https://elv.sh https://elv.sh
- dancek 8y agoSimilar story for me, but I consider the POSIX shell language a worthwhile least-common-denominator language. I avoid using bash or zsh extensions except interactively (and in a zsh plugin I maintain [0]). As I think you need to know the standard shell language anyway, new shell DSLs are a bit of a turn-off to me. If the language is trivial it's not very powerful and if it's powerful it takes time to learn. That's why I have high hopes for shells that combine tried-and-true programming languages and their ecosystems to a thin shell layer. Like http://xonsh.org http://xonsh.org or https://docs.racket-lang.org/rash/index.html https://docs.racket-lang.org/rash/index.html . But if I'm completely honest, I think bash will still be the standard choice in 5 years and weird shells you haven't heard of will still be weird shells you haven't heard of. [0]: https://gitlab.com/code-stats/code-stats-zsh https://gitlab.com/code-stats/code-stats-zsh
- santix 8y agoI was hoping to see that they added a `time` command, which is something that makes me change to bash every once in a while.
- scbrg 8y agoThere's an actual program, usually installed in /usr/bin/time. The shell builtin is not really necessary.
- kurtisc 8y agoThere's an outstanding issue in the github because the binary doesn't let you directly time fish functions. You can do time fish -c '[function]' but that includes the time to launch fish. This, of course, wouldn't matter for any reasonable usecase but I like a fancy prompt and don't like waiting for it to run.
- scbrg 8y agoAh, timing other shell functions is a use case I hadn't considered. Yes, then you're out of luck I suppose.
- beatgammit 8y agoI think $duration is a thing, which is the time it took to run the previous command. It doesn't separate things like time does, but it's still useful for some cases. In fact, I customized my prompt to pretty print the previous command's duration if it took longer than 3 seconds or something like that.
- avarun 8y agoI use the Spacefish prompt plugin[0], which does that as well, and comes with a whole lot of other goodness! [0] https://github.com/matchai/spacefish https://github.com/matchai/spacefish
- hartator 8y agoDoes anyone know how it compare to zsh with oh-my-zsh?
- orf 8y agoI much prefer fish to zsh + omz. Most of the functionality is built in, and there are plugins for any missing ones (nvm is a big one).
- jonaswouters 8y agoI never got nvm working for me, so after a few years on fish, I switched back to ZSH just for nvm. Any tips on how to get it working? I think it had to do bass not working though, so the plugin didn't work. Now that I'm on NixOS I might give it another shot.
- orf 8y agofisher add FabioAntunes/fish-nvm worked for me! https://github.com/FabioAntunes/fish-nvm https://github.com/FabioAntunes/fish-nvm
- nerdponx 8y agoZsh + OMZ is a slow, unconfigurable mess. If you are new to Zsh, avoid OMZ. If you are experienced with Zsh, you already know to avoid it. Fish "just works", and you won't have any lag. It is a delightful beginner experience, too. A Zsh veteran could probably replicate parts of the Fish experience in Zsh, but ultimately they are different tools. I use Fish at home for casual shell stuff, but I write shell scripts in Zsh, and I use Zsh at work whenever possible.
- h1d 8y agoI guess I try to switch to fish again as like you said zsh with 10 plugins takes so long to start a shell, like 5 seconds which feels forever when you want to start typing right then, that I now never quit the shell from remote machines but just disconnect from its tmux instance so I can go right back without initializing the shell every time I log in.
- anderspitman 8y agoSomething I've been thinking about this week as a vanilla bash user: Does Fish (or zsh, or others) have the ability to maintain some sort of a global command history? I often find myself wanting to run the same command in multiple terminals and currently just copy-paste.
- s09dfhks 8y agoIterm2 on osx supports sending the same inputs to multiple tabs
- Freaky 8y agozsh has a SHARE_HISTORY option: http://zsh.sourceforge.net/Doc/Release/Options.html http://zsh.sourceforge.net/Doc/Release/Options.html
- makecheck 8y agoNot part of a shell but in MacTerm the “command line” window has its own history and it can optionally send the text to all open windows.
- matthewn 8y agoThe sort of global history you want is possible with bash: https://news.ycombinator.com/item?id=3755276 https://news.ycombinator.com/item?id=3755276
- explainplease 8y agoIn fish you can use `history --merge` to merge the current shell's history with other instances of fish.
- hnarayanan 8y agozsh supports this natively (and is the primary reason I switched to it many years ago).
- milin 8y agoLet me know when it's posix compliant.
- j605 8y agoProbably never. Just use a shebang for scripts,they exist for a reason.
- kurtisc 8y agoAs soon as your bash scripts run with /bin/sh. You can still have bash installed and anything that requires significant scripting could probably be done easier with a language for scripting. I want my shell for my terminal. This is also the reason I don't like the verbosity of Powershell, however much an OOP paradigm better supports scripting.
- naniwaduni 8y agoYou can write scripts in the semantics-preserving common subset of POSIX sh and bash, which is not quite, but close to exactly POSIX sh. It's a widely-touted meme that scripting is more easily done in a general-purpose language than in a shell, but this is mostly true of the (common!) category of tasks which use the shell to launch sed &c. to perform string processing which is built-in in general-purpose languages. It's comparatively hard (i.e. verbose and error-prone) to replace a shell language with a general-purpose language in its core competence, viz. launching processes, muxing I/O, and coordinating parallel processing.
- djsumdog 8y agoI started using fish around 2013, back when it would occasionally crash and leave stack traces in the console. I'm really glad I stuck with it though. Fish has come a long way and it's totally an amazing shell. I really love all the functionality that's come out of the box and don't really mind learning new syntax if it means I can get away from old cruft.
- base698 8y agoFish still doesn't support !! or !command expansion. https://github.com/fish-shell/fish-shell/issues/288 https://github.com/fish-shell/fish-shell/issues/288
- davewongillies 8y agoThe bang-bang plugin handles !! and !$ https://github.com/oh-my-fish/plugin-bang-bang https://github.com/oh-my-fish/plugin-bang-bang
- darkpuma 8y agoStill no auto-escaping or quoting for pasted URLs, that's really disappointing. I respect fish's stated goals of user friedlieness, but I just don't think they've realized that goal in ways that other more mainstream shells have: > mpv https://www.youtube.com/watch?v=LBoF1e5YDdQ fish: No matches for wildcard 'https://www.youtube.com/watch?v=LBoF1e5YDdQ'. See `help expand`. mpv https://www.youtube.com/watch?v=LBoF1e5YDdQ ^ This, to me, is not user friendly. For reference, pasting the same URL into zsh with the often touted omz (incidentally I recommend you use antigen instead) auto-escapes the URL to > mpv https://www.youtube.com/watch\?v\=LBoF1e5YDdQ
- faho 8y agoWhat? That's been in for a few releases! To trigger it, enter a single-quote, then paste the URL, then close the quote once you're done. We don't attempt to detect URLs because that can go wrong, and because we don't know your intention. So we use the fact that you're inside single-quotes as the signifier that we should escape things - which also allows this to be used for e.g. pasting shellscript as a literal argument.
- ElijahLynn 8y agoI think the post is wanting it to be handled automatically, without having to quote it, that was the intent I got from it. But yeah, I have had a ton of issues where commands fail because I didn't quote URLs, and in the beginning it wasn't as obvious as it is now. I don't have a solution, just saying that this does add friction for newcomers.
- darkpuma 8y agoThere must be a disconnect here, manually entering a single quote, then pasting my URL, then adding the closing quote is precisely what I wish to avoid. Here is a demonstration about what I'm talking about: https://i.imgur.com/d64lwaB.mp4 https://i.imgur.com/d64lwaB.mp4 > "We don't attempt to detect URLs because that can go wrong, and because we don't know your intention." That much I've gathered from seeing this issue raised with fish people in the past, and in my humble opinion it's the wrong approach. In this mentality fish is forgetting it's stated goal of being user friendly which should in some cases, mean making sane educated guesses about the user's intent. How often do users of the fish shell paste a string that starts with 'http' and contains a '?' that is meant to be a wildcard? Not very often at all, if ever; fish is now evidently planning on deprecating that ? wildcard so I think the fish devs agree! The way I see it traditional shells aren't user friendly because they take a conservative approach, doing crap like not enabling fancy autocompletion features out of the box because "what if the user is running on a timesharing PDP-11 and can't spare the CPU cycles?" Breaking from that mental trap is bold and should be commended, but in the case of not escaping pastes I think fish has fallen into that conservative mindset again. zsh/OMZ does it by default and I've never heard of anybody getting screwed over because of it. Fish could and should do it by default too.
- ElijahLynn 8y agoMy favorite feature of fish is `abbr`, e.g. `fish abbr --add g git`. Then you type `g` followed by space and it just expands it to `g` and you then get all the autocomplete goodness and don't have to futz with adding autocomplete support to an alias, because it is the real command. It also helps for presentations because instead of some obscurely named alias, you can type an abbreviation and it just expands it out for the viewer to see and learn from. On top of that, I make abbreviations with long options, that way I can see exactly what is going on and effectively edit the commands.
- ludwigvan 8y agoNice, thank you. I have been using fish for a long time, but wasn't aware of these. Have defined the following: abbr -a gp 'git push' abbr -a k kubectl abbr -a n 'npm run' abbr -a y yarn abbr -a m make Now, when I type n, then SPACE, then TAB, I can get the list of npm tasks for example.
- floatboth 8y agozsh also does correct autocompletion for aliases, if you enable the counterintuitively-named 'no_complete_aliases' option
- modernerd 8y agoYou can also type fish_config to launch the fish config web app in your browser. From there you can add, edit and remove abbreviations from the “abbreviations” tab directly. I find this a really user-friendly way of managing abbreviations I've created.
- buchanae 8y agoAfter 15 years, I still struggle to test if a string is empty in shell languages. Do I use square brackets, double square brackets, equal sign, double equal sign, test -n, set -q, wtf mate? Do I need to wrap my string variable in double quotes? single quotes? Fish looks great, and I'm going to give it a try, but I ran into these same old shell scripting issues within 2 minutes of trying to configure my prompt, which is a bummer. Took me 10 minutes (I'm ashamed to say) to end up at `if test -n "$git_branch"` (double quotes are critical). I'll be excited when someone invents a shell that feels natural in this respect. Perhaps the nature of shells and commands makes this impossible? Or are we just stuck in a box?
- Groxx 8y agosometimes I wonder if "native" support for regexes would help this, or if it would just be another instance of https://xkcd.com/1171 https://xkcd.com/1171 regexes describe this sort of thing quite concisely and IMO a fair bit more readably than e.g. bash's string replacement syntax, which looks like "${var#"${var%%[![:space:]]*}"}" when you want to do the equivalent of s/^\s*(.*?)\s*$/\1/
- naniwaduni 8y agoIt wouldn't even be another standard; it'd just be another incompatible implementation with its own quirks to be worked around.
- Groxx 8y agoyeah, the wide variance in regex engines would definitely not be a positive quality :|
- duckerude 8y agoIt feels a bit more natural once you've bent your mind enough to understand what the shell is doing. The trick is that `test` and even `[` (which is essentially another name for `test`) are ordinary commands, that exist as stand-alone binaries as well as identical-behaving built-ins. They masquerade as syntax, but they're really not. You can even call them from other, non-shell languages: >>> from subprocess import run >>> run(('/usr/bin/[', '-n', '', ']')) CompletedProcess(args=('/usr/bin/[', '-n', '', ']'), returncode=1) >>> run(('/usr/bin/test', '3', '=', '3')) CompletedProcess(args=('/usr/bin/test', '3', '=', '3'), returncode=0) That means that they're not allowed to do anything to variables, because the variables are inside the shell. `test` doesn't see `"$git_branch"`, it only sees the content of the variable. Per the normal rules, `"$git_branch"` is an empty string iff $git_branch is empty or unset. Leaving the quotes off can do unexpected things, though a lot less so in fish. Using single quotes means you get a literal string, without any substitution. You're just looking for an empty string anyway, so you might as well use the equality operator instead of digging through the 18 (!) unary flags prescribed by POSIX. So I'd write either `[ "$git_branch" = "" ]` or `test "$git_branch" = ""`. Some implementations support `==` as another way to write `=`, but `=` is standard. This modularity makes the shell simpler, but it's not exactly sane. I think that providing `[` was a mistake, because it doesn't look like a command, but maybe having `test` as a command is better than having special expression syntax just for these cases.
- chrisweekly 8y agoCan anyone who's experienced with both fish and zsh comment on reasons fish might be better?
- ilaksh 8y agoFor me it's the out-of-the-box autocompletions just work really well. Not sure I had the ultimate zsh completions setup before but I did try and was not able to get anything near as good as fish. It's like fish can read your mind.
- h1d 8y agoShell scripting finally feels sane. Just the normal "if" and other basic conditionals make you feel you want to switch. Some scripting example : https://nicolas-van.github.io/programming-with-fish-shell https://nicolas-van.github.io/programming-with-fish-shell (I use zsh as shell, as enough customization can do much of what fish can achieve with bit more stability but maybe they fixed with 3.0 which I haven't tried yet.)
- posedge 8y agoThis is nice and everything, but I don't see why you would write fish scripts in the first place. For anything like that I'd use python, and imo the only reason to do POSIX shell scripting is that a compliant shell is probably preinstalled on your target platform.
- okdana 8y agofish doesn't try to support all of the weird historical quirks of Bourne-style shells, so its grammar and built-in 'API' are far simpler and clearer. Its out-of-the-box configuration is much much nicer for most people than zsh's. Completion definitions are easier to read/write. Its source code seems less byzantine. And its GitHub-based development model is more accessible. The down side is that it's functionally very limited compared to zsh. fish's completion functions are easy to maintain, but the trade-off is that they don't offer the fine-grained contextual control over behaviour that zsh's do. Features like globbing, sub-shells, job control, co-processes, modules, &c., are absent or extremely limited. There are fewer knobs and switches, though as mentioned it tries to do the right thing for most people by default. And a consequence of the syntax being clearer is that it's also much more verbose, which i guess you may or may not appreciate. Over-all i think fish is a good shell for the (very common) type of person who doesn't really care about shells but was drawn to zsh just because it has nicer completion than bash and lets you write fancy prompts. I don't think it's a good fit, yet, for people who write complex scripts or regularly make use of stuff like extended globs, background jobs, and fancy parameter expansions.
- Barrin92 8y agoI like fish's auto completion speed and smoothness but one thing that has held me back when I checked out fish was that there didn't seem to be a `Ctrl+r` command that bash and zsh provide to quickly go through history commands.
- robin_reala 8y agoYou start typing what you want, then hit the up arrow to fuzzy search back through history.
- AdamGibbins 8y agoIs this the only way? Arrow keys require I take my fingers off the home row, which is far from ideal with the frequency I search shell history.
- waterhouse 8y agoControl-P does it too, and is what I normally use. (Generally, I use control-{n,p,f,b} instead of arrow keys wherever possible. I also have caps lock mapped to control.)
- syntonym 8y agofzf [0] has a history mode included and integrates nicely with fish. You just need to enable the fzf bindings [1], then CTRL-r will give you a (fzf) history searcher. [0] https://wiki.archlinux.org/index.php/Fzf#fish https://wiki.archlinux.org/index.php/Fzf#fish [1] https://github.com/junegunn/fzf https://github.com/junegunn/fzf
- joshschreuder 8y agoIs there anything remotely like this on Windows? I use Cmder / Conemu now but it doesn't seem to have even 10% of the features of a fully fledged shell like this.
- faho 8y agocmder and conemu are terminals. They run shells, like bash or zsh, but also fish. I've not used it myself, but I know that fish is available in WSL and cygwin (though this release had some issues there).
- joshschreuder 8y agoYeah I realised after I posted that I was talking about terminals not shells but it's too late to edit my mistake away :) Interesting about it working on cygwin / WSL. Maybe I'll give that a go. I'm sure someone's also made Powershell enhancements that add similar functionality too.
- korm 8y agoOh-my-posh + a few custom scripts for better autocomplete that I found here and there. Wasn't very easy to configure and it's still nowhere near my fish shell, but at least it's much better than plain powershell.
- entelechy 8y agoCool stuff! Love the modest headline on http://fishshell.com/ http://fishshell.com/ > Finally, a commandline shell for the 90s It makes me wonder, how would a shell for 2020 look like?
- xkgt 8y agoHow do people manage scripts to be used in such niche shells? I started using zsh at work recently, while I quite enjoy the shell experience it is a pain to rewrite all bash scripts to zsh or add lines of codes for compatibility. Any pointers?
- mixmastamyk 8y agoYou don’t. ;-) Use fish/zsh interactively, sh for simple scripts, Python for the more complex.
- xkgt 8y agoYeah I get that. But this method doesn't help for scripts that need to modify the current session state (such as export session variables). I am guessing here that such scripts are an edge case and most shell scripts can be simply executed with sh.
- pseudalopex 8y agoMost scripts are run, not sourced. Some tools support fish. bass[1] aims to handle the rest. [1] https://github.com/edc/bass https://github.com/edc/bass
- TheAceOfHearts 8y agoCould you give a concrete example of a situation you have in mind? If I'm understanding you correctly, then one solution could be to create a small wrapper to exec bash, source your environment-modifying script, and then exec fish. Are you familiar with exec [0]? fish also has an exec command [1]. I've been using fish for years and it hasn't been an issue. You can keep bash installed for any hardcore scripting, and just fish as your interactive shell. [0] https://stackoverflow.com/a/38581329 https://stackoverflow.com/a/38581329 [1] https://fishshell.com/docs/current/commands.html#exec https://fishshell.com/docs/current/commands.html#exec