Skip to content

Feature/full zsh feature #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .git-bash-for-mac-zsh.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/zsh

autoload -Uz compinit && compinit
source ~/.git-prompt.sh

autoload -U colors && colors
DEFAULT="%{$reset_color%}"
GREEN="%{$fg[green]%}"
YELLOW="%{$fg[yellow]%}"
CYAN="%{$fg[cyan]%}"

setopt PROMPT_SUBST
export PS1=$GREEN"$USER@%m"$YELLOW" %~"$CYAN'$(__git_ps1)'$DEFAULT$'\n'"\$ "
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Did you (finally) migrate from Windows to Mac and the only thing you miss is the lovely Git Bash?
You have no idea what the Git Bash is (or Windows for that matters) and yet you really want to improve your Git experience on Mac?

Here it comes the *Git Bash for Mac*: a nice `Terminal` customisation that always shows you the branch you are on, powered by a tab-based autocompletion for all of Git’s subcommands, command-line parameters, and remotes and ref names.
Here it comes the *Git Bash for Mac*: a nice `Terminal` customisation that always shows you the branch you are on, powered by a tab-based autocompletion for all of Git’s subcommands, command-line parameters, and remotes and ref names. It attaches to `bash` and `zsh`.

![git-bash-for-mac](./images/screenshot.png "Git Bash for Mac")

Expand All @@ -17,6 +17,8 @@ Follow these steps:
2. open `Terminal` -> `Preferences` -> `Profiles` and select the `Pro` theme;
3. restart the `Terminal` and enjoy!

It is recommended that you run Git 2.18+ for a full auto completion support

### Uninstall

Follow these steps:
Expand All @@ -29,9 +31,9 @@ Follow these steps:

### Customize

You don't like the colors of your new prompt? Open `~/.git-bash-for-mac.sh` and start messing up with it!
You don't like the colors of your new prompt? Open `~/.git-bash-for-mac.sh` or `~/.git-bash-for-mac-zsh.sh` and start messing up with it!

In addition, by simply exporting a couple of variables in `~/.git-bash-for-mac.sh` you can make you prompt even more informative:
In addition, by simply exporting a couple of variables in `~/.git-bash-for-mac.sh` or `~/.git-bash-for-mac-zsh.sh` you can make you prompt even more informative:
* if you set `export GIT_PS1_SHOWDIRTYSTATE=1`, unstaged (*) and staged (+) changes will be shown next to the branch name;
* if you set `export GIT_PS1_SHOWSTASHSTATE=1` and something is stashed then a '$' will be shown next to the branch name;
* if you set `export GIT_PS1_SHOWUNTRACKEDFILES=1` and there are untracked files then a '%' will be shown next to the branch name.
Expand Down
8 changes: 7 additions & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
set -e

curl -o ~/.git-bash-for-mac.sh https://raw.githubusercontent.com/fabriziocucci/git-bash-for-mac/master/.git-bash-for-mac.sh
curl -o ~/.git-bash-for-mac-zsh.sh https://raw.githubusercontent.com/fabriziocucci/git-bash-for-mac/master/.git-bash-for-mac-zsh.sh
curl -o ~/.git-completion.bash https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
curl -o ~/.git-prompt.sh https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh

touch ~/.bash_profile
# Add newline at the end of the '.bash_profile' if it doesn't exist
sed -i '' '$a\' ~/.bash_profile

echo "source ~/.git-bash-for-mac.sh" >> ~/.bash_profile

touch ~/.zshrc
# Add newline at the end of the '.zshrc' if it doesn't exist
sed -i '' '$a\' ~/.zshrc
echo "source ~/.git-bash-for-mac-zsh.sh" >> ~/.zshrc
4 changes: 3 additions & 1 deletion uninstall.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/bash

rm ~/.git-bash-for-mac.sh
rm ~/.git-bash-for-mac-zsh.sh
rm ~/.git-completion.bash
rm ~/.git-prompt.sh

sed -i.backup '/source ~\/.git-bash-for-mac.sh/d' ~/.bash_profile
sed -i.backup '/source ~\/.git-bash-for-mac.sh/d' ~/.bash_profile
sed -i.backup '/source ~\/.git-bash-for-mac-zsh.sh/d' ~/.zshrc