Giter Site home page Giter Site logo

custom-powerline-prompt-for-powershell's Introduction

Custom powerline prompt for powershell

Example

It's a simple script containing few useful utils that help in creating custom, pretty and fully flexible Powershell prompts. If you don’t want to write too much code yourself, I would recommend you using one of the existing solutions that work out of the box (for example this one).

But if you want to create a fully custom and tailor made prompt, feel free to fork this repo and adjust it to your needs.

How to set it up

  1. Get yourself a modern terminal (for example the Windows Terminal).
  2. Install a font the supports powerline characters (for example the CascadiaMonoPL.ttf) and set it as the default font of your terminal.
  3. Open (or create) your Powershell profile file (on how to do it).
  4. Paste the content of the profile.ps1 script at the end of your profile file.
  5. Customize the behavior of the script based on your personal needs.

Customization

The profile.ps1 script defines two useful classes: Color and PromptBuilder. Everything after that is me using those classes to customize my own prompt. The customization code contains few hardcoded paths from my environment, so you will definitely want to rewrite it. Nevertheless, it can be a good starting point for experimentations and a nice learning example on how to use this script.

The idea here is simple:

  1. Create an instance of the PromptBuilder class.
  2. Call the WithSection method to append new a block at the end of the prompt. The WriteSection method allows you to specify the background color of the new section.
  3. Call the WithSeparator method (or the WithReversedSeparator depending on the direction the separator is facing) to add the powerline separator between sections. You have to call it between the WithSection calls. The foreground and background color of the separator will be derived from neighboring sections.
  4. Get the complete string by calling the ToString method of the PromptBuilder and return it from the prompt function

The list of powerline character codes can be bound here.

custom-powerline-prompt-for-powershell's People

Contributors

tomaszrewak avatar

Stargazers

 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.