Skip to content

Commit cb2bbfb

Browse files
committed
feat: don't use hydo, roll your own
1 parent fdead02 commit cb2bbfb

File tree

2 files changed

+66
-17
lines changed

2 files changed

+66
-17
lines changed
Lines changed: 66 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,70 @@
1-
# Greeting
2-
31
function fish_greeting
42
fish_logo
53
end
64

7-
# Prompt
8-
set hydro_color_pwd green -d
9-
set hydro_color_git brblack
10-
set hydro_color_prompt brblack
11-
12-
# Tide
13-
set --universal tide_left_prompt_items pwd git
14-
set --universal tide_left_prompt_suffix " \$"
15-
set --universal tide_git_icon ""
16-
set --universal tide_pwd_color_dirs normal
17-
set --universal tide_pwd_color_anchors normal
5+
# track when commands actually execute
6+
function __my_prompt_preexec --on-event fish_preexec
7+
set -g __my_prompt_cmd_executed 1
8+
end
9+
10+
function __my_prompt_postexec --on-event fish_postexec
11+
set -g __my_prompt_last_status $status
12+
end
13+
14+
function fish_prompt
15+
# capture previous command status IMMEDIATELY - must be first
16+
set -l last_status $status
17+
18+
# cache git prompt setup once
19+
if not set -q __my_prompt_git_inited
20+
set -g __fish_git_prompt_showdirtystate 1
21+
set -g __fish_git_prompt_showuntrackedfiles 0
22+
set -g __fish_git_prompt_showcolorhints 0
23+
set -g __fish_git_prompt_char_stateseparator '' # stick "*" to branch
24+
set -g __my_prompt_git_inited 1
25+
end
26+
27+
# line 1: cwd + gray annotations
28+
set_color $fish_color_cwd
29+
printf '%s' (prompt_pwd)
30+
set_color normal
31+
32+
# git branch without parentheses
33+
set -l git_seg (fish_git_prompt "%s")
34+
35+
# duration from CMD_DURATION: ms; switch to seconds >= 1000ms
36+
set -l dur_ms $CMD_DURATION
37+
set -l dur_str $dur_ms"ms"
38+
if test $dur_ms -ge 1000
39+
set dur_str (math -s 1 "$dur_ms/1000")"s"
40+
end
41+
42+
# build annotations: [branch?] <dur> | [status?]
43+
set -l parts
44+
if test -n "$git_seg"
45+
set parts $parts $git_seg
46+
end
47+
set parts $parts $dur_str
48+
49+
# only show status if a command was actually executed and failed
50+
if set -q __my_prompt_cmd_executed; and test $last_status -ne 0
51+
set parts $parts "$last_status"
52+
else
53+
set parts $parts ""
54+
end
55+
56+
# clear the command executed flag
57+
set -e __my_prompt_cmd_executed
58+
59+
if test (count $parts) -gt 0
60+
printf ' '
61+
set_color brblack
62+
printf '%s' (string join ' ' -- $parts)
63+
set_color normal
64+
end
65+
printf '\n'
66+
67+
# line 2: prompt char only
68+
printf '$ '
69+
end
70+

managed/dot_config/fish/user/vi.fish

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,15 @@ function fish_mode_prompt
1919
case default
2020
set vi_mode_color (set_color --reverse magenta)
2121
set vi_mode_symbol N
22-
__fish_cursor_xterm block # WORKAROUND
2322
case insert
2423
set vi_mode_color (set_color --reverse green)
2524
set vi_mode_symbol I
26-
__fish_cursor_xterm line # WORKAROUND
2725
case replace replace_one
2826
set vi_mode_color (set_color --reverse red)
2927
set vi_mode_symbol R
30-
__fish_cursor_xterm underscore # WORKAROUND
3128
case visual
3229
set vi_mode_color (set_color --reverse cyan)
3330
set vi_mode_symbol V
34-
__fish_cursor_xterm block # WORKAROUND
3531
end
3632
string unescape "$vi_mode_color $vi_mode_symbol \x1b[0m "
3733
end

0 commit comments

Comments
 (0)