mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-29 21:41:00 +08:00
Merge branch 'master' of https://github.com/LCTT/TranslateProject into new
This commit is contained in:
commit
a79aa6bcae
53
published/20180518 Mastering CI-CD at OpenDev.md
Normal file
53
published/20180518 Mastering CI-CD at OpenDev.md
Normal file
@ -0,0 +1,53 @@
|
||||
在 OpenDev 大会上学习 CI/CD
|
||||
======
|
||||
> 未来的开发工作需要非常精通 CI/CD 流程。
|
||||
|
||||
![在OpenDev上,掌握CI/CD](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_opennature_3.png?itok=J1OSECM_)
|
||||
|
||||
在 2017 年启动后,OpenDev 大会现在已是一个年度活动。在去年 9 月的首届活动上,会议的重点是边缘计算。今年的活动,于 5 月 22 - 23 日举行,会议的重点是持续集成和持续发布 (CI/CD),并与 OpenStack 峰会一起在温哥华举行。
|
||||
|
||||
基于我在 OpenStack 项目的 CI/CD 系统的技术背景和我近期进入容器下的 CI/CD 方面的经验,我被邀请加入 OpenDev CI/CD 计划委员会。今天我经常借助很多开源技术,例如 [Jenkins][3]、[GitLab][2]、[Spinnaker][4] 和 [Artifactory][5] 来讨论 CI/CD 流程。
|
||||
|
||||
这次活动对我来说是很激动人心的,因为我们将在这个活动中融合两个开源基础设施理念。首先,我们将讨论可以被任何组织使用的 CI/CD 工具。为此目的,在 [讲演][6] 中,我们将听到关于开源 CI/CD 工具的使用讲演,一场来自 Boris Renski 的关于 Spinnaker 的讲演,和一场来自 Jim Blair 的关于 [Zuul][7] 的讲演。同时,讲演会涉及关于开源技术的偏好的高级别话题,特别是那种跨社区的和本身就是开源项目的。从Fatih Degirmenci 和 Daniel Farrel 那里,我们将听到关于在不同社区分享持续发布实践经历,接着 Benjamin Mako Hill 会为我们带来一场关于为什么自由软件需要自由工具的分享。
|
||||
|
||||
在分享 CI/CD 相对新颖的特性后,接下来的活动是对话、研讨会和协作讨论的混合组合。当从人们所提交的讲座和研讨会中进行选择,并提出协作讨论主题时,我们希望确保有一个多样灵活的日程表,这样任何参与者都能在 CI/CD 活动进程中发现有趣的东西。
|
||||
|
||||
这些讲座会是标准的会议风格,选择涵盖关键主题,如制定 CI/CD 流程,在实践 DevOps 时提升安全性,以及更具体的解决方案,如基于容器关于 Kubernetes 的 [Aptomi][8] 和在 ETSI NFV 环境下 CI/CD。这些会话的大部分将会是作为给新接触 CI/CD 或这些特定技术的参与者关于这些话题和理念的简介。
|
||||
|
||||
交互式的研讨会会持续相对比较长的时间,参与者将会在思想上得到特定的体验。这些研讨会包括 “[在持续集成任务中的异常检测][9]”、“[如何安装 Zuul 和配置第一个任务][10]”,和“[Spinnake 101:快速可靠的软件发布][11]”。(注意这些研讨会空间是有限的,所以设立了一个 RSVP 系统。你们将会在会议的链接里找到一个 RSVP 的按钮。)
|
||||
|
||||
可能最让我最兴奋的是协作讨论,这些协作讨论占据了一半以上的活动安排。协作讨论的主题由计划委员会选取。计划委员会根据我们在社区里所看到来选取对应的主题。这是“鱼缸”风格式的会议,通常是几个人聚在一个房间里围绕着 CI/CD 讨论某一个主题。
|
||||
|
||||
这次会议风格的理念是来自于开发者峰会,最初是由 Ubuntu 社区提出,接着 OpenStack 社区也在活动上采纳。这些协作讨论的主题包含不同的会议,这些会议是关于 CI/CD 基础,可以鼓励跨社区协作的提升举措,在组织里推行 CI/CD 文化,和为什么开源 CI/CD 工具如此重要。采用共享文档来做会议笔记,以确保尽可能的在会议的过程中分享知识。在讨论过程中,提出行动项目也是很常见的,因此社区成员可以推动和所涉及的主题相关的倡议。
|
||||
|
||||
活动将以联合总结会议结束。联合总结会议将总结来自协同讨论的关键点和为即将在这个领域工作的参与者指出可选的职业范围。
|
||||
|
||||
可以在 [OpenStack 峰会注册页][13] 上注册参加活动。或者可以在温哥华唯一指定售票的会议中心购买活动的入场券,价格是 $199。更多关于票和全部的活动安排见官网 [OpenDev 网站][1]。
|
||||
|
||||
我希望你们能够加入我们,并在温哥华渡过令人激动的两天,并且在这两天的活动中学习,协作和在 CI/CD 取得进展。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/5/opendev
|
||||
|
||||
作者:[Elizabeth K.Joseph][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[jamelouis](https://github.com/jamelouis)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://opensource.com/users/pleia2
|
||||
[1]:http://2018.opendevconf.com/
|
||||
[2]:https://about.gitlab.com/
|
||||
[3]:https://jenkins.io/
|
||||
[4]:https://www.spinnaker.io/
|
||||
[5]:https://jfrog.com/artifactory/
|
||||
[6]:http://2018.opendevconf.com/schedule/
|
||||
[7]:https://zuul-ci.org/
|
||||
[8]:http://aptomi.io/
|
||||
[9]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21692/anomaly-detection-in-continuous-integration-jobs
|
||||
[10]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21693/how-to-install-zuul-and-configure-your-first-jobs
|
||||
[11]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21699/spinnaker-101-releasing-software-with-velocity-and-confidence
|
||||
[12]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21831/opendev-cicd-joint-collab-conclusion
|
||||
[13]:https://www.eventbrite.com/e/openstack-summit-may-2018-vancouver-tickets-40845826968?aff=VancouverSummit2018
|
@ -1,30 +1,34 @@
|
||||
在Linux上使用 i3 作为窗口管理器的入门教程
|
||||
i3 窗口管理器入门
|
||||
======
|
||||
|
||||
> 本篇文章会介绍如何在 Fedora 系统中,安装、配置、使用 i3 瓦片式桌面管理器。
|
||||
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/windows-tiling-windows-wall.png?itok=mTH7uVrn)
|
||||
|
||||
在我的文章[5 reasons the i3 window manager makes Linux better][1],我分享了选择 [i3 window manager][2] 作为一种Linux桌面替代方案的最主要五个理由。
|
||||
在本篇文章中,我将向大家展示,如何在 Fedora 28 上安装与配置 i3。
|
||||
在我的文章 [i3 桌面让 Linux 更好的 5 个理由][1],我分享了选择 [i3 桌面管理器][2] 作为一种 Linux 桌面替代方案的最主要五个理由。
|
||||
|
||||
### 1\. 安装
|
||||
在本篇文章中,我将向大家展示,如何在 Fedora 28 上安装与简单配置 i3。
|
||||
|
||||
### 1、 安装
|
||||
|
||||
首先进入 Fedora 系统中,打开一个终端。使用 `dnf` 来安装需要的软件包,如下:
|
||||
|
||||
```
|
||||
[ricardo@f28i3 ~]$ sudo dnf install -y i3 i3-ipc i3status i3lock dmenu terminator --exclude=rxvt-unicode
|
||||
Last metadata expiration check: 1:36:15 ago on Wed 08 Aug 2018 12:04:31 PM EDT.
|
||||
Dependencies resolved.
|
||||
================================================================================================
|
||||
Package Arch Version Repository Size
|
||||
Package Arch Version Repository Size
|
||||
================================================================================================
|
||||
Installing:
|
||||
dmenu x86_64 4.8-1.fc28 fedora 33 k
|
||||
i3 x86_64 4.15-1.fc28 fedora 323 k
|
||||
i3-ipc noarch 0.1.4-12.fc28 fedora 14 k
|
||||
i3lock x86_64 2.9.1-2.fc28 fedora 33 k
|
||||
i3status x86_64 2.12-1.fc28 updates 62 k
|
||||
terminator noarch 1.91-4.fc28 fedora 570 k
|
||||
dmenu x86_64 4.8-1.fc28 fedora 33 k
|
||||
i3 x86_64 4.15-1.fc28 fedora 323 k
|
||||
i3-ipc noarch 0.1.4-12.fc28 fedora 14 k
|
||||
i3lock x86_64 2.9.1-2.fc28 fedora 33 k
|
||||
i3status x86_64 2.12-1.fc28 updates 62 k
|
||||
terminator noarch 1.91-4.fc28 fedora 570 k
|
||||
Installing dependencies:
|
||||
dzen2 x86_64 0.8.5-21.20100104svn.fc28 fedora 60 k
|
||||
dzen2 x86_64 0.8.5-21.20100104svn.fc28 fedora 60 k
|
||||
|
||||
... Skipping dependencies/install messages
|
||||
|
||||
@ -36,55 +40,56 @@ Complete!
|
||||
|
||||
据用户目前的系统状态,在命令执行过程中可能会安装很多依赖。等待所有的依赖安装完成,之后重启你的电脑。
|
||||
|
||||
### 2. 登录与初始化
|
||||
### 2、 首次登录与初始化
|
||||
|
||||
在你的机器重启之后,你便可以第一次体验 i3 了。在 GNOME Display Manager (GDM),选择你的用户名,之后先别着急输密码,点击下方的密码输入框下方的小齿轮,之后选择 i3 ,像下方这样:
|
||||
在你的机器重启之后,你便可以第一次体验 i3 了。在 GNOME 显示管理器(GDM)屏幕,选择你的用户名,之后先别着急输密码,点击下方的密码输入框下方的小齿轮,之后选择 i3 而不是 GNOME,像下方这样:
|
||||
|
||||
![](https://opensource.com/sites/default/files/uploads/i3_first_login_small.png)
|
||||
|
||||
输入你的密码,并点击 `Sign In`。在你第一次登入之后,会先看到 i3 的配置界面:
|
||||
输入你的密码,并点击 “Sign In”。在你第一次登入之后,会先看到 i3 的配置界面:
|
||||
|
||||
![](https://opensource.com/sites/default/files/uploads/i3_first_configuration_small.png)
|
||||
|
||||
点击 `ENTER` 就会在 `$HOME/.config/i3` 生成一个配置文件,之后你可以通过这个配置文件来定制化 i3's 的一些行为。
|
||||
点击回车键就会在 `$HOME/.config/i3` 生成一个配置文件,之后你可以通过这个配置文件来定制化 i3 的一些行为。
|
||||
|
||||
在下一屏,你需要选择你的 `Mod` 键。这一步很关键,因为 `Mod` 键通常都会作为 i3's 命令快捷键的发起键。按 `ENTER` 会选择 `Win` 键作为默认的 `Mod` 键。如果你的键盘没有 `Win` 键,用 `Alt` 键做替代,用方向键键选择后按 `ENTER` 确认。
|
||||
在下一屏,你需要选择你的 `Mod` 键。这一步很关键,因为 `Mod` 键通常都会作为 i3 命令快捷键的发起键。按回车会选择 `Win` 键作为默认的 `Mod` 键。如果你的键盘没有 `Win` 键,用 `Alt` 键做替代,用方向键键选择后按回车键确认。
|
||||
|
||||
![](https://opensource.com/sites/default/files/uploads/i3_generate_config_small.png)
|
||||
|
||||
现在你就登录到了 i3 的系统中。由于 i3 是一个最小化的窗口管理器,你会看到一个黑屏窗口,以及屏幕底端显式的状态栏:
|
||||
现在你就登录到了 i3 的系统中。由于 i3 是一个极简的窗口管理器,你会看到一个黑屏窗口,以及屏幕底端显示的状态栏:
|
||||
|
||||
![](https://opensource.com/sites/default/files/uploads/i3_start_small.png)
|
||||
|
||||
接下来,让我们看看 i3 的如何实际使用。
|
||||
|
||||
### 3\. 基本的快捷键
|
||||
### 3、 基本的快捷键
|
||||
|
||||
现在你已经登录到了 i3 的会话中,你需要几个基本的快捷键来应对基本的操作。
|
||||
现在你已经登录到了 i3 会话中,你需要几个基本的快捷键来应对基本的操作。
|
||||
|
||||
大多数的 i3 快捷键都会用到之前配置的 `Mod` 键。在下面的例子中,当我提到 `Mod` 键,请根据情况使用你定义的做替换。通常使用 `Win` 键或者 `Alt` 键。
|
||||
|
||||
首先,打开一个终端,使用 `Mod+ENTER`。重复打开几个终端,观察 i3 是如何自动将它们在桌面中排列。默认情况下, i3 会在水平的方向分割屏幕;使用 `Mod + v` 来垂直分割,再按 `Mod + h` 会恢复水平分割模式。
|
||||
首先,要打开一个终端,可以使用 `Mod+ENTER`。重复打开几个终端,观察 i3 是如何自动将它们在桌面中排列。默认情况下, i3 会在水平的方向分割屏幕;使用 `Mod + v` 来垂直分割,再按 `Mod + h` 会恢复水平分割模式。
|
||||
|
||||
![](https://opensource.com/sites/default/files/uploads/i3_3terminal_tiled_small.png)
|
||||
|
||||
当需要启动其他的应用,按 `Mod + d` 来打开 `dmenu`,一个简单的文字应用菜单。默认情况下,`dmenu` 会呈现出所有在你 `$PATH` 中设置的应用。使用方向键来选择你想启动的应用,同时你可以键入应用的名称,来缩小选择的范围,之后按 `ENTER` 来启动选择的应用。
|
||||
当需要启动其他的应用,按 `Mod + d` 来打开 `dmenu`,一个简单的文字应用菜单。默认情况下,`dmenu` 会呈现出所有在你 `$PATH` 中设置的应用。使用方向键来选择你想启动的应用,同时你可以键入应用的名称,来缩小选择的范围,之后按回车键来启动选择的应用。
|
||||
|
||||
![](https://opensource.com/sites/default/files/uploads/i3_dmenu.png)
|
||||
|
||||
如果你的应用没有提供退出的方法,你可以使用 i3 来关闭对应的窗口,通过按 `Mod + Shift +q`。注意,你可能会丢失未保存的工作内容。
|
||||
|
||||
最后,当你想关闭会话并退出 i3,按 `Mod + Shift +e`。之后会在窗口的上方提示你是否退出。点击 `Yes, exit i3` 退出,或选择 `X` 来取消。
|
||||
最后,当你想关闭会话并退出 i3,按 `Mod + Shift +e`。之后会在窗口的上方提示你是否退出。点击 “Yes, exit i3” 退出,或选择 “X” 来取消。
|
||||
|
||||
![](https://opensource.com/sites/default/files/uploads/i3_exit_small.png)
|
||||
|
||||
这些就是 i3 中最基本的快捷键,如果想了解更多,请查阅官方文档 [documentation][3]。
|
||||
这些就是 i3 中最基本的快捷键,如果想了解更多,请查阅官方[文档][3]。
|
||||
|
||||
### 4\. 替换GDM
|
||||
### 4、 替换 GDM
|
||||
|
||||
使用 i3 window manager 会降低你操作系统的内存占用;然而,Fedora 依然会使用 GDM 作为登录的窗口。GDM 会载入几个与 GNOME 相关的库从而占用内存。
|
||||
使用 i3 窗口管理器会降低你操作系统的内存占用;然而,Fedora 依然会使用 GDM 作为登录屏。GDM 会载入几个与 GNOME 相关的库从而占用内存。
|
||||
|
||||
如果你想进一步的降低你的内存占用,你可以使用一些更轻量级的显示管理器来替换 GDM,比如 lightdm :
|
||||
|
||||
如果你想进一步的降低你的内存占用,你可以使用一些更轻量级的窗口管理器来替换 GDM,比如 `lightdm`:
|
||||
```
|
||||
[ricardo@f28i3 ~]$ sudo dnf install -y lightdm
|
||||
[ricardo@f28i3 ~]$ sudo systemctl disable gdm
|
||||
@ -107,7 +112,7 @@ via: https://opensource.com/article/18/8/getting-started-i3-window-manager
|
||||
作者:[Ricardo Gerardi][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[sd886393](https://github.com/sd886393)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -1,3 +1,4 @@
|
||||
belitex 翻译中
|
||||
How to get into DevOps
|
||||
======
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003784_02_os.comcareers_resume_rh1x.png?itok=S3HGxi6E)
|
||||
|
@ -1,292 +0,0 @@
|
||||
5 tips to improve productivity with zsh
|
||||
======
|
||||
|
||||
### **[翻译中] by tnuoccalanosrep**
|
||||
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/features_solutions_command_data.png?itok=4_VQN3RK)
|
||||
|
||||
The Z shell known as [zsh][1] is a [shell][2] for Linux/Unix-like operating systems. It has similarities to other shells in the `sh` (Bourne shell) family, such as as `bash` and `ksh`, but it provides many advanced features and powerful command line editing options, such as enhanced Tab completion.
|
||||
|
||||
It would be impossible to cover all the options of zsh here; there are literally hundreds of pages [documenting][3] its many features. In this article, I'll present five tips to make you more productive using the command line with zsh.
|
||||
|
||||
### 1\. Themes and plugins
|
||||
|
||||
Through the years, the open source community has developed countless themes and plugins for zsh. A theme is a predefined prompt configuration, while a plugin is a set of useful aliases and functions that make it easier to use a specific command or programming language.
|
||||
|
||||
The quickest way to get started using themes and plugins is to use a zsh configuration framework. There are many available, but the most popular is [Oh My Zsh][4]. By default, it enables some sensible zsh configuration options and it comes loaded with hundreds of themes and plugins.
|
||||
|
||||
A theme makes you more productive as it adds useful information to your prompt, such as the status of your Git repository or Python virtualenv in use. Having this information at a glance saves you from typing the equivalent commands to obtain it, and it's a cool look. Here's an example of [Powerlevel9k][5], my theme of choice:
|
||||
|
||||
![zsh Powerlevel9K theme][7]
|
||||
|
||||
The Powerlevel9k theme for zsh
|
||||
|
||||
In addition to themes, Oh My Zsh bundles tons of useful plugins for zsh. For example, enabling the Git plugin gives you access to a number of useful aliases, such as:
|
||||
```
|
||||
$ alias | grep -i git | sort -R | head -10
|
||||
g=git
|
||||
ga='git add'
|
||||
gapa='git add --patch'
|
||||
gap='git apply'
|
||||
gdt='git diff-tree --no-commit-id --name-only -r'
|
||||
gau='git add --update'
|
||||
gstp='git stash pop'
|
||||
gbda='git branch --no-color --merged | command grep -vE "^(\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d'
|
||||
gcs='git commit -S'
|
||||
glg='git log --stat'
|
||||
```
|
||||
|
||||
There are plugins available for many programming languages, packaging systems, and other tools you commonly use on the command line. Here's a list of plugins I use in my Fedora workstation:
|
||||
```
|
||||
git golang fedora docker oc sudo vi-mode virtualenvwrapper
|
||||
```
|
||||
|
||||
### 2\. Clever aliases
|
||||
|
||||
Aliases are very useful in zsh. Defining aliases for your most-used commands saves you a lot of typing. Oh My Zsh configures several useful aliases by default, including aliases to navigate directories and replacements for common commands with additional options such as:
|
||||
```
|
||||
ls='ls --color=tty'
|
||||
grep='grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn}'
|
||||
```
|
||||
|
||||
In addition to command aliases, zsh enables two additional useful alias types: the suffix alias and the global alias.
|
||||
|
||||
A suffix alias allows you to open the file you type in the command line using the specified program based on the file extension. For example, to open YAML files using vim, define the following alias:
|
||||
```
|
||||
alias -s {yml,yaml}=vim
|
||||
```
|
||||
|
||||
Now if you type any file name ending with `yml` or `yaml` in the command line, zsh opens that file using vim:
|
||||
```
|
||||
$ playbook.yml
|
||||
# Opens file playbook.yml using vim
|
||||
```
|
||||
|
||||
A global alias enables you to create an alias that is expanded anywhere in the command line, not just at the beginning. This is very useful to replace common filenames or piped commands. For example:
|
||||
```
|
||||
alias -g G='| grep -i'
|
||||
```
|
||||
|
||||
To use this alias, type `G` anywhere you would type the piped command:
|
||||
```
|
||||
$ ls -l G do
|
||||
drwxr-xr-x. 5 rgerardi rgerardi 4096 Aug 7 14:08 Documents
|
||||
drwxr-xr-x. 6 rgerardi rgerardi 4096 Aug 24 14:51 Downloads
|
||||
```
|
||||
|
||||
Next, let's see how zsh helps to navigate the filesystem.
|
||||
|
||||
### 3\. Easy directory navigation
|
||||
|
||||
When you're using the command line, navigating across different directories is one of the most common tasks. Zsh makes this easier by providing some useful directory navigation features. These features are enabled with Oh My Zsh, but you can enable them by using this command:
|
||||
```
|
||||
setopt autocd autopushd \ pushdignoredups
|
||||
```
|
||||
|
||||
With these options set, you don't need to type `cd` to change directories. Just type the directory name, and zsh switches to it:
|
||||
```
|
||||
$ pwd
|
||||
/home/rgerardi
|
||||
$ /tmp
|
||||
$ pwd
|
||||
/tmp
|
||||
```
|
||||
|
||||
To move back, type `-`:
|
||||
|
||||
Zsh keeps the history of directories you visited so you can quickly switch to any of them. To see the list, type `dirs -v`:
|
||||
```
|
||||
$ dirs -v
|
||||
0 ~
|
||||
1 /var/log
|
||||
2 /var/opt
|
||||
3 /usr/bin
|
||||
4 /usr/local
|
||||
5 /usr/lib
|
||||
6 /tmp
|
||||
7 ~/Projects/Opensource.com/zsh-5tips
|
||||
8 ~/Projects
|
||||
9 ~/Projects/ansible
|
||||
10 ~/Documents
|
||||
```
|
||||
|
||||
Switch to any directory in this list by typing `~#` where # is the number of the directory in the list. For example:
|
||||
```
|
||||
$ pwd
|
||||
/home/rgerardi
|
||||
$ ~4
|
||||
$ pwd
|
||||
/usr/local
|
||||
```
|
||||
|
||||
Combine these with aliases to make it even easier to navigate:
|
||||
```
|
||||
d='dirs -v | head -10'
|
||||
1='cd -'
|
||||
2='cd -2'
|
||||
3='cd -3'
|
||||
4='cd -4'
|
||||
5='cd -5'
|
||||
6='cd -6'
|
||||
7='cd -7'
|
||||
8='cd -8'
|
||||
9='cd -9'
|
||||
```
|
||||
|
||||
Now you can type `d` to see the first ten items in the list and the number to switch to it:
|
||||
```
|
||||
$ d
|
||||
0 /usr/local
|
||||
1 ~
|
||||
2 /var/log
|
||||
3 /var/opt
|
||||
4 /usr/bin
|
||||
5 /usr/lib
|
||||
6 /tmp
|
||||
7 ~/Projects/Opensource.com/zsh-5tips
|
||||
8 ~/Projects
|
||||
9 ~/Projects/ansible
|
||||
$ pwd
|
||||
/usr/local
|
||||
$ 6
|
||||
/tmp
|
||||
$ pwd
|
||||
/tmp
|
||||
```
|
||||
|
||||
Finally, zsh automatically expands directory names with Tab completion. Type the first letters of the directory names and `TAB` to use it:
|
||||
```
|
||||
$ pwd
|
||||
/home/rgerardi
|
||||
$ p/o/z (TAB)
|
||||
$ Projects/Opensource.com/zsh-5tips/
|
||||
```
|
||||
|
||||
This is just one of the features enabled by zsh's powerful Tab completion system. Let's look at some more.
|
||||
|
||||
### 4\. Advanced Tab completion
|
||||
|
||||
Zsh's powerful completion system is one of its hallmarks. For simplification, I call it Tab completion, but under the hood, more than one thing is happening. There's usually expansion and command completion. I'll discuss them together here. For details, check this [User's Guide][8].
|
||||
|
||||
Command completion is enabled by default with Oh My Zsh. To enable it, add the following lines to your `.zshrc` file:
|
||||
```
|
||||
autoload -U compinit
|
||||
compinit
|
||||
```
|
||||
|
||||
Zsh's completion system is smart. It tries to suggest only items that can be used in certain contexts—for example, if you type `cd` and `TAB`, zsh suggests only directory names as it knows `cd` does not work with anything else.
|
||||
|
||||
Conversely, it suggests usernames when running user-related commands or hostnames when using `ssh` or `ping`, for example.
|
||||
|
||||
It has a vast completion library and understands many different commands. For example, if you're using the `tar` command, you can press Tab to see a list of files available in the package as candidates for extraction:
|
||||
```
|
||||
$ tar -xzvf test1.tar.gz test1/file1 (TAB)
|
||||
file1 file2
|
||||
```
|
||||
|
||||
Here's a more advanced example, using `git`. In this example, when typing `TAB`, zsh automatically completes the name of the only file in the repository that can be staged:
|
||||
```
|
||||
$ ls
|
||||
original plan.txt zsh-5tips.md zsh_theme_small.png
|
||||
$ git status
|
||||
On branch master
|
||||
Your branch is up to date with 'origin/master'.
|
||||
|
||||
Changes not staged for commit:
|
||||
(use "git add <file>..." to update what will be committed)
|
||||
(use "git checkout -- <file>..." to discard changes in working directory)
|
||||
|
||||
modified: zsh-5tips.md
|
||||
|
||||
no changes added to commit (use "git add" and/or "git commit -a")
|
||||
$ git add (TAB)
|
||||
$ git add zsh-5tips.md
|
||||
```
|
||||
|
||||
It also understands command line options and suggests only the ones that are relevant to the subcommand selected:
|
||||
```
|
||||
$ git commit - (TAB)
|
||||
--all -a -- stage all modified and deleted paths
|
||||
--allow-empty -- allow recording an empty commit
|
||||
--allow-empty-message -- allow recording a commit with an empty message
|
||||
--amend -- amend the tip of the current branch
|
||||
--author -- override the author name used in the commit
|
||||
--branch -- show branch information
|
||||
--cleanup -- specify how the commit message should be cleaned up
|
||||
--date -- override the author date used in the commit
|
||||
--dry-run -- only show the list of paths that are to be committed or not, and any untracked
|
||||
--edit -e -- edit the commit message before committing
|
||||
--file -F -- read commit message from given file
|
||||
--gpg-sign -S -- GPG-sign the commit
|
||||
--include -i -- update the given files and commit the whole index
|
||||
--interactive -- interactively update paths in the index file
|
||||
--message -m -- use the given message as the commit message
|
||||
... TRUNCATED ...
|
||||
```
|
||||
|
||||
After typing `TAB`, you can use the arrow keys to navigate the options list and select the one you need. Now you don't need to memorize all those Git options.
|
||||
|
||||
There are many options available. The best way to find what is most helpful to you is by using it.
|
||||
|
||||
### 5\. Command line editing and history
|
||||
|
||||
Zsh's command line editing capabilities are also useful. By default, it emulates emacs. If, like me, you prefer vi/vim, enable vi bindings with the following command:
|
||||
```
|
||||
$ bindkey -v
|
||||
```
|
||||
|
||||
If you're using Oh My Zsh, the `vi-mode` plugin enables additional bindings and a mode indicator on your prompt—very useful.
|
||||
|
||||
After enabling vi bindings, you can edit the command line using vi commands. For example, press `ESC+/` to search the command line history. While searching, pressing `n` brings the next matching line, and `N` the previous one. Most common vi commands work after pressing `ESC` such as `0` to jump to the start of the line, `$` to jump to the end, `i` to insert, `a` to append, etc. Even commands followed by motion work, such as `cw` to change a word.
|
||||
|
||||
In addition to command line editing, zsh provides several useful command line history features if you want to fix or re-execute previous used commands. For example, if you made a mistake, typing `fc` brings the last command in your favorite editor to fix it. It respects the `$EDITOR` variable and by default uses vi.
|
||||
|
||||
Another useful command is `r`, which re-executes the last command; and `r <WORD>`, which executes the last command that contains the string `WORD`.
|
||||
|
||||
Finally, typing double bangs (`!!`) brings back the last command anywhere in the line. This is useful, for instance, if you forgot to type `sudo` to execute commands that require elevated privileges:
|
||||
```
|
||||
$ less /var/log/dnf.log
|
||||
/var/log/dnf.log: Permission denied
|
||||
$ sudo !!
|
||||
$ sudo less /var/log/dnf.log
|
||||
```
|
||||
|
||||
These features make it easier to find and re-use previously typed commands.
|
||||
|
||||
### Where to go from here?
|
||||
|
||||
These are just a few of the zsh features that can make you more productive; there are many more. For additional information, consult the following resources:
|
||||
|
||||
[An Introduction to the Z Shell][9]
|
||||
|
||||
[A User's Guide to ZSH][10]
|
||||
|
||||
[Archlinux Wiki][11]
|
||||
|
||||
[zsh-lovers][12]
|
||||
|
||||
Do you have any zsh productivity tips to share? I would love to hear about them in the comments below.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/9/tips-productivity-zsh
|
||||
|
||||
作者:[Ricardo Gerardi][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/rgerardi
|
||||
[1]: http://www.zsh.org/
|
||||
[2]: https://en.wikipedia.org/wiki/Shell_(computing)
|
||||
[3]: http://zsh.sourceforge.net/Doc/Release/zsh_toc.html
|
||||
[4]: https://ohmyz.sh/
|
||||
[5]: https://github.com/bhilburn/powerlevel9k
|
||||
[7]: https://opensource.com/sites/default/files/uploads/zsh_theme_small.png (zsh Powerlevel9K theme)
|
||||
[8]: http://zsh.sourceforge.net/Guide/zshguide06.html#l144
|
||||
[9]: http://zsh.sourceforge.net/Intro/intro_toc.html
|
||||
[10]: http://zsh.sourceforge.net/Guide/
|
||||
[11]: https://wiki.archlinux.org/index.php/zsh
|
||||
[12]: https://grml.org/zsh/
|
@ -1,3 +1,5 @@
|
||||
translating---geekpi
|
||||
|
||||
How To Configure Mouse Support For Linux Virtual Consoles
|
||||
======
|
||||
|
||||
|
@ -1,52 +0,0 @@
|
||||
在OpenDev上,掌握CI/CD(持续集成/持续发布)
|
||||
======
|
||||
|
||||
![在OpenDev上,掌握CI/CD](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_opennature_3.png?itok=J1OSECM_)
|
||||
|
||||
在2017年启动后,OpenDev会议现在是一个年度活动。在去年9月的首届活动上,会议的重点是边缘计算。今年的活动,将于5月22-23日举行,会议的重点是持续集成和持续发布 (CI/CD),并将与OpenStack峰会一起在温哥华举行。
|
||||
|
||||
基于我在OpenStack项目的CI/CD系统的技术背景和近期进入容器下的CI/CD方面的经验,我被邀请加入OpenDev CI/CD的编程委员会。今天我经常通过很多开源技术,例如[Jenkins][3] [GitLab][2],[Spinnaker][4],和[Artifactory][5],来讨论CI/CD流水管线。
|
||||
|
||||
这次活动对我来说是很激动人心的,因为我们将在这个活动中融合两个开源基础设施理念。首先,我们将讨论可以被任何组织使用的CI/CD工具。为此目的,在[keynotes][6],我们将听到关于开源CI/CD工具的使用讲座,一场来自Boris Renski的关于Spinnaker的和一场来自Jim Blair的关于[Zuul][7]的。同时,讲座会涉及关于开源技术的偏好的高级别话题,特别是那种跨社区的和本身就是开源项目的。从Fatih Degirmenci和Daniel Farrel那里,我们将听到关于在不同社区分享持续发布实践经历,接着Benjamin Mako Hill会为我带来一场关于为什么免费软件需要免费工具的分享。
|
||||
|
||||
在分享CI/CD相对新颖特性后,接下来的活动是对话,研讨会和协作讨论的混合组合。当从所提交的讲座和研讨会选择,并提出协作讨论主题时,我们希望确保有一个多样灵活的日程表,这样任何参与者都能在CI/CD活动进程中发现有趣的东西。
|
||||
|
||||
这些讲座会是标准的会议风格,选择以涵盖关键主题,如制作CI/CD管线,在实践DevOps时提升安全性,以及更具体的解决方案,如基于容器关于Kubernetes的[Aptomi][8]和在ETSI NFV环境下CI/CD。这些会话的大部分将会是作为给新接触CI/CD或这些特定技术的参与者关于这些话题和理念的简介。
|
||||
|
||||
交互式的研讨会会持续相对比较长的时间,参与者将会在思想上得到特定的体验。这些研讨会包括"[Anomaly Detection in Continous Integration Jobs(在持续集成任务中的异常检测)][9]","[How to Install Zuul and Configure Your First Jobs(如何安装Zuul和配置第一个任务)][10]",和"[Spinnake 101: Releasing Software with Velocity and Confidence(Spinnake 101:快速可靠的软件发布)][11]."(注意这些研讨会空间是有限的,所以设立了一个RSVP系统。你们将会在会议的链接里找到一个RSVP的按钮。)
|
||||
|
||||
可能最让我最兴奋的是协作讨论,这些协作讨论占据了一半以上的活动安排。协作讨论的主题由编程委员会选取。编程委员会是根据我们在社区里所看到选取对应的主题。这是“鱼缸”风格式的会议,通常是几个人聚在一个房间里围绕着CI/CD讨论某一个主题。
|
||||
|
||||
这次会议风格的理念是来自于开发者峰会,最初是由Ubuntu社区提出,接着OpenStack社区在活动上采纳。这些协作讨论的主题包含不同的会议,这些会议是关于CI/CD基础,可以鼓励跨社区协作的提升举措,在组织里推行CI/CD文化,和为什么开源CI/CD工具如此重要。采用共享文档来做会议笔记,以确保尽可能的在会议的过程中分享知识。在讨论过程中,提出行动项目也是很常见的,因此社区成员可以推动和所涉及的主题相关的倡议。
|
||||
|
||||
活动将以联合总结会议结束。联合总结会议将总结来自协同讨论的关键点和为即将在这个领域工作的参与者指出可选的职业范围。
|
||||
|
||||
可以在[OpenStack Summit registration(OpenStack峰会注册)][13]上注册参加活动。或者可以在温哥华唯一指定售票的会议中心购买活动的入场券,价格是$199。更多关于票和全部的活动安排见官网[OpenDev website][1]。
|
||||
|
||||
我希望你们能够加入我们,并在温哥华渡过令人激动的两天,并且在这两天的活动中学习,协作和在CI/CD取得进展。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/5/opendev
|
||||
|
||||
作者:[Elizabeth K.Joseph][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[jamelouis](https://github.com/jamelouis)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://opensource.com/users/pleia2
|
||||
[1]:http://2018.opendevconf.com/
|
||||
[2]:https://about.gitlab.com/
|
||||
[3]:https://jenkins.io/
|
||||
[4]:https://www.spinnaker.io/
|
||||
[5]:https://jfrog.com/artifactory/
|
||||
[6]:http://2018.opendevconf.com/schedule/
|
||||
[7]:https://zuul-ci.org/
|
||||
[8]:http://aptomi.io/
|
||||
[9]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21692/anomaly-detection-in-continuous-integration-jobs
|
||||
[10]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21693/how-to-install-zuul-and-configure-your-first-jobs
|
||||
[11]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21699/spinnaker-101-releasing-software-with-velocity-and-confidence
|
||||
[12]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21831/opendev-cicd-joint-collab-conclusion
|
||||
[13]:https://www.eventbrite.com/e/openstack-summit-may-2018-vancouver-tickets-40845826968?aff=VancouverSummit2018
|
@ -0,0 +1,313 @@
|
||||
用 zsh 提高生产力的5个 tips
|
||||
======
|
||||
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/features_solutions_command_data.png?itok=4_VQN3RK)
|
||||
|
||||
Z shell (亦称 zsh) 是 *unx 系统中的命令解析器 。 它跟 `sh` (Bourne shell) 家族的其他解析器 ( 如 `bash` 和 `ksh` ) 有着相似的特点,但它还提供了大量的高级特性以及强大的命令行编辑功能(选项?),如增强版tab补全。
|
||||
|
||||
由于 zsh 有好几百页的文档去描述他的特性,所以我无法在这里阐明 zsh 的所有功能。在本文,我会列出5个 tips,让你通过使用 zsh 来提高你的生产力。
|
||||
|
||||
### 1\. 主题和插件
|
||||
|
||||
多年来,开源社区已经为 zsh 开发了数不清的主题和插件。主题是预定义提示符的配置,而插件则是一组常用的别名命令和功能,让你更方便的使用一种特定的命令或者编程语言。
|
||||
|
||||
如果你现在想开始用 zsh 的主题和插件,那么使用 zsh 的配置框架 (configuiration framework) 是你最快的入门方式。在众多的配置框架中,最受欢迎的则是 [Oh My Zsh][4]。在默认配置中,他就已经为 zsh 启用了一些合理的配置,同时它也自带多个主题和插件。
|
||||
|
||||
由于主题会在你的命令行提示符之前添加一些常用的信息,比如你 Git 仓库的状态,或者是当前使用的 Python 虚拟环境,所以它会让你的工作更高效。只需要看到这些信息,你就不用再敲命令去重新获取它们,而且这些提示也相当酷炫。
|
||||
下图就是我(作者)选用的主题 [Powerlevel9k][5]
|
||||
|
||||
![zsh Powerlevel9K theme][7]
|
||||
|
||||
zsh 主题 Powerlevel9k
|
||||
|
||||
除了主题,Oh my Zsh 还自带了大量常用的 zsh 插件。比如,通过启用 Git 插件,你可以用一组简便的命令别名操作 Git, 比如
|
||||
|
||||
```
|
||||
$ alias | grep -i git | sort -R | head -10
|
||||
g=git
|
||||
ga='git add'
|
||||
gapa='git add --patch'
|
||||
gap='git apply'
|
||||
gdt='git diff-tree --no-commit-id --name-only -r'
|
||||
gau='git add --update'
|
||||
gstp='git stash pop'
|
||||
gbda='git branch --no-color --merged | command grep -vE "^(\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d'
|
||||
gcs='git commit -S'
|
||||
glg='git log --stat'
|
||||
```
|
||||
|
||||
zsh 还有许多插件是用于多种编程语言,打包系统和一些平时在命令行中常用的工具。
|
||||
以下是我(作者) Ferdora 工作站中用到的插件表:
|
||||
|
||||
```
|
||||
git golang fedora docker oc sudo vi-mode virtualenvwrapper
|
||||
```
|
||||
|
||||
### 2\. 智能的命令别名
|
||||
|
||||
命令别名在 zsh 中十分常用。为你常用的命令定义别名可以节省你的打字时间。Oh My Zsh 默认配置了一些常用的命令别名,包括目录导航命令别名,为常用的命令添加额外的选项,比如:
|
||||
|
||||
```
|
||||
ls='ls --color=tty'
|
||||
grep='grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn}'
|
||||
```
|
||||
|
||||
|
||||
除了命令别名意外, zsh 还自带两种额外常用的别名类型:后缀别名和全局别名。
|
||||
|
||||
后缀别名可以让你在基于文件后缀的前提下,在命令行中利用指定程序打开这个文件。比如,要用 vim 打开 YAML 文件,可以定义以下命令行别名:
|
||||
|
||||
```
|
||||
alias -s {yml,yaml}=vim
|
||||
```
|
||||
|
||||
现在,如果你在命令行中输入任何后缀名为 `yml` 或 `yaml` 文件, zsh 都会用 vim 打开这个文件
|
||||
|
||||
```
|
||||
$ playbook.yml
|
||||
# Opens file playbook.yml using vim
|
||||
```
|
||||
|
||||
全局别名可以让你在使用命令行的任何时刻创建命令别名,而不仅仅是在开始的时候。这个在你想替换常用文件名或者管道命令的时候就显得非常有用了。比如
|
||||
|
||||
```
|
||||
alias -g G='| grep -i'
|
||||
```
|
||||
|
||||
要使用这个别名,只要你在想用管道命令的时候输入 `G` 就好了:
|
||||
|
||||
```
|
||||
$ ls -l G do
|
||||
drwxr-xr-x. 5 rgerardi rgerardi 4096 Aug 7 14:08 Documents
|
||||
drwxr-xr-x. 6 rgerardi rgerardi 4096 Aug 24 14:51 Downloads
|
||||
```
|
||||
|
||||
接着,我们就来看看 zsh 是如何导航文件系统的。
|
||||
|
||||
### 3\. 便捷的目录导航
|
||||
|
||||
当你使用命令行的时候, 在不同的目录之间切换访问是最常见的工作了。 zsh 提供了一些十分有用的目录导航功能来简化这个操作。这些功能已经集成到 Oh My Zsh 中了, 而你可以用以下命令来启用它
|
||||
|
||||
```
|
||||
setopt autocd autopushd \ pushdignoredups
|
||||
```
|
||||
|
||||
使用了上面的配置后,你就不用输入 `cd` 来切换目录了,只需要输入目录名称,zsh 就会自动切换到这个目录中:
|
||||
|
||||
```
|
||||
$ pwd
|
||||
/home/rgerardi
|
||||
$ /tmp
|
||||
$ pwd
|
||||
/tmp
|
||||
```
|
||||
|
||||
如果想要回退,只要输入 `-`:
|
||||
|
||||
Zsh 会记录你访问过的目录,这样下次你就可以快速切换到这些目录中。如果想要看这个目录列表,只要输入 `dirs -v`:
|
||||
|
||||
```
|
||||
$ dirs -v
|
||||
0 ~
|
||||
1 /var/log
|
||||
2 /var/opt
|
||||
3 /usr/bin
|
||||
4 /usr/local
|
||||
5 /usr/lib
|
||||
6 /tmp
|
||||
7 ~/Projects/Opensource.com/zsh-5tips
|
||||
8 ~/Projects
|
||||
9 ~/Projects/ansible
|
||||
10 ~/Documents
|
||||
```
|
||||
|
||||
如果想要切换到这个列表中的其中一个目录,只需输入 `~#` (`#` 代表目录在列表中的序号)就可以了。比如
|
||||
|
||||
```
|
||||
$ pwd
|
||||
/home/rgerardi
|
||||
$ ~4
|
||||
$ pwd
|
||||
/usr/local
|
||||
```
|
||||
|
||||
你甚至可以用别名组合这些命令,这样切换起来就变得更简单:
|
||||
|
||||
```
|
||||
d='dirs -v | head -10'
|
||||
1='cd -'
|
||||
2='cd -2'
|
||||
3='cd -3'
|
||||
4='cd -4'
|
||||
5='cd -5'
|
||||
6='cd -6'
|
||||
7='cd -7'
|
||||
8='cd -8'
|
||||
9='cd -9'
|
||||
```
|
||||
|
||||
现在你可以通过输入 `d` 来查看这个目录列表的前10个,然后用目录的序号来进行切换:
|
||||
|
||||
```
|
||||
$ d
|
||||
0 /usr/local
|
||||
1 ~
|
||||
2 /var/log
|
||||
3 /var/opt
|
||||
4 /usr/bin
|
||||
5 /usr/lib
|
||||
6 /tmp
|
||||
7 ~/Projects/Opensource.com/zsh-5tips
|
||||
8 ~/Projects
|
||||
9 ~/Projects/ansible
|
||||
$ pwd
|
||||
/usr/local
|
||||
$ 6
|
||||
/tmp
|
||||
$ pwd
|
||||
/tmp
|
||||
```
|
||||
|
||||
最后,你可以在 zsh 中利用 Tab 来自动补全目录名称。你可以先输入目录的首字母,然后用 `TAB` 来补全它们:
|
||||
|
||||
```
|
||||
$ pwd
|
||||
/home/rgerardi
|
||||
$ p/o/z (TAB)
|
||||
$ Projects/Opensource.com/zsh-5tips/
|
||||
```
|
||||
|
||||
以上仅仅是 zsh 强大的 Tab 补全系统中的一个功能。接来下我们来探索它更多的功能。
|
||||
|
||||
### 4\. 先进的 Tab 补全
|
||||
|
||||
Zsh 强大的补全系统是它其中一个卖点。为了简便起见,我称它为 Tab 补全,然而在系统底层,它不仅仅只做一件事。这里通常包括扩展以及命令的补全,我会在这里同时讨论它们。如果想了解更多,详见 [用户手册][8] ( [User's Guide][8] )。
|
||||
|
||||
在 Oh My Zsh 中,命令补全是默认可用的。要启用它,你只要在 `.zshrc` 文件中添加以下命令:
|
||||
```
|
||||
autoload -U compinit
|
||||
compinit
|
||||
```
|
||||
|
||||
Zsh 的补全系统非常智能。他会根据当前上下文来进行命令的提示——比如,你输入了 `cd` 和 `TAB`,zsh 只会为你提示目录名,因为它知道
|
||||
当前的 `cd` 没有任何作用。
|
||||
|
||||
反之,如果你使用 `ssh` 或者 `ping` 这类与用户或者主机相关的命令, zsh 便会提示用户名。
|
||||
|
||||
`zsh` 拥有一个巨大而又完整的库,因此它能识别许多不同的命令。比如,如果你使用 `tar` 命令, 你可以按 Tab 键,他会为你展示一个可以用于解压的文件列表:
|
||||
|
||||
```
|
||||
$ tar -xzvf test1.tar.gz test1/file1 (TAB)
|
||||
file1 file2
|
||||
```
|
||||
|
||||
如果使用 `git` 的话,这里有个更高级的示例。在这个示例中,当你按 `TAB` 键, zsh 会自动补全当前库可以操作的文件:
|
||||
|
||||
```
|
||||
$ ls
|
||||
original plan.txt zsh-5tips.md zsh_theme_small.png
|
||||
$ git status
|
||||
On branch master
|
||||
Your branch is up to date with 'origin/master'.
|
||||
|
||||
Changes not staged for commit:
|
||||
(use "git add <file>..." to update what will be committed)
|
||||
(use "git checkout -- <file>..." to discard changes in working directory)
|
||||
|
||||
modified: zsh-5tips.md
|
||||
|
||||
no changes added to commit (use "git add" and/or "git commit -a")
|
||||
$ git add (TAB)
|
||||
$ git add zsh-5tips.md
|
||||
```
|
||||
|
||||
zsh 还能识别命令行选项,同时他只会提示与选中子命令相关的命令列表:
|
||||
|
||||
```
|
||||
$ git commit - (TAB)
|
||||
--all -a -- stage all modified and deleted paths
|
||||
--allow-empty -- allow recording an empty commit
|
||||
--allow-empty-message -- allow recording a commit with an empty message
|
||||
--amend -- amend the tip of the current branch
|
||||
--author -- override the author name used in the commit
|
||||
--branch -- show branch information
|
||||
--cleanup -- specify how the commit message should be cleaned up
|
||||
--date -- override the author date used in the commit
|
||||
--dry-run -- only show the list of paths that are to be committed or not, and any untracked
|
||||
--edit -e -- edit the commit message before committing
|
||||
--file -F -- read commit message from given file
|
||||
--gpg-sign -S -- GPG-sign the commit
|
||||
--include -i -- update the given files and commit the whole index
|
||||
--interactive -- interactively update paths in the index file
|
||||
--message -m -- use the given message as the commit message
|
||||
... TRUNCATED ...
|
||||
```
|
||||
|
||||
在按 `TAB` 键之后,你可以使用方向键来选择你想用的命令。现在你就不用记住所有的 Git 命令项了。
|
||||
|
||||
zsh 还有很多有用的功能。当你用它的时候,你就知道哪些对你才是最有用的。
|
||||
|
||||
### 5\. 命令行编辑与历史记录
|
||||
|
||||
Zsh 的命令行编辑功能也十分有效。默认条件下,他是模拟 emacs 编辑器的。如果你是跟我一样更喜欢用 vi/vim,你可以用以下命令启用 vi 编辑。
|
||||
|
||||
```
|
||||
$ bindkey -v
|
||||
```
|
||||
|
||||
如果你使用 Oh My Zsh,`vi-mode` 插件可以启用额外的绑定,同时会在你的命令提示符上增加 vi 的模式提示--这个非常有用。
|
||||
|
||||
当启用 vi 的绑定后,你可以再命令行中使用 vi 命令进行编辑。比如,输入 `ESC+/` 来查找命令行记录。在查找的时候,输入 `n` 来找下一个匹配行,输入 `N` 来找上一个。输入 `ESC` 后,最常用的 vi 命令有以下几个,如输入 `0` 跳转到第一行,输入 `$` 跳转到最后一行,输入 `i` 来插入文本,输入 `a` 来追加文本等等,一些直接操作的命令也同样有效,比如输入 `cw` 来修改单词。
|
||||
|
||||
除了命令行编辑,如果你想修改或重新执行之前使用过的命令,zsh 还提供几个常用的命令行历史功能。比如,你打错了一个命令,输入 `fc`,你可以在你偏好的编辑器中修复最后一条命令。使用哪个编辑是参照 `$EDITOR` 变量的,而默认是使用 vi。
|
||||
|
||||
另外一个有用的命令是 `r`, 他会重新执行上一条命令;而 `r <WORD>` 则会执行上一条包含 `WORD` 的命令。
|
||||
|
||||
最后,输入两个感叹号( `!!` ),可以在命令行中回溯最后一条命令。这个十分有用,比如,当你忘记使用 `sudo` 去执行需要权限的命令时:
|
||||
|
||||
```
|
||||
$ less /var/log/dnf.log
|
||||
/var/log/dnf.log: Permission denied
|
||||
$ sudo !!
|
||||
$ sudo less /var/log/dnf.log
|
||||
```
|
||||
|
||||
这个功能让查找并且重新执行之前命令的操作更加方便。
|
||||
|
||||
### 何去何从?
|
||||
|
||||
这里仅仅介绍了几个可以让你提高生产率的 zsh 特性;其实还有更多功能带你发掘;想知道更多的信息,你可以访问以下的资源:
|
||||
|
||||
[An Introduction to the Z Shell][9]
|
||||
|
||||
[A User's Guide to ZSH][10]
|
||||
|
||||
[Archlinux Wiki][11]
|
||||
|
||||
[zsh-lovers][12]
|
||||
|
||||
你有使用 zsh 提高生产力的tips可以分享吗?我(作者)很乐意在下方评论看到它们。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/9/tips-productivity-zsh
|
||||
|
||||
作者:[Ricardo Gerardi][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[tnuoccalanosrep](https://github.com/tnuoccalanosrep)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/rgerardi
|
||||
[1]: http://www.zsh.org/
|
||||
[2]: https://en.wikipedia.org/wiki/Shell_(computing)
|
||||
[3]: http://zsh.sourceforge.net/Doc/Release/zsh_toc.html
|
||||
[4]: https://ohmyz.sh/
|
||||
[5]: https://github.com/bhilburn/powerlevel9k
|
||||
[7]: https://opensource.com/sites/default/files/uploads/zsh_theme_small.png (zsh Powerlevel9K theme)
|
||||
[8]: http://zsh.sourceforge.net/Guide/zshguide06.html#l144
|
||||
[9]: http://zsh.sourceforge.net/Intro/intro_toc.html
|
||||
[10]: http://zsh.sourceforge.net/Guide/
|
||||
[11]: https://wiki.archlinux.org/index.php/zsh
|
||||
[12]: https://grml.org/zsh/
|
Loading…
Reference in New Issue
Block a user