diff --git a/alias_functions/ga.sh b/alias_functions/ga.sh index d42b4c2..c20e14d 100644 --- a/alias_functions/ga.sh +++ b/alias_functions/ga.sh @@ -1,11 +1,9 @@ #!/bin/bash # -# Author: Diogo Alexsander Cavilha -# Date: 03.13.2017 +# Author: Diogo Alexsander Cavilha +# Date: 03.13.2017 # -# ADDING FILES -# -# Adds files in order to commit and shows git status +# git add git add $* && \ clear && \ diff --git a/alias_functions/gaa.sh b/alias_functions/gaa.sh index b1adeac..7821b2a 100644 --- a/alias_functions/gaa.sh +++ b/alias_functions/gaa.sh @@ -1,11 +1,9 @@ #!/bin/bash # -# Author: Diogo Alexsander Cavilha -# Date: 03.13.2017 +# Author: Diogo Alexsander Cavilha +# Date: 03.13.2017 # -# ADDING ALL FILES -# -# Adds all files in order to commit and shows git status +# git add --all git add --all && \ clear && \ diff --git a/alias_functions/gck.sh b/alias_functions/gck.sh index 475282a..d6e98e1 100644 --- a/alias_functions/gck.sh +++ b/alias_functions/gck.sh @@ -1,11 +1,9 @@ #!/bin/bash # -# Author: Diogo Alexsander Cavilha -# Date: 03.16.2017 +# Author: Diogo Alexsander Cavilha +# Date: 03.16.2017 # -# CHECKOUT FILES -# -# Checkout files and shows git status +# git checkout -- git checkout -- $* && \ clear && \ diff --git a/alias_functions/gckbt.sh b/alias_functions/gckbt.sh index 584508b..c8d085c 100644 --- a/alias_functions/gckbt.sh +++ b/alias_functions/gckbt.sh @@ -1,11 +1,9 @@ #!/bin/bash # -# Author: Diogo Alexsander Cavilha -# Date: 07.05.2016 +# Author: Diogo Alexsander Cavilha +# Date: 07.05.2016 # -# BRANCH CHACKOUT -# -# It forces the checkout of a branch +# git checkout --track origin/ -branch_name=$1 +branch_name="$1" git checkout --track origin/$branch_name diff --git a/alias_functions/gd.sh b/alias_functions/gd.sh index 03f9c02..67a619f 100644 --- a/alias_functions/gd.sh +++ b/alias_functions/gd.sh @@ -1,16 +1,13 @@ #!/bin/bash # -# Author: Diogo Alexsander Cavilha -# Date: 11.28.2017 +# Author: Diogo Alexsander Cavilha +# Date: 11.28.2017 # -# GIT DIFF -# -# Show changes of a file and suggests to add it +# git diff clear -if [ "$1" = "" ] -then +if [ "$1" = "" ]; then git diff return fi @@ -20,8 +17,7 @@ git diff "$1" echo "" read -p " Add this file to commit? [y/N]: " r -if [ "$r" = "y" ] -then +if [ "$r" = "y" ]; then git add "$1" fi diff --git a/alias_functions/gg.sh b/alias_functions/gg.sh index 281f393..a18b555 100644 --- a/alias_functions/gg.sh +++ b/alias_functions/gg.sh @@ -1,15 +1,15 @@ #!/bin/bash # -# Author: Diogo Alexsander Cavilha -# Date: 04.21.2018 +# Author: Diogo Alexsander Cavilha +# Date: 04.21.2018 # -# ADD, COMMIT, PUSH -# -# A shortcut for a common sequence in order to push changes +# git add --all +# git commit -m +# git push origin -branch=$(git branch | grep -oP '(?<=\* ).*') -msg=$1 +branch_name=$(git branch | grep -oP '(?<=\* ).*') +msg="$1" git add --all && \ -git commit -m "$1" && \ -git push origin $branch +git commit -m "$msg" && \ +git push origin $branch_name diff --git a/alias_functions/glp.sh b/alias_functions/glp.sh index 14f44a6..7ae4101 100644 --- a/alias_functions/glp.sh +++ b/alias_functions/glp.sh @@ -1,11 +1,9 @@ #!/bin/bash # -# Author: Diogo Alexsander Cavilha -# Date: 09.01.2016 +# Author: Diogo Alexsander Cavilha +# Date: 09.01.2016 # -# GIT LOG -# -# Perform a pretty git log +# It performs a pretty git log. logCmd="git log --date=short --pretty=format:'%C(bold yellow)%h%C(reset) %C(white)%ad %C(bold blue)(%ar)%C(reset) %C(bold green)%an %C(reset)%C(cyan)%s%C(reset)'" diff --git a/alias_functions/gpl.sh b/alias_functions/gpl.sh index 5b248bf..9a8d174 100644 --- a/alias_functions/gpl.sh +++ b/alias_functions/gpl.sh @@ -1,4 +1,9 @@ #!/bin/bash +# +# Author: Diogo Alexsander Cavilha +# Date: 04.01.2016 +# +# git pull . ~/.fancy-git/random_messages.sh diff --git a/alias_functions/gplo.sh b/alias_functions/gplo.sh index e457c36..332b53b 100644 --- a/alias_functions/gplo.sh +++ b/alias_functions/gplo.sh @@ -1,12 +1,17 @@ #!/bin/bash +# +# Author: Diogo Alexsander Cavilha +# Date: 04.01.2016 +# +# git pull origin . ~/.fancy-git/random_messages.sh run() { - local branch - branch="$1" + local branch_name + branch_name="$1" - git pull origin $branch + git pull origin $branch_name _fancygit_after_pulling_random_message } diff --git a/alias_functions/gplob.sh b/alias_functions/gplob.sh index 3f9ea25..e5450f4 100644 --- a/alias_functions/gplob.sh +++ b/alias_functions/gplob.sh @@ -1,12 +1,17 @@ #!/bin/bash +# +# Author: Diogo Alexsander Cavilha +# Date: 04.01.2016 +# +# git pull origin . ~/.fancy-git/random_messages.sh run() { - local branch - branch=$(git branch | grep -oP '(?<=\* ).*') + local branch_name + branch_name=$(git branch | grep -oP '(?<=\* ).*') - git pull origin $branch + git pull origin $branch_name _fancygit_after_pulling_random_message } diff --git a/alias_functions/gpsob.sh b/alias_functions/gpsob.sh index 11b9eff..33485a3 100644 --- a/alias_functions/gpsob.sh +++ b/alias_functions/gpsob.sh @@ -1,5 +1,10 @@ #!/bin/bash +# +# Author: Diogo Alexsander Cavilha +# Date: 04.01.2016 +# +# git push origin -branch=$(git branch | grep -oP '(?<=\* ).*') +branch_name=$(git branch | grep -oP '(?<=\* ).*') -git push origin $branch +git push origin $branch_name diff --git a/alias_functions/grb.sh b/alias_functions/grb.sh index 5385ae5..d6284e9 100644 --- a/alias_functions/grb.sh +++ b/alias_functions/grb.sh @@ -1,12 +1,12 @@ #!/bin/bash # -# Author: Diogo Alexsander Cavilha -# Date: 05.24.2016 +# Author: Diogo Alexsander Cavilha +# Date: 05.24.2016 # -# BRANCH RENAMING +# It renames a branch locally. # -# Rename branch locally +# git branch -m -new_branch_name=$1 +new_branch_name="$1" git branch -m $new_branch_name diff --git a/alias_functions/grba.sh b/alias_functions/grba.sh index f75c0d4..eae83ad 100644 --- a/alias_functions/grba.sh +++ b/alias_functions/grba.sh @@ -1,15 +1,17 @@ #!/bin/bash # -# Author: Diogo Alexsander Cavilha -# Date: 05.24.2016 +# Author: Diogo Alexsander Cavilha +# Date: 05.24.2016 # -# BRANCH RENAMING +# Rename branch locally. +# Delete the old branch. +# Push the new branch, set local branch to track the new remote branch. # -# Rename branch locally -# Delete the old branch -# Push the new branch, set local branch to track the new remote +# git branch -m +# git push origin : +# git push origin -new_branch_name=$1 +new_branch_name="$1" old_branch_name=$(git branch | grep -oP '(?<=\* ).*') git branch -m $new_branch_name diff --git a/alias_functions/gsta.sh b/alias_functions/gsta.sh index 9b70c87..5a30223 100644 --- a/alias_functions/gsta.sh +++ b/alias_functions/gsta.sh @@ -1,11 +1,9 @@ #!/bin/bash # -# Author: Diogo Alexsander Cavilha -# Date: 04.19.2018 +# Author: Diogo Alexsander Cavilha +# Date: 04.19.2018 # -# APPLY STASH -# -# It applies a stash +# git stash apply stash@{} -stash_id=$1 +stash_id="$1" git stash apply stash@{$stash_id} diff --git a/alias_functions/gstd.sh b/alias_functions/gstd.sh index c66769b..5813f56 100644 --- a/alias_functions/gstd.sh +++ b/alias_functions/gstd.sh @@ -1,11 +1,9 @@ #!/bin/bash # -# Author: Diogo Alexsander Cavilha -# Date: 04.19.2018 +# Author: Diogo Alexsander Cavilha +# Date: 04.19.2018 # -# DROP STASH -# -# It drops a stash +# git stash drop stash@{} -stash_id=$1 +stash_id="$1" git stash drop stash@{$stash_id} diff --git a/alias_functions/gstw.sh b/alias_functions/gstw.sh index 2e9ca2c..a603a72 100644 --- a/alias_functions/gstw.sh +++ b/alias_functions/gstw.sh @@ -1,11 +1,9 @@ #!/bin/bash # -# Author: Diogo Alexsander Cavilha -# Date: 04.19.2018 +# Author: Diogo Alexsander Cavilha +# Date: 04.19.2018 # -# SHOW STASH CHANGES -# -# It shows a stash changes +# git stash show stash@{} -stash_id=$1 +stash_id="$1" git stash show stash@{$stash_id} diff --git a/alias_functions/gurl.sh b/alias_functions/gurl.sh index e1daa07..5d56e2b 100644 --- a/alias_functions/gurl.sh +++ b/alias_functions/gurl.sh @@ -1,7 +1,10 @@ #!/bin/bash - -gurl=$(git config --list | grep -oE 'https://.*|git@.*') +# +# Author: Diogo Alexsander Cavilha +# Date: 03.04.2016 +# +# git remote -v echo "" -echo " $gurl" +git remote -v echo "" diff --git a/alias_functions/guser.sh b/alias_functions/guser.sh index 63f0640..f89932d 100644 --- a/alias_functions/guser.sh +++ b/alias_functions/guser.sh @@ -1,4 +1,9 @@ #!/bin/bash +# +# Author: Diogo Alexsander Cavilha +# Date: 03.18.2016 +# +# It shows the user name and email. guser=$(git config --list | grep -oP '(?<=user.name=).*') gemail=$(git config --list | grep -oP '(?<=user.email=).*') diff --git a/commands.sh b/commands.sh index d86bf09..b00abc6 100755 --- a/commands.sh +++ b/commands.sh @@ -1,4 +1,9 @@ #!/bin/bash +# +# Author: Diogo Alexsander Cavilha +# Date: 03.02.2016 +# +# Commands manager. . ~/.fancy-git/version.sh @@ -19,8 +24,7 @@ fg_update() { current_date=$(date +%Y-%m-%d) - if [ ! -f ~/.fancy-git/last_update_at ] - then + if [ ! -f ~/.fancy-git/last_update_at ]; then touch -f ~/.fancy-git/last_update_at fi @@ -69,25 +73,21 @@ fg_update_checker() { current_date=$(date +%Y-%m-%d) last_update_at=$(cat ~/.fancy-git/last_update_at) - if [ ! -f ~/.fancy-git/last_update_at ] - then + if [ ! -f ~/.fancy-git/last_update_at ]; then touch -f ~/.fancy-git/last_update_at fi - if [ "$manual_update" = "yes" ] - then + if [ "$manual_update" = "yes" ]; then fg_update return fi - if [ "$current_date" = "$last_update_at" ] - then + if [ "$current_date" = "$last_update_at" ]; then return fi branch_name=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/') - if [ "$branch_name" = "" ] - then + if [ "$branch_name" = "" ]; then return fi @@ -97,15 +97,13 @@ fg_update_checker() { updates=$(cd ~/.fancy-git && git diff origin/master) option="n" - if [ "$updates" != "" ] - then + if [ "$updates" != "" ]; then echo "" echo " Hey! A new Fancy Git update has been released!" read -p " Would you like to update it? [Y/n]: " option fi - if [ "$option" = "y" ] - then + if [ "$option" = "y" ]; then echo "" fg_update fi @@ -114,7 +112,7 @@ fg_update_checker() { cd "$current_dir" || return } -case $1 in +case "$1" in "-h"|"--help") fg_script_help;; "-v"|"--version") fg_show_version;; "update") fg_update_checker;; diff --git a/config b/config.sh similarity index 97% rename from config rename to config.sh index b4f5498..a930548 100644 --- a/config +++ b/config.sh @@ -1,3 +1,10 @@ +#!/bin/bash +# +# Author: Diogo Alexsander Cavilha +# Date: 06.06.2018 +# +# Configuration file. + # ASCII local separator local branch_icon diff --git a/help.sh b/help.sh index 6366d03..b2138ce 100644 --- a/help.sh +++ b/help.sh @@ -1,4 +1,9 @@ #!/bin/bash +# +# Author: Diogo Alexsander Cavilha +# Date: 11.18.2017 +# +# It prints the help text. . ~/.fancy-git/version.sh diff --git a/install.sh b/install.sh index d5db488..ed853fc 100755 --- a/install.sh +++ b/install.sh @@ -1,7 +1,7 @@ #!/bin/bash # # Author: Diogo Alexsander Cavilha -# Date: 11.16.2017 +# Date: 11.16.2017 # # Fancygit installation script. @@ -9,8 +9,7 @@ fg_os=$(uname) git clone https://github.com/diogocavilha/fancy-git.git ~/.fancy-git -if [ "$fg_os" = "Linux" ] -then +if [ "$fg_os" = "Linux" ]; then cp -f ~/.bashrc ~/.bashrc.backup echo "" >> ~/.bashrc echo ". ~/.fancy-git/prompt.sh" >> ~/.bashrc @@ -23,8 +22,7 @@ then echo "$current_date" > ~/.fancy-git/last_update_at fi -if [ "$fg_os" = "Darwin" ] -then +if [ "$fg_os" = "Darwin" ]; then cp -f ~/.bash_profile ~/.bash_profile.backup echo "" >> ~/.bash_profile echo ". ~/.fancy-git/prompt.sh" >> ~/.bash_profile diff --git a/prompt.sh b/prompt.sh index 504d32c..a9fa174 100644 --- a/prompt.sh +++ b/prompt.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# Author: Diogo Alexsander Cavilha -# Date: 06.11.2018 +# Author: Diogo Alexsander Cavilha +# Date: 06.11.2018 # # Changes de prompt by loading the style configured in ~/.fancygit/mode file. diff --git a/prompt_styles/dark-double-line.sh b/prompt_styles/dark-double-line.sh index ff61ca7..339034b 100644 --- a/prompt_styles/dark-double-line.sh +++ b/prompt_styles/dark-double-line.sh @@ -1,9 +1,14 @@ +#!/bin/bash +# +# Author: Diogo Alexsander Cavilha +# Date: 12.02.2018 + . ~/.fancy-git/aliases . ~/.fancy-git/fancygit-completion . ~/.fancy-git/commands.sh fancygit_prompt_builder() { - . ~/.fancy-git/config + . ~/.fancy-git/config.sh . ~/.fancy-git/update_checker.sh && _fancygit_update_checker # Prompt style diff --git a/prompt_styles/dark.sh b/prompt_styles/dark.sh index b4646ec..16d2e99 100644 --- a/prompt_styles/dark.sh +++ b/prompt_styles/dark.sh @@ -1,9 +1,14 @@ +#!/bin/bash +# +# Author: Diogo Alexsander Cavilha +# Date: 12.01.2018 + . ~/.fancy-git/aliases . ~/.fancy-git/fancygit-completion . ~/.fancy-git/commands.sh fancygit_prompt_builder() { - . ~/.fancy-git/config + . ~/.fancy-git/config.sh . ~/.fancy-git/update_checker.sh && _fancygit_update_checker # Prompt style diff --git a/prompt_styles/default.sh b/prompt_styles/default.sh index b98e69b..ef851e2 100644 --- a/prompt_styles/default.sh +++ b/prompt_styles/default.sh @@ -1,9 +1,14 @@ +#!/bin/bash +# +# Author: Diogo Alexsander Cavilha +# Date: 06.08.2018 + . ~/.fancy-git/aliases . ~/.fancy-git/fancygit-completion . ~/.fancy-git/commands.sh fancygit_prompt_builder() { - . ~/.fancy-git/config + . ~/.fancy-git/config.sh . ~/.fancy-git/update_checker.sh && _fancygit_update_checker # Prompt style diff --git a/prompt_styles/fancy-double-line.sh b/prompt_styles/fancy-double-line.sh index d146b63..039c731 100644 --- a/prompt_styles/fancy-double-line.sh +++ b/prompt_styles/fancy-double-line.sh @@ -1,9 +1,14 @@ +#!/bin/bash +# +# Author: Diogo Alexsander Cavilha +# Date: 06.06.2018 + . ~/.fancy-git/aliases . ~/.fancy-git/fancygit-completion . ~/.fancy-git/commands.sh fancygit_prompt_builder() { - . ~/.fancy-git/config + . ~/.fancy-git/config.sh . ~/.fancy-git/update_checker.sh && _fancygit_update_checker # Prompt style diff --git a/prompt_styles/human.sh b/prompt_styles/human.sh index 66407c8..becb50e 100644 --- a/prompt_styles/human.sh +++ b/prompt_styles/human.sh @@ -1,9 +1,14 @@ +#!/bin/bash +# +# Author: Diogo Alexsander Cavilha +# Date: 06.11.2018 + . ~/.fancy-git/aliases . ~/.fancy-git/fancygit-completion . ~/.fancy-git/commands.sh fg_branch_status() { - . ~/.fancy-git/config + . ~/.fancy-git/config.sh local branch_icon local branch_status @@ -40,7 +45,7 @@ fg_branch_name() { } fancygit_prompt_builder() { - . ~/.fancy-git/config + . ~/.fancy-git/config.sh . ~/.fancy-git/update_checker.sh && _fancygit_update_checker local user diff --git a/prompt_styles/light-double-line.sh b/prompt_styles/light-double-line.sh index d31b656..8742705 100644 --- a/prompt_styles/light-double-line.sh +++ b/prompt_styles/light-double-line.sh @@ -1,9 +1,14 @@ +#!/bin/bash +# +# Author: Diogo Alexsander Cavilha +# Date: 12.04.2018 + . ~/.fancy-git/aliases . ~/.fancy-git/fancygit-completion . ~/.fancy-git/commands.sh fancygit_prompt_builder() { - . ~/.fancy-git/config + . ~/.fancy-git/config.sh . ~/.fancy-git/update_checker.sh && _fancygit_update_checker # Prompt style diff --git a/prompt_styles/light.sh b/prompt_styles/light.sh index 78ae19c..9a0502f 100644 --- a/prompt_styles/light.sh +++ b/prompt_styles/light.sh @@ -1,9 +1,14 @@ +#!/bin/bash +# +# Author: Diogo Alexsander Cavilha +# Date: 12.04.2018 + . ~/.fancy-git/aliases . ~/.fancy-git/fancygit-completion . ~/.fancy-git/commands.sh fancygit_prompt_builder() { - . ~/.fancy-git/config + . ~/.fancy-git/config.sh . ~/.fancy-git/update_checker.sh && _fancygit_update_checker # Prompt style diff --git a/prompt_styles/simple-double-line.sh b/prompt_styles/simple-double-line.sh index e6c2225..10b1087 100644 --- a/prompt_styles/simple-double-line.sh +++ b/prompt_styles/simple-double-line.sh @@ -1,9 +1,14 @@ +#!/bin/bash +# +# Author: Diogo Alexsander Cavilha +# Date: 06.12.2018 + . ~/.fancy-git/aliases . ~/.fancy-git/fancygit-completion . ~/.fancy-git/commands.sh fg_branch_status() { - . ~/.fancy-git/config + . ~/.fancy-git/config.sh local info info="" @@ -66,7 +71,7 @@ fg_branch_name() { } fancygit_prompt_builder() { - . ~/.fancy-git/config + . ~/.fancy-git/config.sh . ~/.fancy-git/update_checker.sh && _fancygit_update_checker local user diff --git a/prompt_styles/simple.sh b/prompt_styles/simple.sh index 8b97028..e9aafeb 100644 --- a/prompt_styles/simple.sh +++ b/prompt_styles/simple.sh @@ -1,9 +1,14 @@ +#!/bin/bash +# +# Author: Diogo Alexsander Cavilha +# Date: 06.06.2018 + . ~/.fancy-git/aliases . ~/.fancy-git/fancygit-completion . ~/.fancy-git/commands.sh fg_branch_status() { - . ~/.fancy-git/config + . ~/.fancy-git/config.sh local info info="" @@ -66,7 +71,7 @@ fg_branch_name() { } fancygit_prompt_builder() { - . ~/.fancy-git/config + . ~/.fancy-git/config.sh . ~/.fancy-git/update_checker.sh && _fancygit_update_checker local user diff --git a/random_messages.sh b/random_messages.sh index 0299526..780df7e 100644 --- a/random_messages.sh +++ b/random_messages.sh @@ -1,9 +1,12 @@ #!/bin/bash # # Author: Diogo Alexsander Cavilha -# Date: 11.27.2018 +# Date: 11.27.2018 +# +# It prints a random funny message after pulling. _fancygit_after_pulling_random_message() { + local list_size local messages local option diff --git a/uninstall.sh b/uninstall.sh index 86fbfff..86ed18f 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -1,21 +1,18 @@ #!/bin/bash # # Author: Diogo Alexsander Cavilha -# Date: 11.16.2017 +# Date: 11.16.2017 # # Fancygit uninstaller. fg_os=$(uname) -if [ "$fg_os" = "Linux" ] -then +if [ "$fg_os" = "Linux" ]; then sed -i '/. ~\/.fancy-git\/prompt\-changer.sh/d' ~/.bashrc fi -if [ "$fg_os" = "Darwin" ] -then +if [ "$fg_os" = "Darwin" ]; then sed -i '' '/. ~\/.fancy-git\/prompt\-changer.sh/d' ~/.bashrc fi rm -rf ~/.fancy-git - diff --git a/update_checker.sh b/update_checker.sh index bd1b1d7..07cf331 100644 --- a/update_checker.sh +++ b/update_checker.sh @@ -1,7 +1,7 @@ #!/bin/bash # # Author: Diogo Alexsander Cavilha -# Date: 12.05.2018 +# Date: 12.05.2018 _fancygit_update_checker() { local current_date @@ -9,15 +9,13 @@ _fancygit_update_checker() { current_date=$(date +%Y-%m-%d) - if [ ! -f ~/.fancy-git/last_update_at ] - then + if [ ! -f ~/.fancy-git/last_update_at ]; then touch -f ~/.fancy-git/last_update_at fi last_update_at=$(cat ~/.fancy-git/last_update_at) - if [ "$current_date" != "$last_update_at" ] - then + if [ "$current_date" != "$last_update_at" ]; then fg_update_checker "no" fi } diff --git a/version.sh b/version.sh index ab955d0..d4f990f 100644 --- a/version.sh +++ b/version.sh @@ -1,6 +1,6 @@ #!/bin/bash # # Author: Diogo Alexsander Cavilha -# Date: 11.17.2017 +# Date: 11.17.2017 FANCYGIT_VERSION="5.2.3"