jorgebucaran/hydro

Hide full path of last command with exit code != 0

bwolf opened this issue · 9 comments

bwolf commented

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?

Hydro only shows the exit status AFAIC. Can you share a screenshot?

~/C/hydro main ❱ foo
fish: Unknown command: foo
~/C/hydro main [127] 
bwolf commented

Example with fish shell 3.2.2 and Hydro a5877e9ef76b3e915c06143630bffc5ddeaba2a1 which is the commit from 2021-05-15:

~/s/p/p/project master ❱ mvn clean test
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.892 s
[INFO] Finished at: 2021-11-01T19:08:03+01:00
[INFO] ------------------------------------------------------------------------
~/s/p/p/project master /nix/store/dj7xwrgp4kjl36f09yyqsl1ay8glxk5b-lorri-keep-env-hack-nix-shell 1.8s [1]

Note: this only happens when running a command in a directory which is baked by direnv and a shell.nix Nix environment. Running it outside, say in ~, only the exit code is printed.

~ ❱ zsh -c 'sleep 2; exit 0'
~ 2s ❱ zsh -c 'sleep 2; exit 1'
~ 2s [1]

Hydro only prints the error code when exit code != 0. This must be the git prompt behaving erratically.

hydro/conf.d/hydro.fish

Lines 52 to 85 in cf7b198

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

I often see error codes like [0|1]. Can’t remember if there’s a type of command that consistently causes that though.

bwolf commented

Ok thanks, I assume this has nothing to do with Hydro.

@jorgebucaran Never knew about that. Thanks for the link.

Sorry for commenting on a closed issue, but did you find a solution for this issue? @bwolf

bwolf commented

@okkdev unfortunately not.