Skip to content

Commit

Permalink
✨ Add new styles
Browse files Browse the repository at this point in the history
- Add human-single-line style.
- Add human-dark-single-line style.

closes #45
  • Loading branch information
diogocavilha committed Dec 1, 2019
1 parent e96256f commit b11849f
Show file tree
Hide file tree
Showing 5 changed files with 208 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Fancy Git Changelog

### v6.2.6

- Add `human-single-line` style.
- Add `human-dark-single-line` style.

### v6.1.6

- Improve the way fancygit looks for its configurations.
Expand Down
2 changes: 2 additions & 0 deletions commands.sh
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ case "$1" in
"double-line") fg_update_app_config "style" "fancy-double-line";;
"simple-double-line") fg_update_app_config "style" "simple-double-line";;
"human") fg_update_app_config "style" "human";;
"human-single-line") fg_update_app_config "style" "human-single-line";;
"human-dark") fg_update_app_config "style" "human-dark";;
"human-dark-single-line") fg_update_app_config "style" "human-dark-single-line";;
"dark") fg_update_app_config "style" "dark";;
"dark-double-line") fg_update_app_config "style" "dark-double-line";;
"light") fg_update_app_config "style" "light";;
Expand Down
2 changes: 2 additions & 0 deletions fancygit-completion
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ _fancygit() {
update \
configure-fonts \
human \
human-single-line \
human-dark \
human-dark-single-line \
default \
double-line \
simple \
Expand Down
101 changes: 101 additions & 0 deletions prompt_styles/human-dark-single-line.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#!/bin/bash
#
# Author: Diogo Alexsander Cavilha <[email protected]>
# Date: 06.11.2018

. ~/.fancy-git/aliases
. ~/.fancy-git/fancygit-completion
. ~/.fancy-git/commands.sh

fg_branch_status() {
. ~/.fancy-git/config.sh

local info=""

if [ "$git_has_unpushed_commits" ]
then
info="${info}${light_green}${git_number_unpushed_commits}^${none} "
fi

if [ "$git_number_untracked_files" -gt 0 ]
then
info="${info}${cyan}?${none} "
fi

if [ "$git_number_changed_files" -gt 0 ]
then
info="${info}${light_green}+${none}${light_red}-${none} "
fi

if [ "$git_stash" != "" ]
then
info="${info}${none} "
fi

if [ "$staged_files" != "" ]
then
info="${info}${light_green}${none} "
fi

if [ "$info" != "" ]; then
info=$(echo "$info" | sed -e 's/[[:space:]]*$//')
echo " [$info]"
return
fi

echo ""
}

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" != "" ] && [ "$only_local_branch" -eq 0 ]; then
branch_name="${orange}$branch_name${none}${light_green}*${none}"
fi

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

echo "$branch_name$(fg_branch_status) "
}

fancygit_prompt_builder() {
. ~/.fancy-git/update_checker.sh && _fancygit_update_checker

# Colors
local bold="\\[\\e[1m\\]"
local bold_none="\\[\\e[0m\\]"
local none="\\[\\e[39m\\]"
local red="\\[\\e[31m\\]"

local at="${red}at${none}"
local in="${red}in${none}"
local on="${red}on${none}"
local venvfor="${red}for${none}"

# Prompt
local user="\u"
local host="\h"
local where="\W"
local venv=""

if fg_show_full_path
then
where="\w"
fi

if ! [ -z ${VIRTUAL_ENV} ]; then
venv="`basename \"$VIRTUAL_ENV\"` ${venvfor} "
fi

PS1="${bold}${venv}${user} ${at} ${host} ${in} $where$(fg_branch_name)${bold_none}\$ "
}

PROMPT_COMMAND="fancygit_prompt_builder"
98 changes: 98 additions & 0 deletions prompt_styles/human-single-line.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/bin/bash
#
# Author: Diogo Alexsander Cavilha <[email protected]>
# Date: 06.11.2018

. ~/.fancy-git/aliases
. ~/.fancy-git/fancygit-completion
. ~/.fancy-git/commands.sh

fg_branch_status() {
. ~/.fancy-git/config.sh

local info=""

if [ "$git_has_unpushed_commits" ]
then
info="${info}${light_green}${git_number_unpushed_commits}^${none} "
fi

if [ "$git_number_untracked_files" -gt 0 ]
then
info="${info}${cyan}?${none} "
fi

if [ "$git_number_changed_files" -gt 0 ]
then
info="${info}${light_green}+${none}${light_red}-${none} "
fi

if [ "$git_stash" != "" ]
then
info="${info}${none} "
fi

if [ "$staged_files" != "" ]
then
info="${info}${light_green}>${none} "
fi

if [ "$info" != "" ]; then
info=$(echo "$info" | sed -e 's/[[:space:]]*$//')
echo " [$info]"
return
fi

echo ""
}

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}"
fi

echo "$branch_name$(fg_branch_status) "
}

fancygit_prompt_builder() {
. ~/.fancy-git/update_checker.sh && _fancygit_update_checker

# Colors
local blue="\\[\\e[34m\\]"
local bold="\\[\\e[1m\\]"
local bold_none="\\[\\e[0m\\]"
local light_green="\\[\\e[92m\\]"
local light_yellow="\\[\\e[93m\\]"
local none="\\[\\e[39m\\]"
local orange="\\033[95;38;5;214m"

# Prompt
local user="${orange}\u${none}"
local host="${light_yellow}\h${none}"
local where="${light_green}\w${none}"
local venv=""

if ! fg_show_full_path
then
where="${light_green}\W${none}"
fi

if ! [ -z ${VIRTUAL_ENV} ]; then
venv="${light_yellow}`basename \"$VIRTUAL_ENV\"`${none} for "
fi

PS1="${bold}${venv}${user} at ${host} in $where$(fg_branch_name)${bold_none}\$ "
}

PROMPT_COMMAND="fancygit_prompt_builder"

0 comments on commit b11849f

Please sign in to comment.