Giter Club home page Giter Club logo

bash-powerline-shell's Introduction

A bash-script based Powerline style prompt for your shell

A Powerline like prompt for Bash using bash scripts

This implementation was inspired by Powerline-Shell. But that version, which is based on python, was exceedingly slow for my taste, taking upto 1.5 seconds for the shell prompt to be set with the python script. Hence, I decided to recreate the appearance created in that prompt using only shell scripts.

Consequently this is not nearly as readily configurable as python based one above. However, with a little bit of effort and knowledge of shell scripts, you can make this look however you desire.

Screenshot of powerline style shell

Main Features

  • Shows time, hostname, current directory, and prompt
  • Optional segments for number of background jobs, read-only status of current directory, return code for last command if exited in failure along with color change of the prompt to red
  • Segment that shows current git branch if in a git repository, and number of modified, staged and conflicted files in the git repository.

Unicode symbols used

  • Number of background jobs: followed by number
  • Read-only status of current directory:
  • Return code from previous bash command:
  • Git branch:
  • Number of modified files in git repo:
  • Number of staged files in git repo: ``
  • Number of conflicted files in git repo:

In addition, the following symbols are used to separate different segments: , 

Setup

  • This shell script heavily relies on ANSI color codes to display colors in the terminal window. They may not be portable, hence it may not work for you out of the box. You may need to set your $TERM to xterm-256color.

  • In addition, Unicode symbols require a special font to be used in your terminal. Please use one of the powerline fonts available at: https://github.com/Lokaltog/powerline-fonts

    • The "DejaVu Sans Mono for Powerline" font seems to be one of the better fonts for Unicode support.
  • You may need to use uxterm, the XTerm with unicode support, in place of xterm if the Unicode characters are not correctly rendered.

  • This script uses the __git_ps1 command to identify if a directory is a git repository, and if it is, identify the branch name. If you do not have this command, please install it for your system.

  • Clone this repository, or copy the ps1_prompt shell script to a suitable location. Let us assume that you placed this in your home directory.

  • In your .bashrc or .profile, whichever is used, source the ps1_prompt script as follows:

source ~/ps1_prompt

Customization

At this point, this script has no simple option for customization apart from manually editting the script to your liking. Once you get the flow of the script, and after familiarizing yourself with the ANSI color codes, it should be fairly straightforward to enhance the script to your taste.

Some resources that can help you with tweaking the script:

If you can contribute to make this script more customizable, please do so and submit a pull request!

bash-powerline-shell's People

Contributors

abhijitvalluri avatar hongaar avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.