Header Shadow Image


Bash: PowerLine Configuration under a User Account

Let's setup Powerline to make our prompts look like this in CentOS!

https://i2.wp.com/www.microdevsys.com/WordPressImages/powerline-configuration-introduction.JPG?ssl=1

How to do this?  Follow the following set of steps to configure this within a non privilidged user account without having to modify many target server root owned files or install any packages in the target UNIX systems.

  • Install powerline using pip3 Python 3 installer:

    [tom@mds.xyz@awx01:~] :)$ pip3 install –user powerline-status
    Collecting powerline-status
      Using cached https://files.pythonhosted.org/packages/9c/30/8bd3c62642778af9ad813a526c6ff7dd20ad6fab94ca389265/powerline-status-2.7.tar.gz
    Installing collected packages: powerline-status
      Running setup.py install for powerline-status … done
    Successfully installed powerline-status-2.7
    [tom@mds.xyz@awx01:~] :)$

     

  • Find the installed powerline direcctories. This is needed to configure .bash_profile 

    [tom@mds.xyz@awx01:~] :)$ pip3 show powerline-status
    Name: powerline-status
    Version: 2.7
    Summary: The ultimate statusline/prompt utility.
    Home-page: https://github.com/powerline/powerline
    Author: Kim Silkebaekken
    Author-email: kim.silkebaekken+vim@gmail.com
    License: MIT
    Location: /n/mds.xyz/tom/.local/lib/python3.6/site-packages
    Requires:
    [tom@mds.xyz@awx01:~] :)$

    ?

  • Next, add the following lines to your .bash_profile.  It's ok to leave the previous .bash_profile settings in place.  They'll be overwritten.

    [tom@mds.xyz@awx01:~] :)$ cat .bash_profile |tail -n5
    export PATH=$PATH:$HOME/Library/Python/2.7/bin
    powerline-daemon -q
    POWERLINE_BASH_CONTINUATION=1
    POWERLINE_BASH_SELECT=1
    . ./.local/lib/python3.6/site-packages/powerline/bindings/bash/powerline.sh
    [tom@mds.xyz@awx01:~] :)$

     

  • If running on an X Windows system, such as Gnome or KDE, install a set of fonts in the home folder of the user:

    [tom@mds.xyz@awx01:~] :)$ wget https://github.com/powerline/fonts/archive/master.zip
    [tom@mds.xyz@awx01:~] :($ unzip master.zip

    [tom@mds.xyz@awx01:~/fonts] :)$ ./install.sh
    Copying fonts…
    Powerline fonts installed to /n/mds.xyz/tom/.local/share/fonts
    [tom@mds.xyz@awx01:~/fonts] :)$

     

  • This next part occurs in Windows 10.  Grab the set of fonts below and install them in Windows 10.  https://github.com/powerline/fonts :  A few examples:

    Adding Croscore fonts for Powerline (Chrome OS core fonts)
    https://github.com/powerline/fonts/blob/master/Arimo/

    DejaVu Sans Mono for Powerline 
    https://github.com/powerline/fonts/tree/master/DejaVuSansMono

    Droid Sans Mono for Powerline
    https://github.com/powerline/fonts/tree/master/DroidSansMono
     

  • Select the installed fonts in PuTTy:

    Within PuTTy (Putty Configuration) -> Window -> Apearance -> Font settings -> Change

    Select above-installed fonts.

  • Login to a host.

  • Enjoy your new command line!

BONUS

Below is a one line ansible command to update the .bash_profile as root:

ansible 'awx01*' -i /ansible/infra -m shell -a "yum install python3 -y" -become -u root

ansible 'awx01*' -i /ansible/infra -m shell -a "pip3 install –user powerline-status" -become -u root

ansible 'awx01*' -i /ansible/infra -m shell -a "if ! grep -q powerline ~/.bash_profile; then echo -ne \"export PATH=\\\$PATH:$HOME/.local/bin/\\npowerline-daemon -q\\nPOWERLINE_BASH_CONTINUATION=1\\nPOWERLINE_BASH_SELECT=1\\n. /root/.local/lib/python3.6/site-packages/powerline/bindings/bash/powerline.sh\\n\" >> ~/.bash_profile; fi" -become -u root

Modify the host parameter to just '*' once you feel comfortable with the commands. This is how it looks when done:

https://www.microdevsys.com/WordPressImages/powerline-configuration-rootJPG

Have Fun!
TK


     
  Copyright © 2003 - 2013 Tom Kacperski (microdevsys.com). All rights reserved.

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License