Skip to content

Commit

Permalink
📝 Add sign for local branches only
Browse files Browse the repository at this point in the history
If a branch called "testing" exists only locally, that will be shown
with an * at the end of its name, like testing*
  • Loading branch information
diogocavilha committed Dec 19, 2018
1 parent 4027aff commit fcd7b57
Show file tree
Hide file tree
Showing 13 changed files with 90 additions and 40 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Fancy Git Changelog

### v5.3.0

- Add a sign for remote branches only.

### v5.2.9

- Change stash icon from simple and human styles.
Expand Down
2 changes: 2 additions & 0 deletions help.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ echo " Fancy Git v$FANCYGIT_VERSION - $fg_current_year by Diogo Alexsander Cavil
∿ = There are stashes.
N^ = There are N commits waiting to be pushed.
If a branch name is followed by an asterisk (*), it means that the branch exists only locally.
ALIASES
gs Show git status.
Expand Down
6 changes: 6 additions & 0 deletions prompt_styles/dark-double-line.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ fancygit_prompt_builder() {
prompt_symbol="\n${user_symbol}\$${user_symbol_end}"
prompt_path="${path}${bold}${white} \\w ${path_end}${s_darkgray}"

local only_local_branch=$(git branch -a 2> /dev/null | egrep "remotes/origin/${branch_name}" | wc -l)

if [ "$branch_name" != "" ] && [ "$only_local_branch" -eq 0 ]; then
branch_name="${branch_name}*"
fi

if [ "$branch_name" != "" ]
then
prompt_path="${path_git}${has_unpushed_commits}${has_git_stash}${has_untracked_files}${has_changed_files}${has_added_files} \\w ${path_end}"
Expand Down
6 changes: 6 additions & 0 deletions prompt_styles/dark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ fancygit_prompt_builder() {
prompt_symbol="${user_symbol} \$ ${user_symbol_end}"
prompt_path="${path}${bold}${white} \\w ${path_end}${s_darkgray01}"

local only_local_branch=$(git branch -a 2> /dev/null | egrep "remotes/origin/${branch_name}" | wc -l)

if [ "$branch_name" != "" ] && [ "$only_local_branch" -eq 0 ]; then
branch_name="${branch_name}*"
fi

if [ "$branch_name" != "" ]
then
prompt_path="${path_git}${has_unpushed_commits}${has_git_stash}${has_untracked_files}${has_changed_files}${has_added_files} \\w ${path_end}"
Expand Down
6 changes: 6 additions & 0 deletions prompt_styles/default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ fancygit_prompt_builder() {
prompt_symbol="${user_symbol} \$ ${user_symbol_end}"
prompt_path="${path}${bold}${white} \\w ${path_end}${s_blue}"

local only_local_branch=$(git branch -a 2> /dev/null | egrep "remotes/origin/${branch_name}" | wc -l)

if [ "$branch_name" != "" ] && [ "$only_local_branch" -eq 0 ]; then
branch_name="${branch_name}*"
fi

if [ "$branch_name" != "" ]
then
prompt_path="${path_git}${has_unpushed_commits}${has_git_stash}${has_untracked_files}${has_changed_files}${has_added_files} \\w ${path_end}"
Expand Down
6 changes: 6 additions & 0 deletions prompt_styles/fancy-double-line.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ fancygit_prompt_builder() {
prompt_symbol="\n${user_symbol}\$${user_symbol_end}"
prompt_path="${path}${bold}${white} \\w ${path_end}${s_blue}"

local only_local_branch=$(git branch -a 2> /dev/null | egrep "remotes/origin/${branch_name}" | wc -l)

if [ "$branch_name" != "" ] && [ "$only_local_branch" -eq 0 ]; then
branch_name="${branch_name}*"
fi

if [ "$branch_name" != "" ]
then
prompt_path="${path_git}${has_unpushed_commits}${has_git_stash}${has_untracked_files}${has_changed_files}${has_added_files} \\w ${path_end}"
Expand Down
22 changes: 13 additions & 9 deletions prompt_styles/human-dark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
fg_branch_status() {
. ~/.fancy-git/config.sh

local info
info=""
local info=""

if [ "$git_has_unpushed_commits" ]
then
Expand Down Expand Up @@ -49,17 +48,22 @@ fg_branch_status() {

fg_branch_name() {
local branch_name=$(git rev-parse --abbrev-ref HEAD 2> /dev/null)
local only_local_branch=$(git branch -a 2> /dev/null | egrep "remotes/origin/${branch_name}" | wc -l)
local orange="\\033[95;38;5;214m"
local light_green="\\[\\e[92m\\]"
local red="\\[\\e[31m\\]"
local none="\\[\\e[39m\\]"
local on="${red}on${none}"

if [ "$branch_name" != "" ]; then
local orange="\\033[95;38;5;214m"
local red="\\[\\e[31m\\]"
local none="\\[\\e[39m\\]"
local on="${red}on${none}"
if [ "$branch_name" != "" ] && [ "$only_local_branch" -eq 0 ]; then
branch_name="${orange}$branch_name${none}${light_green}*${none}"
fi

branch_name="${on} ${orange}$branch_name${none} $(fg_branch_status)"
if [ "$branch_name" != "" ]; then
branch_name="${on} ${orange}$branch_name${none}"
fi

echo "$branch_name"
echo "$branch_name $(fg_branch_status)"
}

fancygit_prompt_builder() {
Expand Down
14 changes: 10 additions & 4 deletions prompt_styles/human.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
fg_branch_status() {
. ~/.fancy-git/config.sh

local info
info=""
local info=""

if [ "$git_has_unpushed_commits" ]
then
Expand Down Expand Up @@ -50,12 +49,19 @@ fg_branch_status() {
fg_branch_name() {
local light_magenta="\\[\\e[95m\\]"
local branch_name=$(git rev-parse --abbrev-ref HEAD 2> /dev/null)
local only_local_branch=$(git branch -a 2> /dev/null | egrep "remotes/origin/${branch_name}" | wc -l)
local light_green="\\[\\e[92m\\]"
local none="\\[\\e[39m\\]"

if [ "$branch_name" != "" ] && [ "$only_local_branch" -eq 0 ]; then
branch_name="${light_magenta}$branch_name${none}${light_green}*${none}"
fi

if [ "$branch_name" != "" ]; then
branch_name="on ${light_magenta}$branch_name${none} $(fg_branch_status)"
branch_name="on ${light_magenta}$branch_name${none}"
fi

echo "$branch_name"
echo "$branch_name $(fg_branch_status)"
}

fancygit_prompt_builder() {
Expand Down
6 changes: 6 additions & 0 deletions prompt_styles/light-double-line.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ fancygit_prompt_builder() {
prompt_symbol="\n${user_symbol}\$${user_symbol_end}"
prompt_path="${path}${bold}${white} \\w ${path_end}${s_darkgray}"

local only_local_branch=$(git branch -a 2> /dev/null | egrep "remotes/origin/${branch_name}" | wc -l)

if [ "$branch_name" != "" ] && [ "$only_local_branch" -eq 0 ]; then
branch_name="${branch_name}*"
fi

if [ "$branch_name" != "" ]
then
prompt_path="${path_git}${has_unpushed_commits}${has_git_stash}${has_untracked_files}${has_changed_files}${has_added_files} \\w ${path_end}"
Expand Down
6 changes: 6 additions & 0 deletions prompt_styles/light.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ fancygit_prompt_builder() {
prompt_symbol="${user_symbol} \$ ${user_symbol_end}"
prompt_path="${path}${bold}${black} \\w ${path_end}${s_lightgray}"

local only_local_branch=$(git branch -a 2> /dev/null | egrep "remotes/origin/${branch_name}" | wc -l)

if [ "$branch_name" != "" ] && [ "$only_local_branch" -eq 0 ]; then
branch_name="${branch_name}*"
fi

if [ "$branch_name" != "" ]
then
prompt_path="${path_git}${has_unpushed_commits}${has_git_stash}${has_untracked_files}${has_changed_files}${has_added_files} \\w ${path_end}"
Expand Down
25 changes: 12 additions & 13 deletions prompt_styles/simple-double-line.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
fg_branch_status() {
. ~/.fancy-git/config.sh

local info
info=""
local info=""

if [ "$git_has_unpushed_commits" ]
then
Expand Down Expand Up @@ -48,22 +47,22 @@ fg_branch_status() {
}

fg_branch_name() {
local branch_name
local branch_status

branch_name=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
branch_status=$(fg_branch_status)

if [ "$branch_status" != "" ]; then
branch_name="$branch_name | "
local branch_name=$(git rev-parse --abbrev-ref HEAD 2> /dev/null)
local only_local_branch=$(git branch -a 2> /dev/null | egrep "remotes/origin/${branch_name}" | wc -l)
local branch_status=$(fg_branch_status)
local light_green="\\[\\e[92m\\]"
local none="\\[\\e[39m\\]"

if [ "$branch_name" != "" ] && [ "$only_local_branch" -eq 0 ]; then
branch_name="$branch_name${light_green}*${none}"
fi

if [ "$branch_name" != "" ]; then
branch_name="($branch_name$branch_status)"
if [ "$branch_status" != "" ]; then
branch_name="$branch_name | $branch_status"
fi

if [ "$branch_name" != "" ]; then
echo " $branch_name"
echo " ($branch_name)"
return
fi

Expand Down
25 changes: 12 additions & 13 deletions prompt_styles/simple.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
fg_branch_status() {
. ~/.fancy-git/config.sh

local info
info=""
local info=""

if [ "$git_has_unpushed_commits" ]
then
Expand Down Expand Up @@ -48,22 +47,22 @@ fg_branch_status() {
}

fg_branch_name() {
local branch_name
local branch_status

branch_name=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
branch_status=$(fg_branch_status)

if [ "$branch_status" != "" ]; then
branch_name="$branch_name | "
local branch_name=$(git rev-parse --abbrev-ref HEAD 2> /dev/null)
local only_local_branch=$(git branch -a 2> /dev/null | egrep "remotes/origin/${branch_name}" | wc -l)
local branch_status=$(fg_branch_status)
local light_green="\\[\\e[92m\\]"
local none="\\[\\e[39m\\]"

if [ "$branch_name" != "" ] && [ "$only_local_branch" -eq 0 ]; then
branch_name="$branch_name${light_green}*${none}"
fi

if [ "$branch_name" != "" ]; then
branch_name="($branch_name$branch_status)"
if [ "$branch_status" != "" ]; then
branch_name="$branch_name | $branch_status"
fi

if [ "$branch_name" != "" ]; then
echo " $branch_name"
echo " ($branch_name)"
return
fi

Expand Down
2 changes: 1 addition & 1 deletion version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# Author: Diogo Alexsander Cavilha <[email protected]>
# Date: 11.17.2017

FANCYGIT_VERSION="5.2.9"
FANCYGIT_VERSION="5.3.0"

0 comments on commit fcd7b57

Please sign in to comment.