It's also compatible-enough with POSIX for most purposes, and supported as an alternative for lots of software (venv comes to mind).
It's also compatible-enough with POSIX for most purposes, and supported as an alternative for lots of software (venv comes to mind).
I agree that fish is a sweet middle ground spot.
The thing is, when I picked up fish, I couldn't forget my existing bash knowledge. I still have to write normal bash-dialect shell scripts, and with the fish syntax being so much nicer and simpler, the two can happily co-exist in my head. Occasionally I'll hit Up to search through history instead of Control-R, but I quickly realise what I've done and use the bash keybinding instead. And the only fish aliases I missed were 'l', 'll', and 'la', which I just manually copied over without bothering with the rest.
If I had to use bash more often at work... I'd still use fish at home after all the time I've sunk into it, but YMMV.
So Oil is almost indistinguishable from bash at first, but you can unlock more powerful functionality with the var and proc keywords, etc.
This page has the old sh and new Oil idioms, but importantly Oil runs all the old stuff!
Does oil allow a gradual upgrade path to using oil semantics for stuff like “echo $dontbreak”? Are there “set” options that enable oil semantics? Sort of like “use strict” in JavaScript and perl
http://www.oilshell.org/blog/2021/01/why-a-new-shell.html#ho...
I need to document things a bit better but the idea is here: https://lobste.rs/s/ritbgc/what_glue_lanugages_do_you_use_li...
In the case of echo, we respect -e and -n, but we also have "write -- -n" for correctness. I try not to "stomp" on existing names.
---
And yes there's an analogy to Perl: http://www.oilshell.org/blog/2020/07/blog-roadmap.html#the-u...
Getting "good at bash" is a game with diminishing returns.
It's so random and non-orthogonal (bash itself, and the flags of common UNIX cli utils) as a scripting language, that you always end up having to look this or that, and with crazy corner cases you've missed.
I switch to bash about once/month:
* for/while loops with a lot of logic that I don't feel would be worth translating to fish
* dealing with obscure/strange other things that again wouldn't be worth the time to translate to fish
ultimately, I feel that I get such benefit out of fish that the occasional switch to bash is worth the pain.
The most common tripping points are the minor adjustments in syntax, probably the biggest one being command substitution:
Bash:
$ echo “$(ls -al)”
Fish: $ echo (ls -al)
You get used to it though.Another thing many bash-ers sometimes miss is the !! substitution, e.g.
$ apt update
# permission denied
$ sudo !!
This doesn’t work in fish, BUT fish does offer a handy keybinding out of the box to prepend ‘sudo’ to your current command line (submitted by yours truly). So when using fish, you’d handle the above scenario like this: $ apt update
# permission denied
# press Up or Ctrl-P followed by Alt-s
$ sudo apt update
There are so many other great things I love about fish, but this comment is already long enough.Be sure to read (or at least scan) through the user guide on their website. It’s an easy read and not dense. You can also view it at any time by running `help` from inside fish.
I can’t recommend fish highly enough, I’m excited for your journey :)
function bind_bang
switch (commandline -t)[-1]
case "!"
commandline -t $history[1]; commandline -f repaint
case "*"
commandline -i !
end
end
function bind_dollar
switch (commandline -t)[-1]
case "!"
commandline -t ""
commandline -f history-token-search-backward
case "*"
commandline -i '$'
end
end
function fish_user_key_bindings
bind ! bind_bang
bind '$' bind_dollar
end for f in (ls -1 *py); echo $f; end
One more thing to note is setting ENV var FOO to value bar is set -x FOO bar
Note no equal sign. To delete an ENV var use `set -e FOO`.If you want to set ENV vars permanently for your login shell, the file to edit is `~/.config/fish/config.fish` and the syntax is:
set -gx PATH $PATH /some/new/path
which means set var PATH to whatever PATH contained before with /some/new/path appended to it.So I spent a day migrating my fish config to zsh, and am much happier now.
Regarding a bare shell: perhaps I’m not understanding your exact needs, but fish is able to check whether or not it’s being used interactively with `status is-interactive`, so you could certainly try wrapping all of the plug-in loading machinery around a guard like this.
[1]: https://git.sr.ht/~gpanders/dotfiles/tree/master/item/.confi...
$ exec bash -c ‘source script.sh; exec fish’
This has some caveats and won’t work in all cases (both bass and replay.fish go into more detail), but this is what I use and it hasn’t failed me yet.Edited to add: A suggestion is a complete command line based on the history. Completion looks at the disk for file names and the like, and only talks about the current "word".
If the '→' key is too far away from the home row for your liking, you can use Control-E instead, as long as you're at the end of the input buffer (it's the "go-to-end-of-buffer" command normally)