https://github.com/filippobovo/bash_powerline
Bash Powerline Command Prompt
https://github.com/filippobovo/bash_powerline
bash powerline
Last synced: about 1 year ago
JSON representation
Bash Powerline Command Prompt
- Host: GitHub
- URL: https://github.com/filippobovo/bash_powerline
- Owner: FilippoBovo
- Created: 2018-04-15T13:09:56.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-24T09:02:51.000Z (about 8 years ago)
- Last Synced: 2025-04-08T16:55:13.890Z (about 1 year ago)
- Topics: bash, powerline
- Language: Shell
- Size: 3.71 MB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Simple Bash Powerline
This is a short guide to create a Bash Powerline based on existing online resources.

This Bash Powerline:
- displays the Git status in the command prompt, including information on the active branch and the presence of un-staged files, un-committed files and un-pushed commits;
- displays the active Python Virtual Environment;
- automatically activate a Python Virtual Environment when cd'ing into a path that contains a folder with the same name of the virtual environment.
## Install
Download the following files into your home folder:
- The [official Git Command Prompt script](https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh).
```shell
curl -o $HOME/.git-prompt.sh https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh
```
- The script to auto-activate a virtual environment — [credits to Harry Marr](https://hmarr.com/2010/jan/19/making-virtualenv-play-nice-with-git/).
```shell
curl -o $HOME/.auto-virtualenv.sh https://raw.githubusercontent.com/FilippoBovo/bash_powerline/master/auto-virtualenv.sh
```
- The Virtual Environment Command Prompt script — [adapted from ivanalejandro0 and Daniel Harding's script](https://stackoverflow.com/a/20026992).
```shell
curl -o $HOME/.virtualenv-prompt.sh https://raw.githubusercontent.com/FilippoBovo/bash_powerline/master/virtualenv-prompt.sh
```
Add the following lines to your `~/.bashrc` file if you are using Linux or to your `~/.bash_profile` if you are using Mac OS.
```shell
# COMMAND PROMPT: BASH POWERLINE
source $HOME/.git-prompt.sh
export GIT_PS1_SHOWDIRTYSTATE="True"
export GIT_PS1_SHOWUNTRACKEDFILES="True"
export GIT_PS1_SHOWUPSTREAM="auto"
source $HOME/.auto-virtualenv.sh
source $HOME/.virtualenv-prompt.sh
export VIRTUAL_ENV_DISABLE_PROMPT=1
export COL_BASE=$(tput setab 4)$(tput setaf 0) # Base Colour
export COL_VENV=$(tput setab 3)$(tput setaf 0) # Virtual Environment Colour
export COL_GIT=$(tput setab 2)$(tput setaf 0) # Git Colour
export COL_RESET=$(tput sgr0) # Colour Reset
export PS1='\[$COL_BASE\] \u@\h: \W $(virtualenv_info "\[$COL_VENV\] %s ")$(__git_ps1 "\[$COL_GIT\] %s ")❯❯❯\[$COL_RESET\] '
```
Finally, restart the terminal.
### Colours
The colour configuration used in the above script leads to the colours in the Gif above if coupled with the [Solarized Dark](https://github.com/mbadolato/iTerm2-Color-Schemes#builtin-solarized-dark) colour theme for [iTerm2](https://www.iterm2.com/).
If you are using another theme, you can look for a colour configuraton that matches your theme by changing the number after `tput setab` in the script above according to [this guide](https://linux.101hacks.com/ps1-examples/prompt-color-using-tput/).
## Uninstall
To uninstall this Bash Powerline, simply remove the script snippet added to the `~/.bashrc` or `~/.bash_profile` files during the installation, and remove the downloaded files.
```shell
rm $HOME/.git-prompt.sh $HOME/.auto-virtualenv.sh $HOME/.virtualenv-prompt.sh
```
Finally, restart the terminal.