As I spend a lot of time trying to configure my terminal and git, so they fit my preferences on macOS, I ended up doing these tutorials below.
On these tutorial you may use a text editor from terminal, for those users that have experience with, feel free to use your favorite one.
To users that doesn't use an editor on terminal, I suggest trying the nano
,
because its simple to use and install.
If you want nano
follow steps below, otherwise jump to step 1.
- First installs Homebrew, a package manage for macOS.
- Open terminal (
cmd + space
and writeterminal
). - Run
brew install nano
to installnano
. So open a text file:nano path/to/file/name
. To save and close, just pressctrl + x
andenter
.
Choose which step do you want, and roll until there:
- First install Homebrew, a package manage for macOS.
- Second opens terminal (
cmd + space
and writeterminal
):-
On Terminal run
brew install bash-completion
-
Open
~/.bash_profile
. -
Paste the come below at
bash_profile
:
if [ -f $(brew --prefix)/etc/bash_completion ]; then . $(brew --prefix)/etc/bash_completion fi
- Save and close
~/.bash_profile
-
- Run
source ~/.bash_profile
on terminal. - Now when you press
tab
on a git command, it will auto complete.
- Open terminal (
cmd + space
and writeterminal
):-
Open the file
~/.bash_profile
-
Paste at the end of
bash_profile
:
-
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
This "function" will get the branch that you are working.
- Now to change the Prompt String One (PS1), the string before each command on terminal, we have some different designs.
- Choose which PS1 do you want based on the pictures below, and copy the code related to the picture you want.
- Design 1
export PS1="\u@\h \[\033[32m\] | \w\[\033[33m\] | \$(parse_git_branch)\[\033[00m\] \n $ "
```
User @ Computer | path until actual folder | branch
$ :
```
- Design 2
export PS1="\u@\h \[\033[32m\] | \W\[\033[33m\] | \$(parse_git_branch)\[\033[00m\] \n $ "
```
User @ Computer | actual folder | branch
$ :
```
- Design 3
export PS1="\u@\h \[\033[32m\] | \w\[\033[33m\] | \$(parse_git_branch)\[\033[00m\] $ "
```
User @ Computer | path until actual folder | branch $ :
```
- Paste after the function `parse_git_branch`.
- Save and close `~/.bash_profile`
- Run
source ~/.bash_profile
on terminal.
If you use Linux please check this tutorial
I suggest combine the commands on PS1 to fit your necessities, to understand all commands there and learn othesr check this link.
Although this tutorial focus on macOS users, this step also works on Linux!
- Open terminal (
cmd + space
and writeterminal
):- Run git command:
git config --global -e
- If you want to change your git editor run:
git config --global core.editor "editor"
- On "editor" put your preferable editor.
- If you want to change your git editor run:
- Paste the code below on it:
As you can see this files setup the colors on git commands: branch, diff and status. You can search others commands or change the colors.[color] branch = auto diff = auto status = auto ui = true [color "branch"] current = yellow reverse local = yellow remote = green [color "diff"] meta = yellow bold frag = magenta bold old = red bold new = green bold [color "status"] added = yellow changed = green untracked = cyan
- Run git command:
I hope that you enjoy it! Any suggestion feel free to open a issue!
Thanks you, @lhcavalcanti