3 ms·
Setting a specific path as an “autoload” path to load shell functions is in bash and zsh too?
by krinchan 5y ago
Setting a specific path as an “autoload” path to load shell functions is in bash and zsh too?
- laumars 5y agoYeah, but there aren’t magic function paths that you need to do basic things like setting the prompt. Don’t get me wrong, I think the PS1 variable sucks. But I’m not convinced Fish’s solution is much better.
- krinchan 5y agoOkay so I think I understand your objection a bit more. So fish only wants you to define a function called fish_prompt in order to customize the prompt. That function can be defined however you want. It can be in fish’s equivalent of .bashrc (~/.config/fish/config.fish). Putting it in ~/.config/fish/functions/fish_prompt.fish is just leveraging more tooling around shell function autoloading and sane defaults. You can achieve PS1-like functionality “simply” by placing this bit of code somewhere in your startup: function fish_prompt set -l prompt_symbol '$' fish_is_root_user; and set prompt_symbol '#' echo -s $hostname (set_color blue) (prompt_pwd) \ (set_color yellow) $prompt_symbol (set_color normal) end It’s very verbose but it runs as fast as both bash’s PS1 and zsh’s PROMPT and is much easier for someone new to fussing with prompts to comprehend. Even as someone who doesn’t use fish day to day, I think fish’s prompt customization is much more approachable. If I had a powerline prompt I wanted to tweak, I’d know to start with `functions fish_prompt` to print out the current contents of the function and have the complete code to how the prompt is built. zsh requires a lot more reading and understanding of the prompt system before you can dig into how exactly it all works. IIRC, most dynamic bash prompts have similar issues. PS1 is just interpolated globals and color codes, creating a disconnect between the prompt variable and the shell functions that update it.