Skip to content

Commit b473719

Browse files
add max number of chars
1 parent c125907 commit b473719

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

scripts/cwd.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ getPaneDir() {
1616
}
1717

1818
main() {
19-
path=$(getPaneDir)
19+
path="$(getPaneDir)"
2020

2121
if [[ "$path" == "$HOME" ]]; then
2222
echo "~"
@@ -27,7 +27,7 @@ main() {
2727
cwd="${path/"${HOME}/"/'~/'}"
2828

2929
# check max number of subdirs to display. 0 means unlimited
30-
cwd_max_dirs=$(get_tmux_option "@dracula-cwd-max-dirs" "0")
30+
cwd_max_dirs="$(get_tmux_option "@dracula-cwd-max-dirs" "0")"
3131

3232
if [[ "$cwd_max_dirs" -gt 0 ]]; then
3333
base_to_erase=$cwd
@@ -40,6 +40,11 @@ main() {
4040
fi
4141
fi
4242

43+
cwd_max_chars="$(get_tmux_option "@dracula-cwd-max-chars" "0")"
44+
if [[ "${#cwd}" -gt "$cwd_max_chars" ]]; then
45+
cwd="…/…${cwd:(- cwd_max_chars)}"
46+
fi
47+
4348
echo "$cwd"
4449
}
4550

0 commit comments

Comments
 (0)