Skip to content

Commit a2ddf12

Browse files
Merge pull request #349 from lfreixial/show-repo-name-status-bar
feat(): Show repo name status bar
2 parents a6cb07f + 7de8c31 commit a2ddf12

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

docs/CONFIG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,12 @@ Show remote tracking branch together with diverge/sync state
379379
set -g @dracula-git-show-remote-status true
380380
```
381381

382+
Show the current repository name in the status bar
383+
```bash
384+
# default is false
385+
set -g @dracula-git-show-repo-name true
386+
```
387+
382388
### gpu-info - [up](#table-of-contents)
383389

384390
These widgets display the current computational, ram, and power usage of installed graphics cards.

scripts/git.sh

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ IFS=' ' read -r -a diff_symbol <<< $(get_tmux_option "@dracula-git-show-diff-sym
99
IFS=' ' read -r -a no_repo_message <<< $(get_tmux_option "@dracula-git-no-repo-message" "")
1010
IFS=' ' read -r -a no_untracked_files <<< $(get_tmux_option "@dracula-git-no-untracked-files" "false")
1111
IFS=' ' read -r -a show_remote_status <<< $(get_tmux_option "@dracula-git-show-remote-status" "false")
12+
show_repo_name="$(get_tmux_option "@dracula-git-show-repo-name" "false")"
1213

1314
# Get added, modified, updated and deleted files from git status
1415
getChanges()
@@ -129,36 +130,45 @@ getRemoteInfo()
129130
echo "$out"
130131
}
131132

133+
getRepoName()
134+
{
135+
if [ "$show_repo_name" = "true" ] && [ "$(checkForGitDir)" = "true" ]; then
136+
repo="$(basename "$(git -C "$path" --no-optional-locks rev-parse --show-toplevel 2>/dev/null)")"
137+
echo "$repo | "
138+
fi
139+
}
140+
132141
# return the final message for the status bar
133142
getMessage()
134143
{
135144
if [ $(checkForGitDir) == "true" ]; then
136145
branch="$(getBranch)"
146+
repo_name="$(getRepoName)"
137147
output=""
138148

139149
if [ $(checkForChanges) == "true" ]; then
140150

141151
changes="$(getChanges)"
142152

143153
if [ "${hide_status}" == "false" ]; then
144-
if [ $(checkEmptySymbol $diff_symbol) == "true" ]; then
145-
output=$(echo "${changes} $branch")
154+
if [ "$(checkEmptySymbol "${diff_symbol[0]}")" = "true" ]; then
155+
output="$repo_name${changes:+ ${changes}} $branch"
146156
else
147-
output=$(echo "$diff_symbol ${changes} $branch")
157+
output="$repo_name${diff_symbol[0]} ${changes:+$changes }$branch"
148158
fi
149159
else
150-
if [ $(checkEmptySymbol $diff_symbol) == "true" ]; then
151-
output=$(echo "$branch")
160+
if [ "$(checkEmptySymbol "${diff_symbol[0]}")" = "true" ]; then
161+
output=$(echo "$repo_name$branch")
152162
else
153-
output=$(echo "$diff_symbol $branch")
163+
output=$(echo "$repo_name$diff_symbol $branch")
154164
fi
155165
fi
156166

157167
else
158168
if [ $(checkEmptySymbol $current_symbol) == "true" ]; then
159-
output=$(echo "$branch")
169+
output=$(echo "$repo_name$branch")
160170
else
161-
output=$(echo "$current_symbol $branch")
171+
output="$repo_name${current_symbol[0]} $branch"
162172
fi
163173
fi
164174

0 commit comments

Comments
 (0)