Skip to content

Commit

Permalink
Fix code style according to ShellCheck
Browse files Browse the repository at this point in the history
Fix code style according to ShellCheck
  • Loading branch information
diogocavilha authored Mar 1, 2022
2 parents c6dc34c + eefa967 commit 1a9054c
Show file tree
Hide file tree
Showing 37 changed files with 109 additions and 88 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Build

on:
push:
branches:
- '*'
pull_request:
branches:
- master

jobs:
shellcheck:
name: ShellCheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run ShellCheck ...
uses: ludeeus/action-shellcheck@master
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

> Any trouble, please visit the [troubleshooting page](https://github.com/diogocavilha/fancy-git/blob/master/TROUBLESHOOTING.md)
## v7.1.6

- Fix code stye according to ShellCheck rules.
- Remove commands to enable/disable tag name.
- Fix minor bugs.

## v7.1.5

- Update screenshots on readme file.
Expand Down
14 changes: 7 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ Please use [GitHub Issues](https://github.com/diogocavilha/fancy-git/issues) to
Please follow these steps:

1. Give this project a star. :vulcan_salute:
2. **Fork** the project.
3. **Clone** the project to your own machine.
2. Fork the project.
3. Clone the project to your own machine.
4. Create a branch. (`git checkout -b your-branch-name` or `gcb your-branch-name`).
- Don't forget to change the `version.sh` file for creating the new version.
- Don't forget to update the `CHANGELOG.md` file by adding some topics containing briefs of the changes you did. As you can see, there are plenty of entries there, so it's quite simple to create yours by following some example.
6. **Commit** changes to the branch you've just created.
7. **Push** your work back up to your fork.
8. Submit a **Pull Request** and take a coffee (or even better, you could take a coffee before it).
- Don't forget to change the **version.sh** file for creating the new version.
- Don't forget to update the **CHANGELOG.md** file by adding some topics containing briefs of the changes you did. As you can see, there are plenty of entries there, so it's quite simple to create yours by following some example.
6. Commit changes to the branch you've just created.
7. Push your work back up to your fork. (`git push origin your-branch-name`).
8. Submit a Pull Request and take a coffee (or even better, you could take a coffee before it).
11 changes: 2 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
[![All Contributors](https://img.shields.io/badge/all_contributors-13-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

[![Build](https://github.com/diogocavilha/fancy-git/actions/workflows/main.yml/badge.svg)](https://github.com/diogocavilha/fancy-git/actions/workflows/main.yml)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
[![made-with-bash](https://img.shields.io/badge/Made%20with-Bash-1f425f.svg)](https://www.gnu.org/software/bash/)
[![MIT Licence](https://badges.frapsoft.com/os/mit/mit.svg?v=103)](https://github.com/diogocavilha/fancy-git/blob/master/LICENSE)
Expand All @@ -12,7 +13,7 @@

FancyGit is a tool which works for Linux and MAC OS, that changes the terminal prompt in order to show you a few cool git informations when you're working on a git repo. It'll always keep you informed about the current branch status.

:rocket: [Guidelines for contributing](https://github.com/diogocavilha/fancy-git/blob/master/CONTRIBUTING.md) | :monocle_face: [Changelog](https://github.com/diogocavilha/fancy-git/blob/master/CHANGELOG.md) | :hammer: [Troubleshooting](https://github.com/diogocavilha/fancy-git/blob/master/TROUBLESHOOTING.md)
:rocket: [Contributing](https://github.com/diogocavilha/fancy-git/blob/master/CONTRIBUTING.md) | :monocle_face: [Changelog](https://github.com/diogocavilha/fancy-git/blob/master/CHANGELOG.md) | :hammer: [Troubleshooting](https://github.com/diogocavilha/fancy-git/blob/master/TROUBLESHOOTING.md)

# :cupid: Installing

Expand Down Expand Up @@ -284,14 +285,6 @@ FANCYGIT_ICON_HAS_ADDED_FILES
FANCYGIT_ICON_HAS_UNPUSHED_COMMITS
```

# :pick: Troubleshooting

[Troubleshooting page](https://github.com/diogocavilha/fancy-git/blob/master/TROUBLESHOOTING.md)

# :rocket: Contributing

[Guidelines for contributing](https://github.com/diogocavilha/fancy-git/blob/master/CONTRIBUTING.md#rocket-contributing-to-fancygit)

# Contributors ✨

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
Expand Down
20 changes: 10 additions & 10 deletions TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
# :pick: Troubleshooting

- **Double line problem and general weird behavior**
**System:** Linux | MAC OS - [reported issue](https://github.com/diogocavilha/fancy-git/issues/63).
### :bug: Double line problem and general weird behavior
**System:** Linux/MAC OS - [reported issue](https://github.com/diogocavilha/fancy-git/issues/63).
If you have a few more changes in your `.bashrc` file, be aware that `. ~/.fancy-git/prompt.sh` must be the last line of it.

- **Problems with Konsole Terminal**
### :bug: Problems with Konsole Terminal
**System:** Linux (with KDE) - [reported issue](https://bugs.kde.org/show_bug.cgi?id=272443).
Maybe you could face an issue related to icons rendering when using `Konsole` on version `18.12.1`.
An idea here is to update the `Konsole` to its latest version. So the problem might be solved ;)
Maybe you could face an issue related to icons rendering when using **Konsole** on version **18.12.1**.
An idea here is to update the **Konsole** to its latest version. So the problem might be solved ;)

- **Problems with `grep` command**
### :bug: Problems with `grep` command
**System:** MAC OS - [reported issue](https://github.com/diogocavilha/fancy-git/issues/47).
As you can read there, the solution found is to `brew install grep` and adding `/usr/local/opt/grep/libexec/gnubin` to the PATH ahead of `/usr/bin`.

- **Problems with `sed` command**
### :bug: Problems with `sed` command
**System:** MAC OS - [reported issue](https://github.com/diogocavilha/fancy-git/issues/47).
You can follow the steps as you did for `grep`, but this time, installing `gnu-sed` by running `brew install gnu-sed`.

- **Problems upgrading from v6.0.5 to a newest version**
### :bug: Problems upgrading from v6.0.5 to a newest version
If you've just upgraded it from v6.0.5 to a newest version, you might have seeing an error, because FancyGit can't find its configuration file.
You can fix that just by running `fancygit --config-reset`. It'll create a default configuration file and reset the FancyGit state.
You can fix that just by running `fancygit --reset`. It'll create a default configuration file and reset the FancyGit state.

- **Icons rendering**
### :bug: Icons rendering
**System:** Windows (WSL) - [reported issue](https://github.com/diogocavilha/fancy-git/issues/70).
If you use Windows terminal, under WSL system, Fancy Git will not render icons and symbols properly.
In this case, you can use [this font](https://github.com/microsoft/cascadia-code). This might solve the problem.
2 changes: 1 addition & 1 deletion alias_functions/ga.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
#
# git add

git add $* && \
git add "$*" && \
clear && \
git status
2 changes: 1 addition & 1 deletion alias_functions/gck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
#
# git checkout --

git checkout -- $* && \
git checkout -- "$*" && \
clear && \
git status
2 changes: 1 addition & 1 deletion alias_functions/gckbt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
# git checkout --track origin/<current_branch_name>

branch_name="$1"
git checkout --track origin/$branch_name
git checkout --track origin/"$branch_name"
4 changes: 2 additions & 2 deletions alias_functions/gd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fi
git diff "$1"

echo ""
read -p " Add this file to commit? [y/N]: " r
read -rp " Add this file to commit? [y/N]: " r

if [ "$r" = "y" ]; then
git add "$1"
Expand All @@ -29,7 +29,7 @@ if [ "$r" = "y" ]; then
fg_return
fi

read -p " Rollback this file changes? [y/N]: " r
read -rp " Rollback this file changes? [y/N]: " r

if [ "$r" = "y" ]; then
git checkout "$1"
Expand Down
2 changes: 1 addition & 1 deletion alias_functions/gg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ msg="$1"

git add --all && \
git commit -m "$msg" && \
git push origin $branch_name
git push origin "$branch_name"
2 changes: 1 addition & 1 deletion alias_functions/glp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

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)'"

eval $logCmd $*
eval "$logCmd $*"
1 change: 1 addition & 0 deletions alias_functions/gpl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#
# git pull

# shellcheck source=/dev/null
. ~/.fancy-git/random_messages.sh

run() {
Expand Down
3 changes: 2 additions & 1 deletion alias_functions/gplo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
#
# git pull origin <branch_name>

# shellcheck source=/dev/null
. ~/.fancy-git/random_messages.sh

run() {
local branch_name
branch_name="$1"

git pull origin $branch_name
git pull origin "$branch_name"

_fancygit_after_pulling_random_message
}
3 changes: 2 additions & 1 deletion alias_functions/gplob.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
#
# git pull origin <current_branch_name>

# shellcheck source=/dev/null
. ~/.fancy-git/random_messages.sh

run() {
local branch_name
branch_name=$(git branch | grep -oP '(?<=\* ).*')

git pull origin $branch_name
git pull origin "$branch_name"

_fancygit_after_pulling_random_message
}
2 changes: 1 addition & 1 deletion alias_functions/gpsob.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

branch_name=$(git branch | grep -oP '(?<=\* ).*')

git push origin $branch_name
git push origin "$branch_name"
2 changes: 1 addition & 1 deletion alias_functions/grb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@

new_branch_name="$1"

git branch -m $new_branch_name
git branch -m "$new_branch_name"
6 changes: 3 additions & 3 deletions alias_functions/grba.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
new_branch_name="$1"
old_branch_name=$(git branch | grep -oP '(?<=\* ).*')

git branch -m $new_branch_name
git push origin :$old_branch_name
git push origin $new_branch_name
git branch -m "$new_branch_name"
git push origin :"$old_branch_name"
git push origin "$new_branch_name"
2 changes: 1 addition & 1 deletion alias_functions/gsta.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
# git stash apply stash@{<stash_id>}

stash_id="$1"
git stash apply stash@{$stash_id}
git stash apply "stash@{$stash_id}"
2 changes: 1 addition & 1 deletion alias_functions/gstd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
# git stash drop stash@{<stash_id>}

stash_id="$1"
git stash drop stash@{$stash_id}
git stash drop "stash@{$stash_id}"
2 changes: 1 addition & 1 deletion alias_functions/gstw.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
# git stash show stash@{<stash_id>}

stash_id="$1"
git stash show stash@{$stash_id}
git stash show "stash@{$stash_id}"
4 changes: 2 additions & 2 deletions alias_functions/pve.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

venv_name="none"

if ! [ -z ${VIRTUAL_ENV} ]; then
venv_name="`basename \"$VIRTUAL_ENV\"`"
if [[ -n ${VIRTUAL_ENV} ]]; then
venv_name=$(basename "$VIRTUAL_ENV")
fi

echo ""
Expand Down
5 changes: 4 additions & 1 deletion commands-handler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#
# Commands manager.

# shellcheck source=/dev/null
. ~/.fancy-git/modules/settings-manager.sh
. ~/.fancy-git/modules/git-manager.sh
. ~/.fancy-git/modules/update-manager.sh
Expand Down Expand Up @@ -38,7 +39,7 @@ case "$1" in
"--enable-rich-notification") fancygit_config_save "show_rich_notification" "true";;
"--disable-rich-notification") fancygit_config_save "show_rich_notification" "false";;

# Set Name and Host
# Set Name and Host.
"--set-user-name") fancygit_config_save "user_name" "$2";;
"--unset-user-name") fancygit_config_save "user_name" "";;
"--set-host-name") fancygit_config_save "host_name" "$2";;
Expand Down Expand Up @@ -95,6 +96,8 @@ case "$1" in
"dark") fancygit_app_command_deprecation_warning "--color-scheme-batman";;
"dark-col") fancygit_app_command_deprecation_warning "--color-scheme-robin";;
"light") fancygit_app_command_deprecation_warning "--color-scheme-light";;

# Default.
"") fancygit_app_command_return;;
*) fancygit_app_command_not_found "$1";;
esac
2 changes: 0 additions & 2 deletions fancygit-completion
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ _fancygit() {
--disable-double-line \
--enable-rich-notification \
--disable-rich-notification \
--enable-tag-name \
--disable-tag-name \
--set-user-name \
--unset-user-name \
--set-host-name \
Expand Down
2 changes: 0 additions & 2 deletions help.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ FEATURE SWITCHER COMMANDS:
fancygit --disable-double-line Show a single line prompt.
fancygit --enable-rich-notification Show notification area with icons.
fancygit --disable-rich-notification Show notification area with simple symbols.
fancygit --enable-tag-name Show the current tag name.
fancygit --disable-tag-name Hide the current tag name.
THEME COMMANDS:
fancygit --theme-default Change prompt to the default theme.
Expand Down
Binary file modified images/default_001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/screenshots/separators.png
Binary file not shown.
Binary file removed images/screenshots/theme-default-double-line.png
Binary file not shown.
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ FANCYGIT_RUNNING_OS=$(uname)
FANCYGIT_GIT_PATH=$(whereis git | cut -d ":" -f 2)

errcho() {
>&2 echo $@;
>&2 echo "$@";
}

if [ "" = "$FANCYGIT_GIT_PATH" ]; then
Expand Down
10 changes: 5 additions & 5 deletions modules/app-manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fancygit_app_command_show_version() {

# ----------------------------------------------------------------------------------------------------------------------
# Show default error message when a command is not found.
#
#
# param string $1 Command.
# ----------------------------------------------------------------------------------------------------------------------
fancygit_app_command_not_found() {
Expand Down Expand Up @@ -93,7 +93,7 @@ fancygit_show_color_schemes() {
printf "\nAll available color schemes:\n\n"
tput sgr0

printf "%s\n" $(ls ${color_schemes_path}/* | sed "s,${color_schemes_path}/.*_,--color-scheme-,")
printf "%s\n" "$(find "${color_schemes_path}" | sed s,"${color_schemes_path}/.*_",--color-scheme-, | sed '1d')"
echo ""
return
fi
Expand All @@ -102,10 +102,10 @@ fancygit_show_color_schemes() {

tput bold
tput setaf 2
printf "\nAvailable color schemes for current theme (--theme-${current_theme}):\n\n"
printf "\n%s\n\n" "Available color schemes for current theme (--theme-${current_theme}):"
tput sgr0

printf "%s\n" $(ls ${color_schemes_path}/${current_theme}_* | sed "s,${color_schemes_path}/${current_theme}_,--color-scheme-,")
printf "%s\n" "$(find "${color_schemes_path}/${current_theme}"_* | sed "s,${color_schemes_path}/${current_theme}_,--color-scheme-,")"
echo ""
}

Expand All @@ -120,6 +120,6 @@ fancygit_show_themes() {
printf "\nAll available themes:\n\n"
tput sgr0

printf "%s\n" $(ls ${themes_path}/* | sed "s,${themes_path}/*,--theme-," | sed 's/.sh//')
printf "%s\n" "$(find "${themes_path}"/* | sed "s,${themes_path}/*,--theme-," | sed 's/.sh//')"
echo ""
}
18 changes: 9 additions & 9 deletions modules/git-manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ fancygit_git_get_branch() {
# ----------------------------------------------------------------------------------------------------------------------
fancygit_git_get_tag() {
local tag

tag=$(git describe --tags --exact-match 2> /dev/null)

if [ "" != "$tag" ]
Expand Down Expand Up @@ -158,7 +158,7 @@ fancygit_git_get_changed_files() {
__fancygit_git_get_remote_branch() {
local branch_name

branch_name=$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2> /dev/null | cut -d"/" -f1)
branch_name=$(git rev-parse --abbrev-ref --symbolic-full-name "@{u}" 2> /dev/null | cut -d"/" -f1)
branch_name=${branch_name:-origin}
echo "$branch_name"
}
Expand Down Expand Up @@ -195,11 +195,11 @@ git config --global color.status.untracked \"cyan\"
# Apply the suggested global git config.
# ----------------------------------------------------------------------------------------------------------------------
fancygit_git_suggested_git_config_apply() {
`git config --global color.ui true`
`git config --global color.diff.meta "yellow bold"`
`git config --global color.diff.old "red bold"`
`git config --global color.diff.new "green bold"`
`git config --global color.status.added "green bold"`
`git config --global color.status.changed "yellow"`
`git config --global color.status.untracked "cyan"`
eval git config --global color.ui true
eval git config --global color.diff.meta "yellow bold"
eval git config --global color.diff.old "red bold"
eval git config --global color.diff.new "green bold"
eval git config --global color.status.added "green bold"
eval git config --global color.status.changed "yellow"
eval git config --global color.status.untracked "cyan"
}
Loading

0 comments on commit 1a9054c

Please sign in to comment.