Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Powerline in Linux

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to use Powerline in Linux, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Powerline is a great Vim editor status line plug-in, this plug-in is developed using Python, mainly used to display status lines and prompts, suitable for a lot of software, such as bash, zsh, tmux and so on.

Special features

Written in python to make it more scalable and feature-rich

Stable and easy to test code base, compatible with python 2.6 + and python 3

Tips and status bars that support multiple Linux functions and tools

Save the configuration and color scheme through JSON

Fast, lightweight, with background daemon support for better performance

Screenshot of Powerline effect

Powerline status Line effect in Vim

In this article, I'll show you how to install Powerline and its fonts, and how to make Bash and Vim support Powerline in systems of the RedHat and Debian classes.

* step: get ready to install the software required by Powerline

Because of naming conflicts with other unrelated items, powerline can only be placed under the powerline-status package in PyPI (Python Package Index).

In order to install the package from PyPI, you need to prepare the pip tool (which is dedicated to the management of Python packages). So first of all, we should install the pip tool under the Linux system.

Install pip in Debian, Ubuntu, and Linux Mint

# apt-get install python-pip

Sample output:

Reading package lists... Done Building dependency tree Reading state information... Done Recommended packages: python-dev-all python-wheel The following NEW packages will be installed: python-pip 0 upgraded, 1 newly installed, 0 to remove and 533 not upgraded. Need to get 97.2 kB of archives. After this operation, 477 kB of additional disk space will be used. Get:1 http://archive.ubuntu.com/ubuntu/ trusty-updates/universe python-pip all 1.5.4-1ubuntu3 [97.2 kB] Fetched 97.2 kB in 1s (73.0 kB/s) Selecting previously unselected package python-pip. (Reading database... 216258 files and directories currently installed.) Preparing to unpack... / python-pip_1.5.4-1ubuntu3_all.deb... Unpacking python-pip (1.5.4-1ubuntu3). Processing triggers for man-db (2.6.7.1-1ubuntu1). Setting up python-pip (1.5.4-1ubuntu3).

Install pip in CentOS, RHEL, and Fedora

In a Fedora-like system, you need to open the epel repository and then install the pip package as follows.

# yum install python-pip # dnf install python-pip [over Fedora 22 +]

Sample output:

Installing: python-pip noarch 7.1.0-1.el7 epel 1.5 M Transaction Summary = Install 1 Package Total download size: 1.5 M Installed size: 6.6 M Is this ok [y/d/N]: y Downloading packages: python-pip-7.1.0-1.el7.noarch.rpm | 1.5 MB 00:00:01 Running transaction check Running transaction Test Transaction test succeeded Running transaction Installing: python-pip-7.1.0-1.el7.noarch 1 Verifying: python-pip-7.1.0-1.el7.noarch 1 1.el7.noarch 1 Installed: python-pip.noarch 0 Vera 7.1.0-1.el7 Complete!

Step 2: install Powerline in Linux

You can now install the development version of Powerline from the Git repository. Before that, the system needs to install the Git tool so that the code can be pulled from the warehouse.

# apt-get install git # yum install git # dnf install git

Then you can install Powerline with the pip command.

# pip install git+git://github.com/powerline/powerline

Sample output:

Cloning git://github.com/powerline/powerline to / tmp/pip-WAlznH-build Running setup.py (path:/tmp/pip-WAlznH-build/setup.py) egg_info for package from git+git://github.com/Lokaltog/powerline warning: no previously-included files matching'* .pyc 'found under directory' powerline/bindings' warning: no previously-included files matching'* .pyo 'found under directory' powerline/bindings' Installing collected packages: powerline-status Found existing installation: powerline-status 2.2 Uninstalling powerline- Status: Successfully uninstalled powerline-status Running setup.py install for powerline-status warning: no previously-included files matching'* .pyc 'found under directory' powerline/bindings' warning: no previously-included files matching'* .pyo 'found under directory' powerline/bindings' changing mode of build/scripts-2.7/powerline-lint from 644 to 755 changing mode of build/scripts-2.7/powerline-daemon from 644 to 755 changing mode of build/scripts-2.7/powerline-render from 644 to 755 changing mode of build/scripts-2 . 7/powerline-config from 644 to 755 changing mode of / usr/local/bin/powerline-config to 755 changing mode of / usr/local/bin/powerline-lint to 755 changing mode of / usr/local/bin/powerline-render to 755 changing mode of / usr/local/bin/powerline-daemon to 755 Successfully installed powerline-status Cleaning up...

Step 3: install Powerline fonts in Linux

Powerline uses special symbols to display special arrow effects and symbol content for developers. So you must have symbolic fonts or patched fonts in your system.

Download the system font and font configuration file for * through the wget command below.

# wget https://github.com/powerline/powerline/raw/develop/font/PowerlineSymbols.otf # wget https://github.com/powerline/powerline/raw/develop/font/10-powerline-symbols.conf

Then you put the downloaded fonts into the font directory / usr/share/fonts or / usr/local/share/fonts, or you can find a valid font directory with the xset Q command.

# mv PowerlineSymbols.otf / usr/share/fonts/

Next you need to update your system's font cache with the following command.

# fc-cache-vf / usr/share/fonts/

Secondly, install the font configuration file.

# mv 10-powerline-symbols.conf / etc/fonts/conf.d/

Note: if the corresponding symbol does not appear, you can try to close the terminal session and restart X window, which will take effect.

Step 4: set Powerline to the Bash Shell and Vim status lines

This section introduces the configuration of Powerline in the bash shell and vim editors. First, set the terminal to 256 colors by adding the following to ~ / .bashrc.

Export TERM= "screen-256color"

Open Powerline in Bash Shell

If you want to turn on Powerline by default in bash shell, you can add the following to ~ / .bashrc.

First, get the installation location of powerline with the following command.

# pip show powerline-status Name: powerline-status Version: 2.2.dev9999-git.aa33599e3fb363ab7f2744ce95b7c6465eef7f08 Location: / usr/local/lib/python2.7/dist-packages Requires:

Once you have found the specific location of powerline, replace it with the corresponding location of / usr/local/lib/python2.7/dist-packages in the following lines according to the situation of your system.

Powerline-daemon-Q POWERLINE_BASH_CONTINUATION=1 POWERLINE_BASH_SELECT=1. / usr/local/lib/python2.7/dist-packages/powerline/bindings/bash/powerline.sh

Then log in again after logging out, and the status line for powerline should now be shown below.

Bash Powerline Statuslines

Now change the directory and notice the change in the breadcrumb navigation prompt that shows your current path.

If powerline is installed on the remote Linux server, you can see the tasks pending in the background, and when you log in with ssh, you will see the prompt with the hostname added.

Open Powerline in Vim

If you like to use vim, there happens to be a powerful plug-in for vim. You can open the plug-in by adding the following content to ~ / .vimrc. (note: note that you also need to modify the path according to your system conditions).

Set rtp+=/usr/local/lib/python2.7/dist-packages/powerline/bindings/vim/ set laststatus=2 set t_Co=256

Then you will see a new status line when you open vim:

Thank you for reading this article carefully. I hope the article "how to use Powerline in Linux" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report