Skip to content

Commit

Permalink
Merge pull request #26 from diogocavilha/fix-base-path
Browse files Browse the repository at this point in the history
📝 Improve base path definitions
  • Loading branch information
diogocavilha authored Dec 6, 2018
2 parents d36adf3 + 0115bee commit 7eafdb7
Show file tree
Hide file tree
Showing 42 changed files with 269 additions and 206 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

### v5.2.3

- Improve base path definitions
- Improve code style

### v5.2.2

- Update README.md
Expand Down
82 changes: 48 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,26 @@ curl -sS https://raw.githubusercontent.com/diogocavilha/fancy-git/master/uninsta

If you can't find the font, it's still possible to install it manually by running `fancygit configure-fonts` or even installing the ttf file placed at `~/.fancy-git/fonts/SourceCodePro+Powerline+Awesome+Regular.ttf`.

### Git suggested colors

```bash
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"
```

I suggest you to use this scheme color because fancygit will paint the background branch or showing icon colors, most of the time, according to the current repo status.

### Overview

As a picture is worth a thousand words...

**Default mode**
**Default style**

![001](https://github.com/diogocavilha/fancy-git/blob/master/images/default_001.png)
![002](https://github.com/diogocavilha/fancy-git/blob/master/images/default_002.png)
Expand All @@ -45,57 +60,56 @@ As a picture is worth a thousand words...

> In case you are in doubt about what some icon means, you can type `fancygit -h` or `fancygit --help`.
**Simple mode**
If you don't want to be too "fancy" (as I don't), you can choose using the **simple style**.

If you're running it on a server and you don't want to be too "fancy", you can choose using the simple mode.
In order to change to the **simple style** you can type `fancygit simple`. And if you want to return to the **default style** (colored), you can type `fancygit default`.

> Once you're using the simple mode, it'll not show you lots of cool informations about the git repository. The only information it'll give you is the branch name and whether or not it has changes.
There are a bit of styles you can choose from. Here you have a list of available styles and their corresponding command.

In order to change to the **simple mode** you can type `fancygit simple`. And if you want to return to the **default mode** (colored), you can type `fancygit default`.
> In case you are in doubt about which styles are available, you can type `fancygit -h` or `fancygit --help`.
![001](https://github.com/diogocavilha/fancy-git/blob/master/images/001.png)
![002](https://github.com/diogocavilha/fancy-git/blob/master/images/002.png)
![003](https://github.com/diogocavilha/fancy-git/blob/master/images/003.png)
### Styles

| Command | Description
| --------------------------- | ---------------------------------------------------------
| fancygit simple | `simple` style.
| fancygit simple-double-line | The same as `simple` style but the cursor gets waiting on next line.
| fancygit default | Colored style. (This is the fallback style).
| fancygit double-line | The same as `default` style but the cursor gets waiting on next line.
| fancygit human | Make prompt more human readable.
| fancygit dark | Like `default` style but with darker colors.
| fancygit dark-double-line | The same as `dark` style but the cursor gets waiting on next line.
| fancygit light | The opposite of `dark` style.
| fancygit light-double-line | The same as `light` style but the cursor gets waiting on next line.

### Commands

| Command | Description
| ------------------------ | ---------------------------------------------------------
| fancygit -h, --help | Show this help.
| fancygit -v, --version | Show the fancygit version.
| fancygit update | Update fancygit code with the last release from github.
| fancygit configure-fonts | Install font in order to render icons properly. (only for colored styles).
| 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`.

### Styles
### Aliases

| Command | Description
| --------------------------- | ---------------------------------------------------------
| 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 dark | Change prompt to the dark style.
| fancygit dark-double-line | Change prompt to the dark 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.
Here we got a list of useful aliases you can use when working.

### Git suggested colors
They seem to be not that interesting, but believe me, after getting used to them, your productivity will increase considerably when working with git repos.

```bash
git config --global color.ui true
For example, what if you could replace `git push origin <branch-name>` for `gpsob`? Much smaller command, isn't it?. That's is possible but what, for goodness sake, means `gpsob`?

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"
```
Well, here goes a little explanation:

I suggest you to use this scheme color because fancygit will paint the background branch or showing icon colors, most of the time, according to the current repo status.
`gps + o + b`

### Aliases
`gps` = `git push`

`o` = `origin`

`b` = `<branch-name>`... Yes, it will get the branch you're working on.

Basically, most of the Fancy Git aliases work this way.

| Alias | Command | Description
| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------
Expand Down
8 changes: 3 additions & 5 deletions alias_functions/ga.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#!/bin/bash
#
# Author: Diogo Alexsander Cavilha <[email protected]>
# Date: 03.13.2017
# Author: Diogo Alexsander Cavilha <[email protected]>
# Date: 03.13.2017
#
# ADDING FILES
#
# Adds files in order to commit and shows git status
# git add

git add $* && \
clear && \
Expand Down
8 changes: 3 additions & 5 deletions alias_functions/gaa.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#!/bin/bash
#
# Author: Diogo Alexsander Cavilha <[email protected]>
# Date: 03.13.2017
# Author: Diogo Alexsander Cavilha <[email protected]>
# 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 && \
Expand Down
8 changes: 3 additions & 5 deletions alias_functions/gck.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#!/bin/bash
#
# Author: Diogo Alexsander Cavilha <[email protected]>
# Date: 03.16.2017
# Author: Diogo Alexsander Cavilha <[email protected]>
# Date: 03.16.2017
#
# CHECKOUT FILES
#
# Checkout files and shows git status
# git checkout --

git checkout -- $* && \
clear && \
Expand Down
10 changes: 4 additions & 6 deletions alias_functions/gckbt.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#!/bin/bash
#
# Author: Diogo Alexsander Cavilha <[email protected]>
# Date: 07.05.2016
# Author: Diogo Alexsander Cavilha <[email protected]>
# Date: 07.05.2016
#
# BRANCH CHACKOUT
#
# It forces the checkout of a branch
# git checkout --track origin/<current_branch_name>

branch_name=$1
branch_name="$1"
git checkout --track origin/$branch_name
14 changes: 5 additions & 9 deletions alias_functions/gd.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
#!/bin/bash
#
# Author: Diogo Alexsander Cavilha <[email protected]>
# Date: 11.28.2017
# Author: Diogo Alexsander Cavilha <[email protected]>
# 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
Expand All @@ -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

Expand Down
18 changes: 9 additions & 9 deletions alias_functions/gg.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/bin/bash
#
# Author: Diogo Alexsander Cavilha <[email protected]>
# Date: 04.21.2018
# Author: Diogo Alexsander Cavilha <[email protected]>
# Date: 04.21.2018
#
# ADD, COMMIT, PUSH
#
# A shortcut for a common sequence in order to push changes
# git add --all
# git commit -m <message>
# git push origin <current_branch_name>

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
8 changes: 3 additions & 5 deletions alias_functions/glp.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#!/bin/bash
#
# Author: Diogo Alexsander Cavilha <[email protected]>
# Date: 09.01.2016
# Author: Diogo Alexsander Cavilha <[email protected]>
# 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)'"

Expand Down
5 changes: 5 additions & 0 deletions alias_functions/gpl.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/bin/bash
#
# Author: Diogo Alexsander Cavilha <[email protected]>
# Date: 04.01.2016
#
# git pull

. ~/.fancy-git/random_messages.sh

Expand Down
11 changes: 8 additions & 3 deletions alias_functions/gplo.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
#!/bin/bash
#
# Author: Diogo Alexsander Cavilha <[email protected]>
# Date: 04.01.2016
#
# git pull origin <branch_name>

. ~/.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
}
11 changes: 8 additions & 3 deletions alias_functions/gplob.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
#!/bin/bash
#
# Author: Diogo Alexsander Cavilha <[email protected]>
# Date: 04.01.2016
#
# git pull origin <current_branch_name>

. ~/.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
}
9 changes: 7 additions & 2 deletions alias_functions/gpsob.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/bash
#
# Author: Diogo Alexsander Cavilha <[email protected]>
# Date: 04.01.2016
#
# git push origin <current_branch_name>

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

git push origin $branch
git push origin $branch_name
10 changes: 5 additions & 5 deletions alias_functions/grb.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/bash
#
# Author: Diogo Alexsander Cavilha <[email protected]>
# Date: 05.24.2016
# Author: Diogo Alexsander Cavilha <[email protected]>
# Date: 05.24.2016
#
# BRANCH RENAMING
# It renames a branch locally.
#
# Rename branch locally
# git branch -m <new_branch_name>

new_branch_name=$1
new_branch_name="$1"

git branch -m $new_branch_name
16 changes: 9 additions & 7 deletions alias_functions/grba.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#!/bin/bash
#
# Author: Diogo Alexsander Cavilha <[email protected]>
# Date: 05.24.2016
# Author: Diogo Alexsander Cavilha <[email protected]>
# 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 <new_branch_name>
# git push origin :<old_branch_name>
# git push origin <new_branch_name>

new_branch_name=$1
new_branch_name="$1"
old_branch_name=$(git branch | grep -oP '(?<=\* ).*')

git branch -m $new_branch_name
Expand Down
10 changes: 4 additions & 6 deletions alias_functions/gsta.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#!/bin/bash
#
# Author: Diogo Alexsander Cavilha <[email protected]>
# Date: 04.19.2018
# Author: Diogo Alexsander Cavilha <[email protected]>
# Date: 04.19.2018
#
# APPLY STASH
#
# It applies a stash
# git stash apply stash@{<stash_id>}

stash_id=$1
stash_id="$1"
git stash apply stash@{$stash_id}
Loading

0 comments on commit 7eafdb7

Please sign in to comment.