Skip to content

Commit

Permalink
Creates new config commands
Browse files Browse the repository at this point in the history
It fixes #72

`fancygit --disable-show-user-at-machine`
Fancygit will hide (user@machine) info.

`fancygit --enable-show-user-at-machine`
Fancygit will show (user@machine) info, as usual.
  • Loading branch information
diogocavilha committed Aug 16, 2020
1 parent 3a2c397 commit d08b3ff
Show file tree
Hide file tree
Showing 18 changed files with 147 additions and 48 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- Add one more question to "gd" command.
- Fix a minor bug when using MacOS.
- Add the `fancygit --enable-show-user-at-machine` command for making FancyGit to show the the (user@machine) prompt info.
- Add the `fancygit --disable-show-user-at-machine` command for making FancyGit not to show the the (user@machine) prompt info.
- Change the `fancygit --full-path-disable` command to `fancygit --disable-full-path` in orer to keep it organized.
- Change the `fancygit --full-path-enable` command to `fancygit --enable-full-path` in orer to keep it organized.

### v6.3.0

Expand Down
44 changes: 23 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,27 +119,29 @@ Here you have a list of available styles and their corresponding command to appl

# Commands

| Command | Description
| ---------------------------- | ---------------------------------------------------------
| fancygit -h, --help | Show this help.
| fancygit -v, --version | Show the fancygit version.
| fancygit update | Update fancygit code with the latest release from github.
| fancygit configure-fonts | Install font in order to render icons properly. This font is good if you are using some of these styles: `default`, `double-line`, `dark`, `dark-double-line`, `light`, `light-double-line`.
| fancygit --colors | Show suggested colors config in an easy way to copy and paste to apply them.
| fancygit --colors-set | Apply the suggested colors configuration.
| fancygit --full-path-disable | Fancygit will show only the the directory name you are working on. Not the entire path.
| fancygit --full-path-enable | Fancygit will show the entire path.
| fancygit simple | Change prompt to the simple style.
| fancygit simple-double-line | Change prompt to the simple style in double line.
| fancygit default | Change prompt to the default (colored) style. (This is the fallback style).
| fancygit double-line | Change prompt to the default (colored) style in double line.
| fancygit human | Change prompt to the human readable style.
| fancygit human-dark | Change prompt to the human readable style.
| fancygit dark | Change prompt to the dark style.
| fancygit dark-double-line | Change prompt to the dark style in double line.
| fancygit dark-col-double-line| Change prompt to the dark (colored) style in double line.
| fancygit light | Change prompt to the light style.
| fancygit light-double-line | Change prompt to the light style in double line.
| Command | Description
| ------------------------------------------ | ---------------------------------------------------------
| fancygit -h, --help | Show this help.
| fancygit -v, --version | Show the fancygit version.
| fancygit update | Update fancygit code with the latest release from github.
| fancygit configure-fonts | Install font in order to render icons properly. This font is good if you are using some of these styles: `default`, `double-line`, `dark`, `dark-double-line`, `light`, `light-double-line`.
| fancygit --colors | Show suggested colors config in an easy way to copy and paste to apply them.
| fancygit --colors-set | Apply the suggested colors configuration.
| fancygit --disable-full-path | Fancygit will show only the the directory name you are working on. Not the entire path.
| fancygit --enable-full-path | Fancygit will show the entire path.
| fancygit --disable-show-user-at-machine | Fancygit will hide (user@machine) info.
| fancygit --enable-show-user-at-machine | Fancygit will show (user@machine) info, as usual.
| fancygit simple | Change prompt to the simple style.
| fancygit simple-double-line | Change prompt to the simple style in double line.
| fancygit default | Change prompt to the default (colored) style. (This is the fallback style).
| fancygit double-line | Change prompt to the default (colored) style in double line.
| fancygit human | Change prompt to the human readable style.
| fancygit human-dark | Change prompt to the human readable style.
| fancygit dark | Change prompt to the dark style.
| fancygit dark-double-line | Change prompt to the dark style in double line.
| fancygit dark-col-double-line | Change prompt to the dark (colored) style in double line.
| fancygit light | Change prompt to the light style.
| fancygit light-double-line | Change prompt to the light style in double line.

# Aliases

Expand Down
1 change: 1 addition & 0 deletions app_config_sample
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
style:default
show-full-path:true
show-user-at-machine:true
fresh_file
24 changes: 19 additions & 5 deletions commands.sh
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,23 @@ fg_show_app_config() {
}

fg_show_full_path() {
local show_full_path=""
local config_content=""

show_full_path=$(grep -o 'show-full-path:false' < ~/.fancy-git/app_config)
config_content=$(grep -o 'show-full-path:false' < ~/.fancy-git/app_config)

if [ "$show_full_path" = "show-full-path:false" ]; then
if [ "$config_content" = "show-full-path:false" ]; then
return 1
fi

return 0
}

fg_show_user_at_machine() {
local config_content=""

config_content=$(grep -o 'show-user-at-machine:false' < ~/.fancy-git/app_config)

if [ "$config_content" = "show-user-at-machine:false" ]; then
return 1
fi

Expand Down Expand Up @@ -268,8 +280,10 @@ case "$1" in
"-v"|"--version") fg_show_version;;
"--colors") fg_show_colors_config;;
"--colors-set") fg_colors_config_set;;
"--full-path-enable") fg_update_app_config "show-full-path" "true";;
"--full-path-disable") fg_update_app_config "show-full-path" "false";;
"--enable-full-path") fg_update_app_config "show-full-path" "true";;
"--disable-full-path") fg_update_app_config "show-full-path" "false";;
"--enable-show-user-at-machine") fg_update_app_config "show-user-at-machine" "true";;
"--disable-show-user-at-machine") fg_update_app_config "show-user-at-machine" "false";;
"--config-list") fg_show_app_config;;
"--config-reset") fg_reset_app_config;;
"update") fg_update_checker;;
Expand Down
6 changes: 4 additions & 2 deletions fancygit-completion
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ _fancygit() {
light-double-line \
--colors \
--colors-set \
--full-path-enable \
--full-path-disable \
--enable-full-path \
--disable-full-path \
--enable-show-user-at-machine \
--disable-show-user-at-machine \
--config-list \
--config-reset
'
Expand Down
16 changes: 12 additions & 4 deletions prompt_styles/dark-col-double-line.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ fancygit_prompt_builder() {
user="${orange}${bg_dark_gray_01}${bold}"
at="${white}${bg_dark_gray_01}${bold}"
host="${light_yellow}${bg_dark_gray_01}${bold}"
user_at_host_end="${bold_none}${bg_none}${s_darkgray01_bgdarkgray}"
user_at_host_end_git="${bold_none}${bg_none}${s_darkgray01_bgdarkgray05}"
user_at_host_end="${bold_none}${bg_none}"
user_at_host_end_git="${bold_none}${bg_none}"
user_symbol="${bg_dark_gray}${bold}${white}"
user_symbol_end="${none}${bold_none}${bg_none}${s_darkgray}"
path="${bg_dark_gray}${white}${bold}"
Expand All @@ -35,6 +35,7 @@ fancygit_prompt_builder() {
branch_end="${bg_none}${none}${bold_none}${s_darkgray04}"
local venv=""
local path_sign=""
local user_at_host=""

# Building prompt
if [ "$branch_status" != "" ]
Expand Down Expand Up @@ -75,11 +76,18 @@ fancygit_prompt_builder() {
has_unpushed_commits=""
fi

if fg_show_user_at_machine
then
user_at_host="${user}\\u${at}@${host}\\h "
user_at_host_end="${bold_none}${bg_none}${s_darkgray01_bgdarkgray}"
user_at_host_end_git="${bold_none}${bg_none}${s_darkgray01_bgdarkgray05}"
fi

if [ "$branch_name" != "" ]
then
prompt_user="${user}\\u${at}@${host}\\h ${user_at_host_end_git}"
prompt_user="${user_at_host}${user_at_host_end_git}"
else
prompt_user="${user}\\u${at}@${host}\\h ${user_at_host_end}"
prompt_user="${user_at_host}${user_at_host_end}"
fi

prompt_symbol="\n${user_symbol}\$${user_symbol_end}"
Expand Down
9 changes: 8 additions & 1 deletion prompt_styles/dark-double-line.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ fancygit_prompt_builder() {
branch_end="${bg_none}${none}${bold_none}${s_white}"
local venv=""
local path_sign=""
local prompt_user=""

# Building prompt
if [ "$branch_status" != "" ]
Expand Down Expand Up @@ -63,7 +64,13 @@ fancygit_prompt_builder() {
has_unpushed_commits=""
fi

prompt_user="${user_at_host}\\u@\\h ${user_at_host_end}"
if fg_show_user_at_machine
then
user_at_host="${white}${bg_dark_gray_01}${bold}"
user_at_host_end="${bold_none}${bg_none}${s_darkgray01_bgdarkgray}"
prompt_user="${user_at_host}\\u@\\h ${user_at_host_end}"
fi

prompt_symbol="\n${user_symbol}\$${user_symbol_end}"

if ! [ -z ${VIRTUAL_ENV} ]
Expand Down
7 changes: 6 additions & 1 deletion prompt_styles/dark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ fancygit_prompt_builder() {
branch_end="${bg_none}${none}${bold_none}${s_white}"
local venv=""
local path_sign=""
local prompt_user=""

# Building prompt
if [ "$branch_status" != "" ]
Expand Down Expand Up @@ -63,7 +64,11 @@ fancygit_prompt_builder() {
has_unpushed_commits=""
fi

prompt_user="${user_at_host}\\u@\\h ${user_at_host_end}"
if fg_show_user_at_machine
then
prompt_user="${user_at_host}\\u@\\h ${user_at_host_end}"
fi

prompt_symbol="${user_symbol} \$ ${user_symbol_end}"

if ! [ -z ${VIRTUAL_ENV} ]
Expand Down
7 changes: 6 additions & 1 deletion prompt_styles/default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ fancygit_prompt_builder() {
branch_end="${bg_none}${none}${bold_none}${s_white}"
local venv=""
local path_sign=""
local prompt_user=""

# Building prompt
if [ "$branch_status" != "" ]
Expand Down Expand Up @@ -63,7 +64,11 @@ fancygit_prompt_builder() {
has_unpushed_commits=""
fi

prompt_user="${user_at_host}\\u@\\h ${user_at_host_end}"
if fg_show_user_at_machine
then
prompt_user="${user_at_host}\\u@\\h ${user_at_host_end}"
fi

prompt_symbol="${user_symbol} \$ ${user_symbol_end}"

if ! [ -z ${VIRTUAL_ENV} ]
Expand Down
11 changes: 8 additions & 3 deletions prompt_styles/fancy-double-line.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ fancygit_prompt_builder() {
. ~/.fancy-git/update_checker.sh && _fancygit_update_checker

# Prompt style
user_at_host="${white}${bg_dark_gray}${bold}"
user_at_host_end="${bold_none}${bg_none}${s_darkgray_bgblue}"
path="${bg_blue}${white}${bold}"
path_git="${bg_blue}${white} ${is_git_repo} ${bold}"
path_end="${none}${bold_none}"
Expand All @@ -23,6 +21,7 @@ fancygit_prompt_builder() {
branch_end="${bg_none}${none}${bold_none}${s_white}"
local venv=""
local path_sign=""
local prompt_user=""

# Building prompt
if [ "$branch_status" != "" ]
Expand Down Expand Up @@ -63,7 +62,13 @@ fancygit_prompt_builder() {
has_unpushed_commits=""
fi

prompt_user="${user_at_host}\\u@\\h ${user_at_host_end}"
if fg_show_user_at_machine
then
user_at_host="${white}${bg_dark_gray}${bold}"
user_at_host_end="${bold_none}${bg_none}${s_darkgray_bgblue}"
prompt_user="${user_at_host}\\u@\\h ${user_at_host_end}"
fi

prompt_symbol="\n${user_symbol}\$${user_symbol_end}"

if ! [ -z ${VIRTUAL_ENV} ]
Expand Down
8 changes: 7 additions & 1 deletion prompt_styles/human-dark-single-line.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ fancygit_prompt_builder() {
local host="\h"
local where="\W"
local venv=""
local user_at_host=""

if fg_show_full_path
then
Expand All @@ -43,7 +44,12 @@ fancygit_prompt_builder() {
branch_name=" ${red}on${none} ${orange}$branch_name${none}"
fi

PS1="${bold}${venv}${user} ${at} ${host} ${in} $where$branch_name$(fg_branch_status 1) ${bold_none}\$ "
if fg_show_user_at_machine
then
user_at_host="${user} ${at} ${host} ${in} "
fi

PS1="${bold}${venv}${user_at_host}$where$branch_name$(fg_branch_status 1) ${bold_none}\$ "
}

PROMPT_COMMAND="fancygit_prompt_builder"
8 changes: 7 additions & 1 deletion prompt_styles/human-dark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ fancygit_prompt_builder() {
local host="\h"
local where="\W"
local venv=""
local user_at_host=""

if fg_show_full_path
then
Expand All @@ -43,7 +44,12 @@ fancygit_prompt_builder() {
branch_name="${on} ${orange}$branch_name${none}"
fi

PS1="${bold}${venv}${user} ${at} ${host} ${in} $where $branch_name$(fg_branch_status 1)${bold_none}\n\$ "
if fg_show_user_at_machine
then
user_at_host="${user} ${at} ${host} ${in} "
fi

PS1="${bold}${venv}${user_at_host}$where $branch_name$(fg_branch_status 1)${bold_none}\n\$ "
}

PROMPT_COMMAND="fancygit_prompt_builder"
8 changes: 7 additions & 1 deletion prompt_styles/human-single-line.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ fancygit_prompt_builder() {
local host="${light_yellow}\h${none}"
local where="${light_green}\w${none}"
local venv=""
local user_at_host=""

if ! fg_show_full_path
then
Expand All @@ -40,7 +41,12 @@ fancygit_prompt_builder() {
branch_name=" on ${light_magenta}$branch_name${none}"
fi

PS1="${bold}${venv}${user} at ${host} in $where$branch_name$(fg_branch_status 1) ${bold_none}\$ "
if fg_show_user_at_machine
then
user_at_host="${user} at ${host} in "
fi

PS1="${bold}${venv}${user_at_host}$where$branch_name$(fg_branch_status 1) ${bold_none}\$ "
}

PROMPT_COMMAND="fancygit_prompt_builder"
Expand Down
8 changes: 7 additions & 1 deletion prompt_styles/human.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ fancygit_prompt_builder() {
local host="${light_yellow}\h${none}"
local where="${light_green}\w${none}"
local venv=""
local user_at_host=""

if ! fg_show_full_path
then
Expand All @@ -40,7 +41,12 @@ fancygit_prompt_builder() {
branch_name="on ${light_magenta}$branch_name${none}"
fi

PS1="${bold}${venv}${user} at ${host} in $where $branch_name$(fg_branch_status 1)${bold_none}\n\$ "
if fg_show_user_at_machine
then
user_at_host="${user} at ${host} in "
fi

PS1="${bold}${venv}${user_at_host}$where $branch_name$(fg_branch_status 1)${bold_none}\n\$ "
}

PROMPT_COMMAND="fancygit_prompt_builder"
Expand Down
11 changes: 8 additions & 3 deletions prompt_styles/light-double-line.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ fancygit_prompt_builder() {
. ~/.fancy-git/update_checker.sh && _fancygit_update_checker

# Prompt style
user_at_host="${black}${bg_white}${bold}"
user_at_host_end="${bold_none}${bg_none}${s_white_bglightgray}"
user_symbol="${bg_light_gray}${bold}${black}"
user_symbol_end="${none}${bold_none}${bg_none}${s_lightgray}"
path="${bg_light_gray}${black}${bold}"
Expand All @@ -23,6 +21,7 @@ fancygit_prompt_builder() {
branch_end="${bg_none}${none}${bold_none}${s_white}"
local venv=""
local path_sign=""
local prompt_user=""

# Building prompt
if [ "$branch_status" != "" ]
Expand Down Expand Up @@ -63,7 +62,13 @@ fancygit_prompt_builder() {
has_unpushed_commits=""
fi

prompt_user="${user_at_host}\\u@\\h ${user_at_host_end}"
if fg_show_user_at_machine
then
user_at_host="${black}${bg_white}${bold}"
user_at_host_end="${bold_none}${bg_none}${s_white_bglightgray}"
prompt_user="${user_at_host}\\u@\\h ${user_at_host_end}"
fi

prompt_symbol="\n${user_symbol}\$${user_symbol_end}"

if ! [ -z ${VIRTUAL_ENV} ]
Expand Down
7 changes: 6 additions & 1 deletion prompt_styles/light.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ fancygit_prompt_builder() {
branch_end="${bg_none}${none}${bold_none}${s_white}"
local venv=""
local path_sign=""
local prompt_user=""

# Building prompt
if [ "$branch_status" != "" ]
Expand Down Expand Up @@ -63,7 +64,11 @@ fancygit_prompt_builder() {
has_unpushed_commits=""
fi

prompt_user="${user_at_host}\\u@\\h ${user_at_host_end}"
if fg_show_user_at_machine
then
prompt_user="${user_at_host}\\u@\\h ${user_at_host_end}"
fi

prompt_symbol="${user_symbol} \$ ${user_symbol_end}"

if ! [ -z ${VIRTUAL_ENV} ]
Expand Down
Loading

0 comments on commit d08b3ff

Please sign in to comment.