Skip to content

Conversation

@lfreixial
Copy link
Contributor

Show the repo name on the status bar like
tmux | Main

Can be enabled and disabled by having @dracula-git-show-repo-name in the config file. False by default.

@coderabbitai
Copy link

coderabbitai bot commented Jul 9, 2025

📝 Walkthrough

Walkthrough

A new tmux option @dracula-git-show-repo-name is added to control displaying the Git repository name in the status bar. A helper function retrieves the repository name and prepends it to the Git status output in various cases when the option is enabled.

Changes

File(s) Change Summary
scripts/git.sh Added @dracula-git-show-repo-name option, new getRepoName() function, and updated getMessage() to prepend repo name to Git status output when enabled.
docs/CONFIG.md Added documentation for the new @dracula-git-show-repo-name configuration option with default value and usage example.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Tmux
    participant git.sh

    User->>Tmux: Triggers Git status display
    Tmux->>git.sh: Execute script
    git.sh->>git.sh: Read @dracula-git-show-repo-name option
    alt Option enabled and inside Git repo
        git.sh->>git.sh: getRepoName()
        git.sh->>git.sh: Prepend repo name to status output
    else Option disabled or not in Git repo
        git.sh->>git.sh: Skip repo name
    end
    git.sh-->>Tmux: Output status string (with or without repo name)
    Tmux-->>User: Display status
Loading
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (3)
scripts/git.sh (1)

160-169: Avoid redundant echo-into-variable pattern

output=$(echo "...") spawns an extra subshell for no gain. Direct assignment is simpler & faster:

-             output=$(echo "$repo_name ${changes} $branch")
+             output="$repo_name ${changes} $branch"

Apply the same micro-optimisation to the other three similar lines in this block.
Pure style, but zero-cost to change.

scripts/dual_time.sh (1)

20-25: Broaden zone-file test & quote expansion

Some zones (e.g. Etc/UTC) are directories, not plain files. -e handles both and quoting silences SC2046.

-  if [ -f "/usr/share/zoneinfo/$tz" ]; then
-    time=$(env TZ="$tz" /bin/date +"${label} ${time_fmt}")
+  if [ -e "/usr/share/zoneinfo/$tz" ]; then
+    time="$(env TZ="$tz" /bin/date +"${label} ${time_fmt}")"
scripts/dracula.sh (1)

44-47: Quote command substitutions when populating arrays

Unquoted $(get_tmux_option …) is benign for single-word defaults but will break if a user provides values containing spaces (e.g. plugin names with arguments).

-IFS=' ' read -r -a plugins <<<$(get_tmux_option "@dracula-narrow-plugins" "compact-alt battery network weather")
+IFS=' ' read -r -a plugins <<<"$(get_tmux_option "@dracula-narrow-plugins" "compact-alt battery network weather")"

Apply the same quoting to the regular-width branch (line 46) for consistency.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 89d16fd and d59c782.

📒 Files selected for processing (3)
  • scripts/dracula.sh (9 hunks)
  • scripts/dual_time.sh (1 hunks)
  • scripts/git.sh (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
scripts/git.sh (1)
scripts/utils.sh (1)
  • get_tmux_option (3-12)
scripts/dracula.sh (1)
scripts/utils.sh (1)
  • get_tmux_option (3-12)
🪛 Shellcheck (0.10.0)
scripts/git.sh

[warning] 12-12: Quote this to prevent word splitting.

(SC2046)


[warning] 135-135: Expanding an array without an index only gives the first element.

(SC2128)


[warning] 136-136: Quote this to prevent word splitting.

(SC2046)


[warning] 149-149: Quote this to prevent word splitting.

(SC2046)


[warning] 162-162: Expanding an array without an index only gives the first element.

(SC2128)


[warning] 165-165: Quote this to prevent word splitting.

(SC2046)


[warning] 165-165: Expanding an array without an index only gives the first element.

(SC2128)


[warning] 168-168: Expanding an array without an index only gives the first element.

(SC2128)


[warning] 173-173: Quote this to prevent word splitting.

(SC2046)


[warning] 173-173: Expanding an array without an index only gives the first element.

(SC2128)


[warning] 176-176: Expanding an array without an index only gives the first element.

(SC2128)

scripts/dracula.sh

[warning] 44-44: Quote this to prevent word splitting.

(SC2046)


[warning] 46-46: Quote this to prevent word splitting.

(SC2046)


[warning] 208-208: Quote this to prevent word splitting.

(SC2046)


[warning] 213-213: Quote this to prevent word splitting.

(SC2046)


[warning] 218-218: Quote this to prevent word splitting.

(SC2046)


[warning] 223-223: Quote this to prevent word splitting.

(SC2046)


[warning] 228-228: Quote this to prevent word splitting.

(SC2046)


[warning] 233-233: Quote this to prevent word splitting.

(SC2046)


[warning] 237-237: Quote this to prevent word splitting.

(SC2046)


[warning] 241-241: Quote this to prevent word splitting.

(SC2046)


[warning] 245-245: Quote this to prevent word splitting.

(SC2046)


[warning] 249-249: Quote this to prevent word splitting.

(SC2046)


[warning] 253-253: Quote this to prevent word splitting.

(SC2046)


[warning] 257-257: Quote this to prevent word splitting.

(SC2046)


[warning] 261-261: Quote this to prevent word splitting.

(SC2046)


[warning] 265-265: Quote this to prevent word splitting.

(SC2046)


[warning] 310-310: Quote this to prevent word splitting.

(SC2046)


[warning] 314-314: Quote this to prevent word splitting.

(SC2046)


[warning] 318-318: Quote this to prevent word splitting.

(SC2046)


[warning] 322-322: Quote this to prevent word splitting.

(SC2046)


[warning] 326-326: Quote this to prevent word splitting.

(SC2046)


[warning] 330-330: Quote this to prevent word splitting.

(SC2046)


[warning] 334-334: Quote this to prevent word splitting.

(SC2046)


[warning] 338-338: Quote this to prevent word splitting.

(SC2046)


[warning] 342-342: Quote this to prevent word splitting.

(SC2046)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (3)
scripts/git.sh (3)

12-12: Stop reading @dracula-git-show-repo-name into an array – treat it as a scalar
The option is a single boolean string; using read -r -a turns it into an array and triggers the same SC2128 warnings already raised earlier.

-IFS=' ' read -r -a show_repo_name <<<$(get_tmux_option "@dracula-git-show-repo-name" "false")
+show_repo_name="$(get_tmux_option "@dracula-git-show-repo-name" "false")"

169-172: Same spacing / array issue as above

Replicate the fix applied to the diff-symbol branch to keep the output consistent and shellcheck-clean.


133-139: Quote $path, prepend the pipe, and drop the trailing bar

  1. Paths with spaces will explode without quoting.
  2. Spec says the bar precedes the repo name (… | Repo), not trails (Repo |).
  3. No need to expand an array without an index – "$show_repo_name" is now a scalar (see previous comment).
-getRepoName()
-{
-  if [ "$show_repo_name" == "true" ] && [ "$(checkForGitDir)" == "true" ]; then
-    repo="$(basename "$(git -C $path rev-parse --show-toplevel 2>/dev/null)")"
-    echo "$repo |"
-  fi
-}
+getRepoName() {
+  if [ "$show_repo_name" = "true" ] && [ "$(checkForGitDir)" = "true" ]; then
+    repo="$(basename "$(git -C "$path" --no-optional-locks rev-parse --show-toplevel 2>/dev/null)")"
+    echo "| $repo"
+  fi
+}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d59c782 and 7c44e2e.

📒 Files selected for processing (1)
  • scripts/git.sh (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
scripts/git.sh (1)
scripts/utils.sh (1)
  • get_tmux_option (3-12)
🪛 Shellcheck (0.10.0)
scripts/git.sh

[warning] 12-12: Quote this to prevent word splitting.

(SC2046)


[warning] 135-135: Expanding an array without an index only gives the first element.

(SC2128)


[warning] 144-144: Quote this to prevent word splitting.

(SC2046)


[warning] 157-157: Expanding an array without an index only gives the first element.

(SC2128)


[warning] 160-160: Quote this to prevent word splitting.

(SC2046)


[warning] 160-160: Expanding an array without an index only gives the first element.

(SC2128)


[warning] 163-163: Expanding an array without an index only gives the first element.

(SC2128)


[warning] 168-168: Quote this to prevent word splitting.

(SC2046)


[warning] 168-168: Expanding an array without an index only gives the first element.

(SC2128)


[warning] 171-171: Expanding an array without an index only gives the first element.

(SC2128)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (3)
scripts/git.sh (3)

133-139: Quote $path and move the pipe in getRepoName
The two issues previously pointed out are still present:

  1. git -C $path … breaks when the path contains spaces; quote the variable.
  2. The spec shows … | RepoName, but the current implementation returns "RepoName |".
-getRepoName()
-{
-  if [ "$show_repo_name" == "true" ] && [ "$(checkForGitDir)" == "true" ]; then
-    repo="$(basename "$(git -C $path rev-parse --show-toplevel 2>/dev/null)")"
-    echo "$repo |"
-  fi
-}
+getRepoName() {
+  if [ "$show_repo_name" = "true" ] && [ "$(checkForGitDir)" = "true" ]; then
+    repo="$(basename "$(git -C "$path" --no-optional-locks rev-parse --show-toplevel 2>/dev/null)")"
+    echo "| $repo"
+  fi
+}

155-158: Still building the string with echo, risking double spaces

output=$(echo …) was already flagged as fragile. Construct the string directly to avoid word-splitting quirks:

-             output=$(echo "$repo_name ${changes} $branch")
+             output="$repo_name${changes:+ ${changes}} $branch"

Apply the same pattern to the other branches.


161-164: $diff_symbol used without an index – ShellCheck SC2128

diff_symbol is an array; use an explicit element or treat it as a scalar to silence the warning and avoid accidental truncation.

-             output=$(echo "$repo_name $diff_symbol $branch")
+             output="$repo_name ${diff_symbol[0]} $branch"
🧹 Nitpick comments (1)
scripts/git.sh (1)

169-172: Same array / extra-space issue for current_symbol

Replicate the fix for the no-changes path:

-         output=$(echo "$repo_name $current_symbol $branch")
+         output="$repo_name ${current_symbol[0]} $branch"
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7c44e2e and 0e215d9.

📒 Files selected for processing (1)
  • scripts/git.sh (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
scripts/git.sh (1)
scripts/utils.sh (1)
  • get_tmux_option (3-12)
🪛 Shellcheck (0.10.0)
scripts/git.sh

[warning] 144-144: Quote this to prevent word splitting.

(SC2046)


[warning] 160-160: Quote this to prevent word splitting.

(SC2046)


[warning] 160-160: Expanding an array without an index only gives the first element.

(SC2128)


[warning] 163-163: Expanding an array without an index only gives the first element.

(SC2128)


[warning] 168-168: Quote this to prevent word splitting.

(SC2046)


[warning] 168-168: Expanding an array without an index only gives the first element.

(SC2128)


[warning] 171-171: Expanding an array without an index only gives the first element.

(SC2128)

🔇 Additional comments (1)
scripts/git.sh (1)

12-12: Scalar assignment looks good

Switching to a straight assignment removes the SC2046/SC2128 warnings raised earlier.
Nothing further here.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (3)
scripts/git.sh (3)

133-139: Pipe is on the wrong side & trailing space will propagate
Spec (and the earlier review) expects | RepoName, not RepoName |.
Also, emitting a trailing space forces downstream callers to keep trimming or duplicating spaces.

-    repo="$(basename "$(git -C "$path" --no-optional-locks rev-parse --show-toplevel 2>/dev/null)")"
-    echo "$repo |"
+    repo="$(basename "$(git -C "$path" --no-optional-locks rev-parse --show-toplevel 2>/dev/null)")"
+    echo "| $repo"

168-171: Same array / quoting issue for current_symbol

-if [ $(checkEmptySymbol $current_symbol) == "true" ]; then
+if [ "$(checkEmptySymbol "${current_symbol[0]}")" = "true" ]; then

In the else branch you already use ${current_symbol[0]}—make the check consistent.


160-164: Unindexed $diff_symbol triggers SC2128 & mis-formats output

-output=$(echo "$repo_name $diff_symbol $branch")
+output="$repo_name ${diff_symbol[0]} $branch"

This collapses the array, removes the useless subshell, and keeps spacing consistent.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0e215d9 and 960a6d2.

📒 Files selected for processing (1)
  • scripts/git.sh (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
scripts/git.sh (1)
scripts/utils.sh (1)
  • get_tmux_option (3-12)
🪛 Shellcheck (0.10.0)
scripts/git.sh

[warning] 144-144: Quote this to prevent word splitting.

(SC2046)


[warning] 160-160: Quote this to prevent word splitting.

(SC2046)


[warning] 160-160: Expanding an array without an index only gives the first element.

(SC2128)


[warning] 163-163: Expanding an array without an index only gives the first element.

(SC2128)


[warning] 168-168: Quote this to prevent word splitting.

(SC2046)


[warning] 168-168: Expanding an array without an index only gives the first element.

(SC2128)

🔇 Additional comments (1)
scripts/git.sh (1)

12-12: Good: option now assigned as scalar
Switching to a simple assignment eliminates the earlier SC2046/SC2128 warnings – nice catch.

scripts/git.sh Outdated
Comment on lines 154 to 158
if [ $(checkEmptySymbol $diff_symbol) == "true" ]; then
output=$(echo "${changes} $branch")
output="$repo_name${changes:+ ${changes}} $branch"
else
output=$(echo "$diff_symbol ${changes} $branch")
output="$repo_name ${diff_symbol[0]} ${changes:+$changes }$branch"
fi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Array still expanded as scalar & double-space risk
$diff_symbol is an array; $diff_symbol[0] is already used in line 157, but the empty-symbol check on 154 still passes the entire array unquoted → SC2128/SC2046.
While here, redundant echo concatenation and inconsistent spacing creep in.

-                if [ $(checkEmptySymbol $diff_symbol) == "true" ]; then
+                if [ "$(checkEmptySymbol "${diff_symbol[0]}")" = "true" ]; then

(Apply the same quoting/indexing pattern everywhere checkEmptySymbol is called.)
Consider building output via plain assignment instead of echo to avoid accidental double spaces.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if [ $(checkEmptySymbol $diff_symbol) == "true" ]; then
output=$(echo "${changes} $branch")
output="$repo_name${changes:+ ${changes}} $branch"
else
output=$(echo "$diff_symbol ${changes} $branch")
output="$repo_name ${diff_symbol[0]} ${changes:+$changes }$branch"
fi
if [ "$(checkEmptySymbol "${diff_symbol[0]}")" = "true" ]; then
output="$repo_name${changes:+ ${changes}} $branch"
else
output="$repo_name ${diff_symbol[0]} ${changes:+$changes }$branch"
fi
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 154-154: Quote this to prevent word splitting.

(SC2046)


[warning] 154-154: Expanding an array without an index only gives the first element.

(SC2128)

🤖 Prompt for AI Agents
In scripts/git.sh around lines 154 to 158, the checkEmptySymbol function is
called with the entire diff_symbol array unquoted, causing array expansion
issues and potential double spaces in output. Fix this by passing only the first
element of diff_symbol properly quoted to checkEmptySymbol. Also, revise the
output variable assignment to use plain variable assignment with consistent
spacing instead of echo concatenation to prevent accidental double spaces. Apply
this quoting and indexing pattern consistently wherever checkEmptySymbol is
called with arrays.

lfreixial and others added 3 commits July 11, 2025 21:28
- changed getRepoName to just return the repo name for clarity and reusability
- moved pipe and spaces to separate into variable
- removed space from behind repo_name
  - this is important to me because otherwise this widget would have an additional leading whitespace for everyone not using the repo_name option
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
scripts/git.sh (1)

169-172: Unnecessary subshell & echo – just assign
Using $(echo …) adds a useless process and can mangle spacing. Direct assignment is simpler and safer:

-         output=$(echo "$repo_name$branch")
+         output="$repo_name$branch"

Apply the same pattern throughout the block for consistency.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fe202ab and 389c4eb.

📒 Files selected for processing (1)
  • scripts/git.sh (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
scripts/git.sh (1)
scripts/utils.sh (1)
  • get_tmux_option (3-12)
🪛 Shellcheck (0.10.0)
scripts/git.sh

[warning] 144-144: Quote this to prevent word splitting.

(SC2046)


[warning] 149-149: Quote this to prevent word splitting.

(SC2046)


[warning] 153-153: Expanding an array without an index only gives the first element.

(SC2128)


[warning] 163-163: Expanding an array without an index only gives the first element.

(SC2128)


[warning] 168-168: Quote this to prevent word splitting.

(SC2046)


[warning] 168-168: Expanding an array without an index only gives the first element.

(SC2128)

🔇 Additional comments (1)
scripts/git.sh (1)

12-12: Scalar read looks correct – no action needed.
The new option is retrieved as a plain scalar, which eliminates the earlier array/quoting warnings.

Comment on lines +160 to 164
if [ "$(checkEmptySymbol "${diff_symbol[0]}")" = "true" ]; then
output=$(echo "$repo_name$branch")
else
output=$(echo "$diff_symbol $branch")
output=$(echo "$repo_name$diff_symbol $branch")
fi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Still expanding an array as a scalar – SC2128 resurfaces
$diff_symbol is an array; using it unindexed ("$repo_name$diff_symbol $branch") expands only the first element and revives word-splitting warnings.

-         output=$(echo "$repo_name$diff_symbol $branch")
+         output="$repo_name${diff_symbol[0]} $branch"

Update any other occurrences to keep ShellCheck quiet and behaviour predictable.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if [ "$(checkEmptySymbol "${diff_symbol[0]}")" = "true" ]; then
output=$(echo "$repo_name$branch")
else
output=$(echo "$diff_symbol $branch")
output=$(echo "$repo_name$diff_symbol $branch")
fi
if [ "$(checkEmptySymbol "${diff_symbol[0]}")" = "true" ]; then
output=$(echo "$repo_name$branch")
else
output="$repo_name${diff_symbol[0]} $branch"
fi
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 163-163: Expanding an array without an index only gives the first element.

(SC2128)

🤖 Prompt for AI Agents
In scripts/git.sh around lines 160 to 164, the code uses the array diff_symbol
as a scalar without indexing, causing ShellCheck SC2128 warnings and
unpredictable word splitting. Fix this by explicitly referencing the intended
element of diff_symbol with an index (e.g., diff_symbol[0]) wherever it is used,
including in the else branch, to ensure consistent and predictable expansion and
silence ShellCheck warnings.

Comment on lines 133 to 147
getRepoName()
{
if [ "$show_repo_name" = "true" ] && [ "$(checkForGitDir)" = "true" ]; then
repo="$(basename "$(git -C "$path" --no-optional-locks rev-parse --show-toplevel 2>/dev/null)")"
echo "$repo"
fi
}

# return the final message for the status bar
getMessage()
{
if [ $(checkForGitDir) == "true" ]; then
branch="$(getBranch)"
repo_name="$(getRepoName) | "
output=""
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Pipe placement & “empty-repo” glitch – output does not match spec
getRepoName returns the bare repo name, but a hard-coded " | " is appended later (repo_name="$(getRepoName) | ").
• When the option is disabled or you’re not in a Git repo, getRepoName returns nothing, yet you still inject " | " → stray bar.
• When the option is enabled, the final status becomes "Main | …" whereas the spec shows "| Main …" (bar precedes the name).

-getRepoName()
-{
-  if [ "$show_repo_name" = "true" ] && [ "$(checkForGitDir)" = "true" ]; then
-    repo="$(basename "$(git -C "$path" --no-optional-locks rev-parse --show-toplevel 2>/dev/null)")"
-    echo "$repo"
-  fi
-}
+getRepoName() {
+  if [ "$show_repo_name" = "true" ] && [ "$(checkForGitDir)" = "true" ]; then
+    repo="$(basename "$(git -C "$path" --no-optional-locks rev-parse --show-toplevel 2>/dev/null)")"
+    # Prepend the bar only when a repo name is present
+    echo "| $repo"
+  fi
+}
 
-        repo_name="$(getRepoName) | "
+        repo_name="$(getRepoName)"

This delivers the correct "| Main" format and avoids stray separators.

🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 144-144: Quote this to prevent word splitting.

(SC2046)

🤖 Prompt for AI Agents
In scripts/git.sh around lines 133 to 147, the getRepoName function returns the
repo name without a preceding pipe, but the calling code appends a hard-coded "
| " after it, causing stray separators when the repo name is empty and incorrect
formatting compared to the spec. To fix this, remove the " | " from the
assignment of repo_name and instead prepend the pipe inside getRepoName or in
the output formatting logic so that the pipe appears before the repo name only
when it exists, ensuring no stray separators and matching the spec format "|
Main".

and now this mistake is burned into the repo foreverrrr
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (2)
scripts/git.sh (2)

154-161: Array still expanded as scalar – SC2128 resurfaces.

diff_symbol is an array; line 163 passes the entire array ($diff_symbol) to the string, re-introducing ShellCheck warnings and unpredictable word-splitting.

-		     output=$(echo "$repo_name$diff_symbol $branch")
+		     output="$repo_name${diff_symbol[0]} $branch"

Also, line 154 can avoid a subshell by dropping $(checkEmptySymbol ...)’s command substitution:

-               if [ "$(checkEmptySymbol "${diff_symbol[0]}")" = "true" ]; then
+               if [ "$(checkEmptySymbol "${diff_symbol[0]}")" = "true" ]; then

(Only minor, but keeps style uniform.)

Apply the same indexed/quoted pattern wherever diff_symbol or other option arrays are used.


133-139: Separator placement & trailing-space bug – invert the pipe, drop the tailing space.

getRepoName currently outputs "${repo} | " (repo first, pipe after the name, plus a trailing space).
Effects:
• Status becomes Main | …, whereas the spec example shows | Main … (pipe before name).
• Because the string already ends with a space, every consumer that prefixes its own space (${changes:+ ${changes}} etc.) yields double spaces.

Recommended fix:

-    repo="$(basename "$(git -C "$path" --no-optional-locks rev-parse --show-toplevel 2>/dev/null)")"
-    echo "$repo | "
+    repo="$(basename "$(git -C "$path" --no-optional-locks rev-parse --show-toplevel 2>/dev/null)")"
+    echo "| $repo"

This puts the separator in the right place and guarantees exactly one space that downstream code can reuse.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 389c4eb and 7de8c31.

📒 Files selected for processing (1)
  • scripts/git.sh (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
scripts/git.sh (1)
scripts/utils.sh (1)
  • get_tmux_option (3-12)
🪛 Shellcheck (0.10.0)
scripts/git.sh

[warning] 144-144: Quote this to prevent word splitting.

(SC2046)


[warning] 149-149: Quote this to prevent word splitting.

(SC2046)


[warning] 153-153: Expanding an array without an index only gives the first element.

(SC2128)


[warning] 163-163: Expanding an array without an index only gives the first element.

(SC2128)


[warning] 168-168: Quote this to prevent word splitting.

(SC2046)


[warning] 168-168: Expanding an array without an index only gives the first element.

(SC2128)

🔇 Additional comments (1)
scripts/git.sh (1)

12-12: Good switch to scalar assignment.

The option is now read as a simple string, eliminating the earlier array/quoting issues flagged by ShellCheck.

Comment on lines 168 to 172
if [ $(checkEmptySymbol $current_symbol) == "true" ]; then
output=$(echo "$branch")
output=$(echo "$repo_name$branch")
else
output=$(echo "$current_symbol $branch")
output="$repo_name${current_symbol[0]} $branch"
fi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

current_symbol suffers from the same indexing / quoting issue.

checkEmptySymbol $current_symbol expands only the first element and drops quotes, triggering both SC2128 and SC2046.

-            if [ $(checkEmptySymbol $current_symbol) == "true" ]; then
+            if [ "$(checkEmptySymbol "${current_symbol[0]}")" = "true" ]; then

Mirror this fix everywhere current_symbol is referenced.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if [ $(checkEmptySymbol $current_symbol) == "true" ]; then
output=$(echo "$branch")
output=$(echo "$repo_name$branch")
else
output=$(echo "$current_symbol $branch")
output="$repo_name${current_symbol[0]} $branch"
fi
if [ "$(checkEmptySymbol "${current_symbol[0]}")" = "true" ]; then
output=$(echo "$repo_name$branch")
else
output="$repo_name${current_symbol[0]} $branch"
fi
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 168-168: Quote this to prevent word splitting.

(SC2046)


[warning] 168-168: Expanding an array without an index only gives the first element.

(SC2128)

🤖 Prompt for AI Agents
In scripts/git.sh around lines 168 to 172, the variable current_symbol is used
without proper quoting and indexing, causing shellcheck warnings SC2128 and
SC2046. To fix this, always reference current_symbol with explicit indexing and
proper quoting, for example use "${current_symbol[0]}" instead of
$current_symbol. Apply this quoting and indexing fix consistently wherever
current_symbol is referenced in this code block.

@Theoreticallyhugo
Copy link
Collaborator

hi,
thank you very much for your pr, this is very cool!
i made changes, some of which were stupid and so i immediately undid them, but i stand by moving that white space for all those who won't activate the feature.
i'll leave this pr up for a day or to so that you got time to check my changes and then I'll merge.
this looks good to me

@lfreixial
Copy link
Contributor Author

hi, thank you very much for your pr, this is very cool! i made changes, some of which were stupid and so i immediately undid them, but i stand by moving that white space for all those who won't activate the feature. i'll leave this pr up for a day or to so that you got time to check my changes and then I'll merge. this looks good to me

Awesome thank you so much! and yeah I agree removing the extra white space is a good call.

@Theoreticallyhugo Theoreticallyhugo merged commit a2ddf12 into dracula:master Jul 14, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants