Skip to content

Commit 5d7e58f

Browse files
committed
fix: fastfetch render in multiple window
1 parent a65647d commit 5d7e58f

1 file changed

Lines changed: 30 additions & 3 deletions

File tree

configs/zsh/.zshrc

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,32 @@
11

2-
fastfetch
2+
3+
4+
FASTFETCH_SHOWN=0
5+
6+
function hyprland_is_single_window() {
7+
command -v hyprctl >/dev/null || return 1
8+
9+
local ws windows
10+
ws=$(hyprctl activeworkspace -j 2>/dev/null | jq -r '.id')
11+
windows=$(hyprctl clients -j 2>/dev/null | jq "[.[] | select(.workspace.id == $ws)] | length")
12+
13+
[[ "$windows" -eq 1 ]]
14+
}
15+
16+
function show_fastfetch_once() {
17+
[[ $FASTFETCH_SHOWN -eq 1 ]] && return
18+
19+
20+
hyprland_is_single_window || return
21+
22+
FASTFETCH_SHOWN=1
23+
sleep 0.1
24+
clear
25+
fastfetch
26+
}
27+
28+
autoload -Uz add-zsh-hook
29+
add-zsh-hook precmd show_fastfetch_once
330

431
[[ $- != *i* ]] && return
532

@@ -79,10 +106,10 @@ git_prompt() {
79106
out="%F{213} ${branch}%f"
80107

81108
# Show staged count
82-
(( staged > 0 )) && out+=" %F{82}${staged}%f"
109+
(( staged > 0 )) && out+=" %F{82} ${staged}%f"
83110

84111
# Show unstaged / untracked count
85-
(( unstaged > 0 )) && out+=" %F{226}${unstaged}%f"
112+
(( unstaged > 0 )) && out+=" %F{226} ${unstaged}%f"
86113

87114
print -P "$out"
88115
}

0 commit comments

Comments
 (0)