Giter Site home page Giter Site logo

ryanparadipta / powerline-mysegments Goto Github PK

View Code? Open in Web Editor NEW

This project forked from microhobby/powerline-mysegments

0.0 0.0 0.0 6 MB

My Custom Segments for Powerline (Linux Bash and Windows Power Shell Core)

License: MIT License

Python 61.72% PowerShell 38.28%

powerline-mysegments's Introduction

I created scripts to return random sad and angry emojis for each command with an error result in the terminal, for both Windows PowerShell Core and Bash powerline:

$ERROR_EMOJI = "๐Ÿ˜–", "๐Ÿ˜ต", "๐Ÿฅด", "๐Ÿ˜ญ", "๐Ÿ˜ฑ", "๐Ÿ˜ก", "๐Ÿคฌ", "๐Ÿ™ƒ", `
    "๐Ÿค”", "๐Ÿ™„", "๐Ÿฅบ", "๐Ÿ˜ซ", "๐Ÿ’€", "๐Ÿ’ฉ", "๐Ÿ˜ฐ"

In this article I will show how you can use them.

โš  DISCLAIMER: these scripts are meant to be useful to me. I can help with any questions, but I do not intend to maintain it or fix issues. Feel free to use and modify as you wish.

Random Emojis When CMD Result Errors

Windows PowerShell Core

First follow the steps from the How To Install Powerline For Windows Terminal article. After this just edit your PowerShell profile %USERPROFILE%\Documents\PowerShell\Microsoft.PowerShell_profile.ps1 adding the content of the follow file: powerline-mysegments/PowerShell/Microsoft.PowerShell_profile.ps1

Now close the current tab from Windows Terminal or open a new PowerShell Core tab to see your new terminal. Try to input some incorrect commands to test the random emojis:

Here I used an ๐Ÿ‘ฝ emoji to decorate my username. You can change this emoji by modifying the line 99 from powerline-mysegments/PowerShell/Microsoft.PowerShell_profile.ps1:

    # my user name
    { " $env:USERNAME ๐Ÿฆ„" }

Extra Segments

In that same file I added some more custom segments that I found useful for my environment:

enter image description here

Each block script from:

[System.Collections.Generic.List[ScriptBlock]]$Prompt

will be a segment. Beginin on line 20 from powerline-mysegments/PowerShell/Microsoft.PowerShell_profile.ps1. So if you do not want to use any of these extra custom segments just remove the corresponding script block.

โš  WARNING: if you are going to remove any script block but keep the script block from the random emojis segment you will have to fix the color index. Lines 70, 77, 78, 84, 90, 91. You will also have to adjust the colors set for each segment passed during the Set-PowerLinePrompt line 110

Linux Bash

First follow the steps from the How To Install Powerline For Bash article. After this follow the steps:

cd ~
git clone https://github.com/microhobby/powerline-mysegments
cd powerline-mysegments/Bash/segments
pip3 install --editable ./

To verify that the installation was successful, run the following command:

pip3 list

You will need to have the following entry in the list:

mysegments 0.0.1 /home/<your-user>/powerline-mysegments/Bash/segments

Install Custom Configurations

For this custom segments I am also using some colors and customized settings. To apply these settings, run the following commands:

powerline-daemon --replace
cd ~
cd powerline-mysegments/Bash
cp -r .config ~

After that the new style with the customized segments should already be displayed. Try to input some incorrect commands to test the random emojis::

Here I used a ๐Ÿฆ„ emoji to decorate my username. You can change this emoji by modifying the line 68 from powerline-mysegments/Bash/segments/mysegments/custom.py:

    return [{
    'contents': "{} ๐Ÿ‘ฝ".format(usr),
    'highlight_groups': ['cool'],
    }]

Extra Custom Segments

In the same mysegments package I added some more custom segments that I found useful for my environment:

The segments to be used are set in the file powerline-mysegments/Bash/.config/powerline/themes/shell/default_leftonly.json. For example if you want to remove the Docker segment just edit the file and remove the block:

{
	"function": "mysegments.custom.docker",
	"priority": 10
},

Easy peasy ๐Ÿ˜

powerline-mysegments's People

Contributors

microhobby 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.