-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce add-ons #37
base: main
Are you sure you want to change the base?
Conversation
I ended up taking this for a spin, as it would allow me to move a lot of my out of tree customizations out of Hydro and into my own dotfiles. The only issue I have noticed is that the addons do not work until I move into a |
Yep, should be fixed now! 💯 |
Thanks, looks good to me! |
|
||
set --query _hydro_skip_git_prompt && set $_hydro_git && return | ||
command kill $_hydro_last_pid 2>/dev/null | ||
|
||
fish --private --command " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we are defining the prompt in private mode, it doesn't appear possible to conditionally display a character in the prompt if we are in private mode. Could we introduce an additional global variable (something like is_fish_private_mode
) that gets set just before we enter private mode in the code above? Then we can have the following addon in the prompt:
set --global hydro_prompt_addons private
function _hydro_addon_private
if test "$is_fish_private_mode" = 1
echo [p]
end
end
The above would result in the prompt:
/home/johnsmith/abc > fish -P
/home/johnsmith/abc [p] >
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may not even need --private
mode to be honest! 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to change anything in Hydro to handle this particular addon example. In your config.fish
, you can just check that the shell is interactive so that subshells that run your config (like those Hydro creates) don't nuke your flag. This code will do what you want with the current implementation:
# config.fish
status --is-interactive && set --export is_fish_private_mode $fish_private_mode
function _hydro_addon_private
if test "$is_fish_private_mode" = 1
echo [p]
end
end
set --global hydro_prompt_addons private
I like having Hydro use --private
so it doesn't clutter your fish history with all the non-user git
commands it fires off, but that's not a huge deal either way. But, if this is work-around is acceptable, we can leave --private
in and everyone wins.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I concur!
Would it be possible to turn the existing components to pre-built addons? I would like to display the git branch conditionally. I'm using git worktree and the directory is named after the git branch so it's kinda redundant there. This feature is awesome nonetheless. Thank you so much for making it. |
Having this system merged would be fantastic: I want to create an add-on for myself that displays the host name if any of the Edit: I tested this branch out as well, and it works perfectly for what I want to accomplish: function _hydro_addon_ssh
if test -n "$SSH_CLIENT"
echo (set_color yellow)🌐:(hostname)(set_color normal)
end
end
set -g hydro_prompt_addons ssh |
I think that having this would be fantastic too, but the code required to implement this was non-trivial and my implementation is not great either. The more of these little addons you create the slower your terminal gets. |
While I love the idea of these, I was also concerned about how they could slow down the terminal. |
This runs addons inside a subshell, which is better than nothing, but we'd really want to run each addon in its own subshell. |
Addons let you add new components to your Hydro prompt. They're not as flexible as Tide items (and don't intend to be). My goal is not to reinvent Tide, but still allow a degree of configuration not possible right now. For example, maybe I'd want to display the current Node version using nvm.
Creating an addon is easy:
Then in
config.fish
:Closes #34 #35 #36