Started experimenting with #FishShell today, to replace my #zsh when outside of Emacs & Eshell.
-
Started experimenting with #FishShell today, to replace my #zsh when outside of Emacs & Eshell. Why? I dunno, mostly because fish has better defaults, and needs far less configuration.
So far, so good. I do have one issue, though: with zsh, I could do some horrible hacks to filter
direnv
output, to turn this:direnv: loading /persist/store/home/algernon/wip/src/ext/forgejo/.envrc
direnv: using flake
direnv: nix-direnv: Using cached dev shell
direnv: export +AR +AS +CC +CONFIG_SHELL +CXX +DETERMINISTIC_BUILD +GOPATH +GOTOOLCHAIN +HOST_PATH +IN_NIX_SHELL +LD +NIX_BINTOOLS +NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_BUILD_CORES +NIX_CC +NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_CFLAGS_COMPILE +NIX_ENFORCE_NO_NATIVE +NIX_HARDENING_ENABLE +NIX_LDFLAGS +NIX_STORE +NM +NODE_PATH +OBJCOPY +OBJDUMP +PYTHONHASHSEED +PYTHONNOUSERSITE +PYTHONPATH +RANLIB +READELF +SIZE +SOURCE_DATE_EPOCH +STRINGS +STRIP +_PYTHON_HOST_PLATFORM +_PYTHON_SYSCONFIGDATA_NAME +__structuredAttrs +buildInputs +buildPhase +builder +cmakeFlags +configureFlags +depsBuildBuild +depsBuildBuildPropagated +depsBuildTarget +depsBuildTargetPropagated +depsHostHost +depsHostHostPropagated +depsTargetTarget +depsTargetTargetPropagated +doCheck +doInstallCheck +dontAddDisableDepTrack +mesonFlags +name +nativeBuildInputs +out +outputs +patches +phases +preferLocalBuild +propagatedBuildInputs +propagatedNativeBuildInputs +shell +shellHook +stdenv +strictDeps +system ~PATH ~XDG_DATA_DIRSinto this:
direnv: loading /persist/store/home/algernon/wip/src/ext/forgejo/.envrc
direnv: using flake
direnv: nix-direnv: Using cached dev shellI'm having trouble figuring out how to do the same with fish.
Also: I have
cd
aliased toz
(fromzoxide
) in both shells. With zsh, if I typecd f
, it will offercd forgejo/forgejo
for autocompletion, fish does not, even though both saved a previouscd forgejo/forgejo
into history.I like a lot of things about fish, and I got to a reasonable configuration that looks a lot like what I'm used to within minutes, in like 10 lines. But there are some small annoyances like the two above that make it very hard to justify switching from zsh.
-
Himbo In Disguisereplied to Gergely Nagy 🐁 last edited by
@algernon Direnv apparently now has
hide_env_diff = true
in direnv.toml to remove that.Otherwise you'd have to rewrite the hook stuff -
direnv hook fish
,functions --handlers
andfunced
are your friends.As for z, I know the z plugin does some trickery to set up completions for whatever you've called your z command.
-
Gergely Nagy 🐁replied to Himbo In Disguise last edited by
@bean oooh! I will need to update my direnv! My version doesn't have that yet.
Will also check z (was on my todo list anyway, now it got bumped higher), to see if it behaves better than zoxide. I suppose, it being pure fish, it just might.
Thanks! (For fish, too!)
-
Himbo In Disguisereplied to Gergely Nagy 🐁 last edited by
@algernon (note there's some weirdness with overriding "cd" specifically because fish actually has its own wrapper function that adds the directory history etc - it's on my docket to remove that and add it to the builtin proper)
-
Gergely Nagy 🐁replied to Himbo In Disguise last edited by
@bean yeah, noticed. Zoxide makes a copy, and uses the copy internally, so a later alias works.
-
Gergely Nagy 🐁replied to Gergely Nagy 🐁 last edited by
Progress!
Thanks to @bean,
direnv
is sorted! I also havecd
aliased tozoxide
, and it works.However,
cd f
does not offer an autosuggestion at all, even thoughcd forgejo/forgejo
works, and has been used in that fish session too.In this case, I think a video shows my problem better than I can explain:
https://asciinema.org/a/N2ckKLEnvf9ep5yHfyadfpQzAShown therein is how my
cd
works in zsh, and how it does in fish. I want that auto-suggestion in fish, too. The same way it auto-suggests~/src/ext/forgejo/forgejo
, I'd like it to auto-suggestforgejo/forgejo
too, if it's in the history (it is, though that's not shown in the video, and I cba to record it again). -
Gergely Nagy 🐁replied to Gergely Nagy 🐁 last edited by
I might not switch to #FishShell myself (
cd
not auto-suggesting the way I'm used to is a Big Deal), but it will be a perfect shell on Wife's laptop.She's never going to drop into shell herself, but I will, and a stock fish shell will do just fine! Saves me from having to deploy my zsh configuration to her laptop too.
It is also very likely that I will set it as the default shell for the twins, when they get their own computers in a few years time. They likely won't use the shell much either, but if they do, I want them to have something that is friendly out of the box.
-
@algernon
```
zoxide init --cmd cd fish | source
```
zoxide is a phenomenal `cd` modifier. It remembers your most used directories and can fuzzy match them. -
@Brahn Yeah, I'm using that. It makes
cd blah
work, but it does not makecd b
auto-suggestcd blah
. When usingz blah
,z b
will auto-suggestz blah
- I want the same forcd
.cd b<TAB>
does not tab-complete tocd blah
either (I can live with that, I want the auto-suggest, the tab completion is unnecessary).See the zsh & fish comparison video here: https://asciinema.org/a/N2ckKLEnvf9ep5yHfyadfpQzA
-
Gergely Nagy 🐁replied to Gergely Nagy 🐁 last edited by
HAH!
I found the culprit! Fish treats
cd
specially when validating autosuggests, even if I overrode the stockcd
function.I can patch this.
Should I? I dunno. Probably not. But now that I found it, I will. Might even turn it into a settable option and submit it upstream or something.
But I'll check if there's an existing PR or issue about this.
-
@algernon ooh... you want zoxide autocomplete... now I want that.
-
-
@algernon ha! it works!
```
function __zoxide_cd_complete
set -l query (commandline --current-token)
if test -n "$query"
set -l matches (zoxide query --list -- $query)
for match in $matches
echo "$match"
end
end
end# Use zoxide query for cd completions
complete -c cd -f -a '(__zoxide_cd_complete)'
``` -
Gergely Nagy 🐁replied to Gergely Nagy 🐁 last edited by
I did the thing, I patched fish to stop it from special-casing
cd
when validating auto-suggests from history.The raw patch (against 3.7.1, because that is what's in NixOS 24.05) is here.
And with this, it looks like #FishShell will be able to replace #zsh for me too, not just for the rest of the family. I will be experimenting with it for a few more days though, before I commit to it.
-
@algernon If you just wanna get rid of the long direnv output:
```
λ cat ~/.config/direnv/direnv.toml
[global]
hide_env_diff = true
```(needs a recent direnv from this year or so)
-
@jankatins Yep! Was told about that earlier, and am using it now
-
Matija Šukljereplied to Gergely Nagy 🐁 last edited by
@algernon, the only major issue I still have with #FishShell is the lack of alphabet globbing.
Here's the relevant issue and my current workaround:
https://github.com/fish-shell/fish-shell/issues/3681#issuecomment-2341736648 -
Gergely Nagy 🐁replied to Matija Šuklje last edited by
@hook Luckily, I'm not affected. I'm not doing anything serious in neither fish or zsh. Any file renamings or complicated operations are done in Eshell, fish/zsh is only used for some light interactive purposes, where doing it from Emacs would be inconvenient for one reason or another.