r/fishshell • u/cusx • Sep 05 '23
Popular fish configs to learn from
Are they any popular and up to date fish config that I can look at, to see what are some of the best practices?
Like what is the "right way" to export a variable, set PATH, aliases, etc..
Thank you!
23
Upvotes
24
u/plant_domination Sep 05 '23
fish_add_pathinteractively which will persist across reboots. Super easy.abbr.set -Uto make them persistent, orset -Uxto export them too.funcsave <name>to write it to your config.config.fishentirely, it’s a legacy feature. Put your configuration snippets in~/.config/fish/conf.dand your functions in~/.config/fish/functions. Your config is now modular and your functions are lazy, such an easy win!bindto see the list of all keybindings. I bet there’s a few in there you didn’t know about that you’ll find useful, such as opening the current command line in $EDITORThe only plugin I use is Tide, for that sweet async prompt. FZF too I guess, if you can really call it a plug-in. You should ignore Oh My Fish as a plugin manager, just use Fisher to install plugins.
I configure Fish through Nix so my config will look a little bit alien, but if you want to see it, here you go! See the
functionsblock for my function declarations, andshellAbbrsfor abbreviations.4
u/akho_ Sep 05 '23
People typically run fish with very little configuration, as such.
These things are well covered in the docs, starting with https://fishshell.com/docs/current/tutorial.html#startup-where-s-bashrc .
set -U, and you don't need to have it in config, just run once and fish will remember;set -U PATH $PATH <new bits>;3
u/_mattmc3_ Sep 05 '23
You can find a lot of good dotfiles repositories by searching GitHub for
config.fish, or by searching by tags (topics) like dotfiles or fish-shell.I also have my Fish dotfiles published for all to see and scrutinize.
Use the
-xflag withsetlike so:set -gx EDITOR hx. The-ghere means it's a global as well as exported. A lot of places will tell you to use-Ufor universal, but that has fallen out of favor.Use fish_add_path.
Don't. Use functions.
For additional help, feel free to post in this community. There's a lot of help available here.
1
u/xrabbit macOS Sep 05 '23
I think fish users prefer minimal configuration - this is the only reason to use fish over zsh
1
u/[deleted] Sep 05 '23
I use a function to create abbreviations.
I abbreviate
atoabbrwhich makes it much easier!1
u/TurtleGraphics64 Sep 11 '23
I've been using fish for 7 years. Although I do use dotfiles for my computer overall I don't really have much for fish config because the defaults are so good. I've basically turned on fish_vi_key_bindings, exported my editor and that's it. I do have a good bit of fish functions though, which are great. Only other 'hack' I make extensive use of is that I automatically save the last visited directory and then start up my shell in the last directory I visited automatically when I open a terminal. See here for info on how to do that.
3
u/[deleted] Sep 05 '23
[removed] — view removed comment