Skip to content

Commit

Permalink
add max number of chars
Browse files Browse the repository at this point in the history
  • Loading branch information
Theoreticallyhugo committed Feb 8, 2025
1 parent c125907 commit b473719
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions scripts/cwd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ getPaneDir() {
}

main() {
path=$(getPaneDir)
path="$(getPaneDir)"

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

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

if [[ "$cwd_max_dirs" -gt 0 ]]; then
base_to_erase=$cwd
Expand All @@ -40,6 +40,11 @@ main() {
fi
fi

cwd_max_chars="$(get_tmux_option "@dracula-cwd-max-chars" "0")"
if [[ "${#cwd}" -gt "$cwd_max_chars" ]]; then
cwd="…/…${cwd:(- cwd_max_chars)}"
fi

echo "$cwd"
}

Expand Down

0 comments on commit b473719

Please sign in to comment.