beyondworld translated

This commit is contained in:
lixiang23 2017-01-13 09:09:43 +08:00
parent 452201a523
commit 7e87bbb636

View File

@ -1,49 +1,47 @@
beyondworld 翻译中
Powerline - 给Vim和Bash提供更棒的状态行和提示信息
=================================================
Powerline Adds Powerful Statuslines and Prompts to Vim Editor and Bash Terminal
============================================================
Powerline is a great statusline plugin for [Vim editor][1], which is developed in Python and provides statuslines and prompts for many other applications such as bash, zsh, tmux and many more.
Powerline是[Vim editor][1]中一个很好的状态行插件这个插件是使用Python开发的主要用于显示状态行和提示信息适用于很多软件比如bashzshtmux等。
[
![Install Powerline Statuslines in Linux](http://www.tecmint.com/wp-content/uploads/2015/10/Install-Powerline-Statuslines-in-Linux-620x297.png)
][2]
Add Power to Linux Terminal with Powerline Tool
Powerline使Linux终端更具威力
#### Features
#### 特色
1. It is written in Python, which makes it extensible and feature rich.
2. Stable and testable code base, which works well with Python 2.6+ and Python 3.
3. It also supports prompts and statuslines in several Linux utilities and tools.
4. It has configurations and decorator colors developed using JSON.
5. Fast and lightweight, with daemon support, which provides even more better performance.
1. python编写使其更具扩展性且功能丰富
2. 稳定易测的代码基础兼容python2.6+和python3
3. 支持多种Linux版本及工具的提示和状态栏
4. 通过JSON保存配置和颜色方案
5. 快速、轻量级具有daemon支持提供更好的显示效果
#### Powerline Screenshots
#### Powerline截图效果
[
![Powerline Vim Statuslines](http://www.tecmint.com/wp-content/uploads/2015/10/Powerline-Vim-Statuslines.png)
][3]
Powerline Vim Statuslines
Vim中Powerline状态行效果
In this article, I will show you how to install Powerline and Powerline fonts and how to use with Bash and Vimunder RedHat and Debian based systems.
在本文中我会介绍如何安装Powerline和相应字体以及如何在RedHat和Debian类的系统中使用Bash和Vim支持Powerline。
### Step 1: Installing Generic Requirements for Powerline
### 第一步准备好安装Powerline需要的软件
Due to a naming conflict with some other unrelated projects, powerline program is available on PyPI (Python Package Index) under the package name as powerline-status.
由于和其他不相干项目之间存在命名冲突因此powerline只能放在PyPI(Python Package Index)中的powerline-status包下.
To install packages from PyPI, we need a pip (package management tool for installing Python packages). So, lets first install pip tool under our Linux systems.
为了从PyPI中安装该包需要先准备好pip(该工具专门用于Python包的管理)工具。所以首先要在Linux系统下安装好pip工具。
#### Install Pip on Debian, Ubuntu and Linux Mint
#### 在Debian,Ubuntu和Linux Mint中安装Pip的方法
```
# apt-get install python-pip
```
##### Sample Output
##### 示例输出
```
Reading package lists... Done
@ -66,16 +64,16 @@ Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up python-pip (1.5.4-1ubuntu3) ...
```
#### Install Pip on CentOS, RHEL and Fedora
#### 在CentOSRHEL和Fedora中安装Pip
Under Fedora-based systems, you need to first [enable epel-repository][4] and then install pip package as shown.
在Fedora类系统中需要先打开[epel-repository][4]然后按照如下方法安装pip包。
```
# yum install python-pip
# dnf install python-pip [On Fedora 22+ versions]
```
##### Sample Output
##### 示例输出
```
Installing:
@ -99,9 +97,9 @@ python-pip.noarch 0:7.1.0-1.el7
Complete!
```
### Step 2: Installing Powerline Tool in Linux
### 第二步在Linux中安装Powerline
Now its time to install Powerline latest development version from the Git repository. For this, your system must have git package installed in order to fetch the packages from Git.
现在可以从Git仓库中安装Powerline的最新开发版。在此之前系统需要安装好Git工具以便可以从仓库拉下代码。
```
# apt-get install git
@ -109,13 +107,12 @@ Now its time to install Powerline latest development version from the G
# dnf install git
```
Next you can install Powerline with the help of pip command as shown.
然后你可以通过pip命令安装Powerline。
```
# pip install git+git://github.com/Lokaltog/powerline
```
##### Sample Output
##### 示例输出
```
Cloning git://github.com/Lokaltog/powerline to /tmp/pip-WAlznH-build
@ -140,51 +137,47 @@ changing mode of /usr/local/bin/powerline-daemon to 755
Successfully installed powerline-status
Cleaning up...
```
### 第三步在Linux中安装Powerline的字体
### Step 3: Installing Powerline Fonts in Linux
Powerline使用特殊的符号来为开发者显示特殊的箭头效果和符号内容。因此你的系统中必须要有符号字体或者补丁字体。
Powerline uses special glyphs to show special arrow effect and symbols for developers. For this, you must have a symbol font or a patched font installed on your systems.
Download the most recent version of the symbol font and fontconfig configuration file using following [wget command][5].
通过下面的[wget][5]命令下载最新的系统字体及字体配置文件。
```
# 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 need to move the font to your fonts directory, /usr/share/fonts/ or /usr/local/share/fonts as follows or you can get the valid font paths by using command `xset q`.
然后你将下载的字体放到字体目录下/usr/share/fonts或者/usr/local/share/fonts或者你可以通过'xset q'命令找到一个有效的字体目录。
```
# mv PowerlineSymbols.otf /usr/share/fonts/
```
Next, you need to update your systems font cache as follows.
接下来你需要通过如下命令更新你系统的字体缓存。
```
# fc-cache -vf /usr/share/fonts/
```
Now install the fontconfig file.
其次安装字体配置文件。
```
# mv 10-powerline-symbols.conf /etc/fonts/conf.d/
```
注意如果相应的符号没有出现可以尝试关闭终端会话并重启X window这样就会生效了。
Note: If custom symbols doesnt appear, then try to close all terminal sessions and restart X window for the changes to take effect.
### 步骤4给Bash Shell和Vim状态行设置Powerline
### Step 4: Setting Powerline for Bash Shell and Vim Statuslines
In this section we shall look at configuring Powerline for bash shell and vim editor. First make your terminal to support 256color by adding the following line to ~/.bashrc file as follows.
在这一节将介绍bash shell和vim editor中关于Powerline的配置。首先通过在~/.bashrc中添加如下内容以便设置终端为256色。
```
export TERM=”screen-256color”
```
#### Enable Powerline on Bash Shell
#### 打开Bash Shell中的Powerline
To enable Powerline in bash shell by default, you need to add the following snippet to your ~/.bashrc file.
如果希望在bash shell中默认打开Powerline可以在~/.bashrc中添加如下内容。
First get the location of installed powerline using following command.
首先通过如下命令获取powerline的安装位置。
```
# pip show powerline-status
@ -194,7 +187,7 @@ Location: /usr/local/lib/python2.7/dist-packages
Requires:
```
Once you know the actual location of powerline, make sure to replace the location in the below line as per your system suggested.
一旦找到powerline的真正位置后建议最好替换到下面的位置。
```
powerline-daemon -q
@ -202,20 +195,19 @@ POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
. /usr/local/lib/python2.7/dist-packages/powerline/bindings/bash/powerline.sh
```
Now try to logout and login back again, you will see powerline statuesline as shown below.
然后退出后重新登录现在powerline的状态行应该如下显示了。
[
![Bash Powerline Statuslines](http://www.tecmint.com/wp-content/uploads/2015/10/Bash-Powerline-Statuslines.gif)
][6]
Try changing or switching to different directories and keep a eye on “breadcrumb” prompt changes to show your current location.
现在切换目录并注意显示你当前路径的面包屑提示的变化。
You will also be able to watch pending background jobs and if powerline is installed on a remote Linux machine, you can notice that the prompt adds the hostname when you connect via SSH.
如果远程Linux服务器上安装了powerline当你用ssh登录上去查看当前正在后台运行的任务时会看到主机名提示发生变化。
#### Enable Powerline for Vim
#### 在Vim中打开Powerline
If vim is your favorite editor, luckily there is a powerful plugin for vim, too. To enable this plugin, add these lines to `~/.vimrc` file.
如果你喜欢使用vim正好有一个vim的强力插件。可以在~/.vimrc中添加如下内容打开该插件。
```
set rtp+=/usr/local/lib/python2.7/dist-packages/powerline/bindings/vim/
@ -223,15 +215,15 @@ set laststatus=2
set t_Co=256
```
Now you can launch vim and see a spiffy new status line:
然后你打开vim后会看到一个新的状态行:
[
![Vim Powerline Statuslines](http://www.tecmint.com/wp-content/uploads/2015/10/Vim-Powerline-Statuslines.gif)
][7]
### Summary
### 总结
Powerline helps to set colorful and beautiful statuslines and prompts in several applications, good for coding environments. I hope you find this guide helpful and remember to post a comment if you need any help or have additional ideas.
Powerline可以在某些软件中提供颜色鲜艳、很优美的状态行及提示内容,这对编程环境有利。希望这篇指南对您有帮助,如果您需要帮助或者有任何好的想法,请留言给我。
--------------------------------------------------------------------------------
@ -239,14 +231,14 @@ Powerline helps to set colorful and beautiful statuslines and prompts in severa
![](http://1.gravatar.com/avatar/7badddbc53297b2e8ed7011cf45df0c0?s=128&d=blank&r=g)
I am Ravi Saive, creator of TecMint. A Computer Geek and Linux Guru who loves to share tricks and tips on Internet. Most Of My Servers runs on Open Source Platform called Linux. Follow Me: Twitter, Facebook and Google+
我是Ravi SaiveTecMint的作者。一个喜欢分享诀窍和想法的电脑极客及Linux专家。我的大部分服务都运行在开源平台Linux中。关注我的TwitterFacebook和Google+。
--------------------------------------------------------------------------------
via: http://www.tecmint.com/powerline-adds-powerful-statuslines-and-prompts-to-vim-and-bash/
作者:[Ravi Saive][a]
译者:[译者ID](https://github.com/译者ID)
译者:[beyondworld](https://github.com/beyondworld)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出