jorgebucaran / hydro Goto Github PK
View Code? Open in Web Editor NEWUltra-pure, lag-free prompt with async Git status—just for Fish
License: MIT License
Ultra-pure, lag-free prompt with async Git status—just for Fish
License: MIT License
I'm using fish 3.1.2 and fisher 4.1.0. When I install the prompt using Hydro it works as expected, but when I open a new terminal or tab, the prompt disappears completely. I have to reinstall the prompt for it to appear again.
Even though Hydro is much faster than Tide at rendering the prompt, like advertised (measured using time fish_prompt
)
Hydro:
Executed in 172,00 micros fish external
usr time 159,00 micros 159,00 micros 0,00 micros
sys time 15,00 micros 15,00 micros 0,00 micro
Tide:
Executed in 2,06 millis fish external
usr time 2,04 millis 2,04 millis 0,00 micros
sys time 0,01 millis 0,01 millis 0,00 micros
It comes with the downside that it slowdown the launch (or perhaps the shutdown?) of Fish by roughly 8-10ms (mesured using hyperfine with the command fish -i -c "exit"
) on my machine:
Hydro:
Benchmark #1: fish -i -c "exit"
Time (mean ± σ): 24.7 ms ± 1.4 ms [User: 20.1 ms, System: 6.0 ms]
Range (min … max): 20.1 ms … 30.3 ms 102 runs
Tide:
Benchmark #1: fish -i -c "exit"
Time (mean ± σ): 16.7 ms ± 1.1 ms [User: 14.1 ms, System: 3.5 ms]
Range (min … max): 11.8 ms … 18.6 ms 146 runs
This is with the default settings on Hydro and the Pure preset on Tide with few icons. I can reproduce those results by uninstalling / reinstalling both prompts. My config.fish
file is available here if needed
I've recently started to use hydro
and I'm really enjoying it! One thing that is bothering me is the fact that there is a background on some vi modes, namely insert
and normal
:
I checked my config, but I couldn't find anything strange.
set -gx PNPM_HOME "$HOME/Library/pnpm"
# hydro
set -g hydro_multiline true
set -g fish_prompt_pwd_dir_length 0
fish_add_path /opt/homebrew/bin
fish_add_path PNPM_HOME
if status is-interactive
set fish_greeting "🌸"
fish_vi_key_bindings
end
Environment details:
fisher update
few minutes agoThe elapsed time portion if my prompt includes the entire path to pwd
plus a couple of directories:
config.fish
# ~/.config/fish/config.fish: DO NOT EDIT -- this file has been generated
# automatically by home-manager.
# Only execute this file once per shell.
set -q __fish_home_manager_config_sourced; and exit
set -g __fish_home_manager_config_sourced 1
source /nix/store/jvdphk4ax16yxzj2b8hcpm2j8k1waf7l-hm-session-vars.fish
fish_config theme choose "Catppuccin Mocha"
eval (/nix/store/php4qidg2bxzmm79vpri025bqi0fa889-coreutils-9.5/bin/dircolors -c ~/.dir_colors)
status is-login; and begin
# Login shell initialisation
end
status is-interactive; and begin
# Interactive shell initialisation
/nix/store/0qygwgixvg42d5lhfkj18b1zvclmcvc4-fzf-0.52.1/bin/fzf --fish | source
set fish_greeting # Disable greeting
set hydro_color_pwd $fish_color_cwd
set hydro_color_git $fish_color_host
set hydro_color_prompt $fish_color_host_remote
if set -q KITTY_INSTALLATION_DIR
set --global KITTY_SHELL_INTEGRATION no-rc
source "$KITTY_INSTALLATION_DIR/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish"
set --prepend fish_complete_path "$KITTY_INSTALLATION_DIR/shell-integration/fish/vendor_completions.d"
end
# add completions generated by Home Manager to $fish_complete_path
begin
set -l joined (string join " " $fish_complete_path)
set -l prev_joined (string replace --regex "[^\s]*generated_completions.*" "" $joined)
set -l post_joined (string replace $prev_joined "" $joined)
set -l prev (string split " " (string trim $prev_joined))
set -l post (string split " " (string trim $post_joined))
set fish_complete_path $prev "/home/walawren/.local/share/fish/home-manager_generated_completions" $post
end
/nix/store/35klgzald67mkslqb9kkv01gn98zfbza-direnv-2.34.0/bin/direnv hook fish | source
end
plugin-hydro.fish
# Plugin hydro
set -l plugin_dir /nix/store/h44v3fqpf2pcrqjqmrr8y3dj6xqd699f-source
# Set paths to import plugin components
if test -d $plugin_dir/functions
set fish_function_path $fish_function_path[1] $plugin_dir/functions $fish_function_path[2..-1]
end
if test -d $plugin_dir/completions
set fish_complete_path $fish_complete_path[1] $plugin_dir/completions $fish_complete_path[2..-1]
end
# Source initialization code if it exists.
if test -d $plugin_dir/conf.d
for f in $plugin_dir/conf.d/*.fish
source $f
end
end
if test -f $plugin_dir/key_bindings.fish
source $plugin_dir/key_bindings.fish
end
if test -f $plugin_dir/init.fish
source $plugin_dir/init.fish
end
I've just installed this and it's great! I'd love to see the prompt detect if it's in a remote session, and if so display prominently display the hostname.
The branch name does not appear upon cd
into the repo, but on subsequent commands.
~ ❱ git clone https://github.com/jorgebucaran/hydro.git
Cloning into 'hydro'...
remote: Enumerating objects: 403, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 403 (delta 0), reused 1 (delta 0), pack-reused 400
Receiving objects: 100% (403/403), 108.71 KiB | 283.00 KiB/s, done.
Resolving deltas: 100% (199/199), done.
~ 1.5s ❱ cd hydro/
~/hydro ❱ fish -v
fish, version 3.1.0
~/hydro main ❱ fisher list
jorgebucaran/fisher
jethrokuan/z
jethrokuan/fzf
jorgebucaran/hydro
~/hydro main ❱
@jorgebucaran - Are you open to a PR that would introduce two new variables into the prompt: a pre-prompt and a post-prompt like so...
set --query hydro_pre_prompt || set --global hydro_pre_prompt ""
set --query hydro_post_prompt || set --global hydro_post_prompt " "
The intent of the hydro_pre/post_prompt
variables would be to allow users some to way to customize their prompt without having Hydro have to directly support all the customizations a user might dream up. For example, I like a more spacious prompt similar to Zsh's Pure, so I could get that by setting the pre-prompt variable to a new line in my config like so: set --global hydro_pre_prompt "\n"
.
Theoretically, with these variables a user could do whatever they wanted like adding a low battery indicator 🔋, or a python symbol 🐍 when they're in a python venv, or whatever - all without having to modify hydro itself. I'm open to other ideas on an implementation - just thought this would be a real simple change that would give the user more power in customizing their Hydro prompt.
The only change to Hydro in the PR to implement this would be adding those variables and then changing the fish_prompt
function:
function fish_prompt
echo -e "$hydro_pre_prompt...all-the-other-vars...$hydro_post_prompt"
end
After latest updates I have funky problems with various apps and job control (when using fg builtin). I have a habit of suspending vim, running something in terminal, and returning back with fg. It took a while to notice that vim was "crashing". Some quick testing suggests it happens with other applications, so it's not vim's fault.
> touch empty_file.txt
> less empty_file.txt
CTRL + Z from less
fish: Job 1, 'less empty_file.txt' has stopped
> fg
Send job 1, “less empty_file.txt” to foreground
CTRL + Z from less
fish: Job 1, 'less empty_file.txt has stopped
Program is killed by shell after the second suspend...
When I remove hydro plugin the problem doesn't show up anymore.
My plugin list is:
That's maybe too specific but I have a directory structure somewhat like this
~/projects ❱ tree -L 2
.
├── project_a
│ ├── dev_project_a
│ ├── prd_project_a
│ ├── project_a
│ └── stg_project_a
└── project_b
├── dev_project_b
├── prd_project_b
├── project_b
└── stg_project_b
Where all of these leaves are git repos. The thing is, when I get into ~/projects/project_a/project_a
, the prompt is shown like this
~/p/project_a/project_a master ❱
And when I I get into ~/projects/project_a/project_a/src
it goes like that
~/p/project_a/p/src master ❱
I've made a small patch to fix it
24c24
< string replace -- "/$git_base/" /:/ |
---
> string replace --regex -- "/($git_base)(?!.*\1)/" "/:/" |
Hydro extends the prompt with the full path of the last command that failed (exit code != 0). This path is for NixOS users very long (a path like /nix/store/p4i6hi976q7csprsb35d4wx797wzpri2-lorri-keep-env-hack-nix-shell) and I personally would like to hide the full path. Instead it would be enough to display the name of last command or hide it completly. Is there any option to configure this, or is a change required to implement this?
replace
mode, which is presented in Fish's default mode prompt, is this intended?ǀ
doesn't look good with JetBrains Mono on kitty, can this be changed to standard |
or made configurable?Sometimes when closing terminal with CTRL-D there is error message
There are still jobs active:
PID Command
2235785 fish --private --command "
! command git --no-optional-locks rev-parse 2>/dev/null && set $_hydro_git && exit
set branch (
command git symbolic-ref --short HEAD 2>/dev/null ||
command git describe --tags --exact-match HEAD 2>/dev/null ||
command git rev-parse --short HEAD 2>/dev/null |
string replace --regex -- '(.+)' '@\$1'
)
test -z \"\$$_hydro_git\" && set --universal $_hydro_git \"\$branch \"
! command git diff-index --quiet HEAD 2>/dev/null ||
count (command git ls-files --others --exclude-standard) >/dev/null &&
set info \"$hydro_symbol_git_dirty\"
for fetch in $hydro_fetch false
command git rev-list --count --left-right @{upstream}...@ 2>/dev/null |
read behind ahead
switch \"\$behind \$ahead\"
case \" \" \"0 0\"
case \"0 *\"
set upstream \" $hydro_symbol_git_ahead\$ahead\"
case \"* 0\"
set upstream \" $hydro_symbol_git_behind\$behind\"
case \*
set upstream \" $hydro_symbol_git_ahead\$ahead $hydro_symbol_git_behind\$behind\"
end
set --universal $_hydro_git \"\$branch\$info\$upstream \"
test \$fetch = true && command git fetch --no-tags 2>/dev/null
end
" &
A second attempt to exit will terminate them.
Use 'disown PID' to remove jobs from the list without terminating them.
Pressing CTRL-D again allows to close the terminal.
It's quite rare and I can't reproduce it on demand.
It seems like if I try to use an abbreviation too soon after a prompt is initially painted, abbreviations aren't available. If I wait a few moments, presumably after the async bit is resolved, abbreviations work as expected again. Does this sound plausible?
How did you achieve that only the current folder and the git root are colored? Those two get rendered bold, but everything has color.
It would be nice if this prompt automatically displays Nixos relevant environments like described here in "Show that you are in a nix-shell".
Also great fish prompt!
I often find myself exiting a shell while hydro is still fetching something in the background, and I get the following error:
There are still jobs active:
PID Command
91631 fish --private --command "
! command git --no-optional-locks rev-parse 2>/dev/null && set $_hydro_git && exit
set branch (
command git symbolic-ref --short HEAD 2>/dev/null ||
command git describe --tags --exact-match HEAD 2>/dev/null ||
command git rev-parse --short HEAD 2>/dev/null |
string replace --regex -- '(.+)' '@\$1'
)
test -z \"\$$_hydro_git\" && set --universal $_hydro_git \"\$branch \"
! command git diff-index --quiet HEAD 2>/dev/null ||
count (command git ls-files --others --exclude-standard) >/dev/null &&
set info \"$hydro_symbol_git_dirty\"
for fetch in $hydro_fetch false
command git rev-list --count --left-right @{upstream}...@ 2>/dev/null |
read behind ahead
switch \"\$behind \$ahead\"
case \" \" \"0 0\"
case \"0 *\"
set upstream \" $hydro_symbol_git_ahead\$ahead\"
case \"* 0\"
set upstream \" $hydro_symbol_git_behind\$behind\"
case \*
set upstream \" $hydro_symbol_git_ahead\$ahead $hydro_symbol_git_behind\$behind\"
end
set --universal $_hydro_git \"\$branch\$info\$upstream \"
test \$fetch = true && command git fetch --no-tags 2>/dev/null
end
" &
A second attempt to exit will terminate them.
Use 'disown PID' to remove jobs from the list without terminating them.
When I'm in a Git repository and I prevd-or-backward-word
out of it with Alt+←, the branch name still lingers on the prompt.
Reproducible in this container https://github.com/dideler/docker-fish-shell
~ ❱ fish --version
fish, version 3.2.2
~ ❱ fisher --version
fisher, version 4.4.2
~ ❱ fisher list
jorgebucaran/fisher
jorgebucaran/hydro
~ ❱ cd /tmp/src/jorgebucaran/hydro/
/t/s/j/hydro main ❱ # Press ALT-<left arrow> to run prevd-or-backward-word
~ main ❱ # This actually replaces the previous line
Also happens with Fish 3.5.1 on my actual system. Hydro version d4c107a.
I am getting this error whenever I enter a git directory using the hydro shell:
error: process ID out of range
Usage:
ps [options]
Try 'ps --help <simple|list|output|threads|misc|all>'
or 'ps --help <s|l|o|t|m|a>'
for additional help text.
For more details see ps(1).
Sorry if this is unrelated, but I like how Hydro looks combined with them.
It would be nice to have some "blank" variables which can be used to add user-defined functionality.
You can always add your functionality like this:
functions --copy fish_prompt fish_prompt_origin
function fish_prompt
echo -n \n"$os_icon "
fish_prompt_origin
end
in your config.fish
But what if you want to add git branch icon?
You can edit fish_prompt.fish or row 95 in hydro.fish, but it would be much better to just use specific variable for it.
I think following variables would be useful:
hydro_prompt_prefix
hydro_prompt_suffix
hydro_pwd_prefix
hydro_pwd_suffix
hydro_git_prefix
hydro_git_suffix
hydro_duration_prefix
hydro_duration_suffix
Or maybe prefixes only are enough.
It can use existing colors for simplification.
E.g. hydro_pwd_prefix could be colored by hydro_color_pwd.
It can be used to add icons or additional user-defined functionality.
Slightly off-topic 🙂
Since github.com/fishpkg/fish-prompt-mono redirects here: do you happen to have a copy of github.com/fishpkg/fish-prompt-mono repository laying somewhere? Could you send it to me or upload somewhere? Thanks :)
Hey. Looks awesome.
Can stash indicator be added?
Some prompts just show it's something in git stash and some shows how many stashes created.
This is how it was done in Pure https://github.com/pure-fish/pure/pull/239/files
Just noticed this, thanks to the "Sid Meier's Civilization VI" folder:
~ ❱ mkdir "a'b"
~ ❱ cd a\'b/
~/ab\x1b[0m \x1b[0m\x1b[0m❱\x1b[0m
Great theme, the asynchronous git status is a godsend.
See title! Would really love this. I have a little workaround by adding \n
to the symbol, but this breaks sometimes with error messages etc.
Hi - I noticed that my config.fish
was being sourced every time I hit enter and PWD was a git repo. This can slow down one's prompt. I believe the below line is missing a -N
to suppress config loading.
Line 68 in d4c107a
The default fish prompt has a variable fish_prompt_pwd_dir_length
which tells if and how much to shorten directory names when printing pwd in the prompt, while hydro seems to always shorten directories to 1 character.
Would you consider implementing this functionality in hydro?
BTW: it may even be possible to just use the default pompt_pwd
function from inside hydro (see https://fishshell.com/docs/current/cmds/prompt_pwd.html and/or functions prompt_pwd
)
On my Mac I use a tool called Secretive for managing my SSH keys. It notifies me when an application attempts to use the SSH keys it stores and I can choose to either permit the application to use the key or not. When using Hydro in a repository where I have the remote set to an SSH source, Hydro continuously attempts to authenticate against the remote repository and so I continuously get notifications that something is attempting to use my SSH keys whenever I cd
into a local repository where the remote is an SSH source. It's super annoying. But also, I would rather that my shell prompt not connect to my private SSH repositories in the background all the time.
I fixed the issue by removing all references to the _hydro_git_info
function in conf.d/hydro.fish
. So something in the _hydro_git_info
function is causing the issue. I don't really care what because I don't really need the extra git
tracking.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.