mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
Merge branch 'translating' of https://github.com/geekpi/TranslateProject into translating
This commit is contained in:
commit
798d69a597
94
published/20201203 Get the most out of the Vi text editor.md
Normal file
94
published/20201203 Get the most out of the Vi text editor.md
Normal file
@ -0,0 +1,94 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (wxy)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-12947-1.html)
|
||||
[#]: subject: (Get the most out of the Vi text editor)
|
||||
[#]: via: (https://opensource.com/article/20/12/vi-text-editor)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
|
||||
|
||||
初识 Vi 文本编辑器
|
||||
======
|
||||
|
||||
> Vi 是典型的 Unix 文本编辑器。来了解一下它或它的各种化身:Vim、Neovim、gVim、nvi 或 Elvis,它适用于 Linux、macOS、Windows 或 BSD。
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202012/23/222122wc8resp5zpo2yrcm.jpg)
|
||||
|
||||
不管你用的是 Vim、Neovim、gVim、nvi,甚至是 Elvis,其实都是这个典型的 Unix 编辑器 Vi。可能每一个 Linux 和 BSD 发行版中都包含了 Vi,Vi 是一个轻量级的简约型文本编辑器,由于其简单简洁的键盘快捷键和双模式设计,很多用户都喜欢它。
|
||||
|
||||
最初的 Vi 编辑器是由 [C shell][2] 的创建者 Bill Joy 编写的应用程序。现代 Vi 的化身已经[增加了许多功能][3],包括多级撤销、插入模式下更好的导航、行折叠、语法高亮、插件支持等等。Vim 被认为是它的最流行的现代实现,大多数人在提到 Vi 时实际上是指 Vim。
|
||||
|
||||
所有这些化身都是为了同一个目标,所以本文将从通用的场景来探讨 Vi。你的计算机上的版本可能略有不同,但你仍然可以从 Vi 编辑文本的方式中获益。
|
||||
|
||||
### 安装 Vi
|
||||
|
||||
如果你运行的是 Linux、macOS 或 BSD,那么你已经安装了 `vi` 命令。如果你在 Windows 上,你可以[下载 Vim 和 gVim][4]。
|
||||
|
||||
![gVim][5]
|
||||
|
||||
在 [NetBSD][7]上,nvi 是 Vi 的常见替代品,而 Slackware 则提供了 [Elvis][8](和 Vim),流行的 [Neovim][9] 复刻旨在帮助用户用 [Lua][10] 扩展 Vim。
|
||||
|
||||
### 启动 Vi
|
||||
|
||||
在终端中用 `vi` 命令启动 Vi 或 Vim。如果在你的系统中没有找到 `.vimrc` 文件,那么 Vim 就会以 Vi 兼容模式启动(也可以用 `-C` 选项强制启动该模式)。如果你想使用 gVim 以拥有一个图形用户界面(GUI),你可以从桌面的应用程序菜单中启动它。
|
||||
|
||||
如果你是一个刚刚学习 Vi 的新用户,使用图形用户界面是一个很好的方法,可以在你可能期望的文本编辑器的行为和 Vi 的设计行为之间提供一个缓冲带。图形用户界面版本有一个菜单栏,一些鼠标集成,一个工具栏和其他功能,这可以帮助你找到你可能认为在典型的文本编辑器中理所当然的基本功能,但还不知道如何在 Vi 中做。
|
||||
|
||||
### 如何使用 Vi
|
||||
|
||||
学习 Vi 最简单的方法可能是使用 `vimtutor`,这是一个与 Vim 打包在一起的交互式教程。要开始学习该教程,启动 `vimtutor` 并阅读说明,尝试每个练习。正如教程中所说,学好 Vi 不是记住什么键做什么,而是建立肌肉记忆,以在输入时调用常用的动作。
|
||||
|
||||
#### Esc 键
|
||||
|
||||
学习 Vi 的第一件重要的事就是掌握 `Esc` 键。`Esc` 是激活*命令模式*的工具,很快你就会明白,在 Vi 中,只要你不确定,就按 `Esc`。在命令模式下,你按下的任何键都不会被输入到你正在处理的文本文档中,而是被 Vi 解释为一条命令。例如,要将光标向左移动,你可以按键盘上的 `H` 键。如果你处于*插入*模式,那么按 `H` 键就会输入字母 H,就像你期望的那样。但在*命令*模式下,按 `H` 向左移动,`L` 向右移动,`J` 向下移动,`K` 向上移动。
|
||||
|
||||
命令模式和插入模式的分离与其他文本编辑器的工作方式形成了鲜明的对比,由于这种设计,这可能是 Vi 最显著的差异化。不过有趣的是,理论上来说,它与你可能已有的工作方式并没有太大的区别。毕竟,当你把手从键盘上拿开,用鼠标选择文本时,你基本上是将自己置于一种命令模式中。在 Vi 中,你不需要把手从键盘上移开来移动鼠标,也不需要按功能键或 `Ctrl` 键,而是将*编辑器*放入一种特殊的操作模式中,使你的按键重新分配到命令上,而不是文字输入。
|
||||
|
||||
#### 扩展 Vi
|
||||
|
||||
在 Vim 8.0 版本之前,Vi 在很大程度上“只是”一个文本编辑器。它有插件,但安装插件是一个手动的过程,很多用户从未想过要这么做。幸运的是,Vim 8 及以上版本提供了对插件管理的支持,使得安装和加载插件变得轻而易举。
|
||||
|
||||
安装 Vim 的插件可以通过 `vim-plug` 功能来完成。例如,要安装 Vi 文件浏览器 [NERDTree][11]:
|
||||
|
||||
```
|
||||
:PlugInstall NERDTree
|
||||
```
|
||||
|
||||
你也可以更新插件:
|
||||
|
||||
```
|
||||
:PlugUpdate NERDTree
|
||||
```
|
||||
|
||||
关于使用 `vim-plug` 和手动安装插件和主题的更多信息,请阅读我的文章《[如何安装 Vim 插件][12]》。
|
||||
|
||||
### 默认 Vi
|
||||
|
||||
Vi 不仅仅流行,它还是一个 [POSIX][13] 标准。它是每个系统管理员都应该知道如何使用的应用程序,即使他们不打算每天使用它。它也是一个快速而简单的编辑器,所以一旦你熟练掌握了它,它可能就是你一直在寻找的编辑器。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/12/vi-text-editor
|
||||
|
||||
作者:[Seth Kenlon][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[wxy](https://github.com/wxy)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/seth
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/lenovo-thinkpad-laptop-concentration-focus-windows-office.png?itok=-8E2ihcF (Woman using laptop concentrating)
|
||||
[2]: https://opensource.com/article/20/8/tcsh
|
||||
[3]: https://vimhelp.org/vi_diff.txt.html#vi-differences
|
||||
[4]: https://www.vim.org/download.php
|
||||
[5]: https://opensource.com/sites/default/files/uploads/gvim.jpg (gVim)
|
||||
[6]: https://creativecommons.org/licenses/by-sa/4.0/
|
||||
[7]: https://opensource.com/article/19/3/netbsd-raspberry-pi
|
||||
[8]: https://github.com/mbert/elvis
|
||||
[9]: http://neovim.io
|
||||
[10]: https://opensource.com/article/20/2/lua-cheat-sheet
|
||||
[11]: https://www.vim.org/scripts/script.php?script_id=1658
|
||||
[12]: https://opensource.com/article/20/2/how-install-vim-plugins
|
||||
[13]: https://opensource.com/article/19/7/what-posix-richard-stallman-explains
|
169
published/20201216 How to View Images from the Linux Terminal.md
Normal file
169
published/20201216 How to View Images from the Linux Terminal.md
Normal file
@ -0,0 +1,169 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-12948-1.html)
|
||||
[#]: subject: (How to View Images from the Linux Terminal)
|
||||
[#]: via: (https://www.2daygeek.com/how-to-view-display-images-from-linux-terminal/)
|
||||
[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/)
|
||||
|
||||
如何在 Linux 终端查看图像
|
||||
======
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202012/23/233513zcgmggmxfd0wf9g1.png)
|
||||
|
||||
Linux 有很多用于查看图像的 GUI 应用。但我从来没有尝试过用任何命令行应用来查看它。
|
||||
|
||||
幸运的是,在使用 [ImageMagick 工具][1]时,我得到了一个从终端查看图像的命令。命令名是 `“display`,它是 ImageMagick 工具的一部分。这是一个很好的工具,允许类 UNIX 用户从终端查看图像。
|
||||
|
||||
此外,我还为此用途得到了另一个很好的工具,叫做 FIM。
|
||||
|
||||
我们将向你展示如何安装并使用它从 Linux 终端查看图像。这些命令使用系统的<ruby>帧缓冲<rt>framebuffer</rt></ruby>直接从命令行显示图像。
|
||||
|
||||
### 如何使用 display 命令从终端查看图像
|
||||
|
||||
[ImageMagick][2] 是一个自由开源、功能丰富、基于命令行的图像处理工具。它用于创建、编辑、合成或转换位图图像。它可以读取和写入各种格式(超过 200 种)的图像,包括 PNG、JPEG、GIF、PDF、SVG 等。它可以调整图像的大小、镜像、旋转、转换图像、调整图像颜色、应用各种特殊效果等。它支持批处理,允许你一次处理所有图像。
|
||||
|
||||
### 如何安装 ImageMagick?
|
||||
|
||||
ImageMagick 软件包包含在大多数 Linux 发行版的官方仓库中。使用发行版软件包管理器来安装它。
|
||||
|
||||
**需要注意的是:**确保你的 Linux 系统上已经安装了 “[Development Tools][3]” 包,这是安装的前提条件。
|
||||
|
||||
对于 RHEL/CentOS 6/7 系统,请使用 [yum 命令][4] 安装 ImageMagick:
|
||||
|
||||
```
|
||||
$ sudo yum install -y ImageMagick ImageMagick-devel
|
||||
```
|
||||
|
||||
在 RHEL/CentOS 8 和 Fedora 系统,使用 [dnf 命令][5] 安装 ImageMagick:
|
||||
|
||||
```
|
||||
$ sudo dnf install -y ImageMagick ImageMagick-devel
|
||||
```
|
||||
|
||||
对于 Debian/Ubuntu 系统,使用 [apt 命令][6] 或 [apt-get 命令][7] 安装 ImageMagick:
|
||||
|
||||
```
|
||||
$ sudo apt-get update
|
||||
$ sudo apt-get install imagemagick
|
||||
```
|
||||
|
||||
对于 openSUSE 系统,使用 [zypper 命令][8] 安装 ImageMagick:
|
||||
|
||||
```
|
||||
$ sudo zypper install -y ImageMagick
|
||||
```
|
||||
|
||||
要查看任何图像文件,请运行 `display` 命令,如下所示。你可以按下 `Esc`/`q` 按钮关闭图像:
|
||||
|
||||
```
|
||||
$ display bird.jpg
|
||||
```
|
||||
|
||||
![](https://www.2daygeek.com/wp-content/uploads/2020/12/how-to-view-display-images-from-linux-terminal-2.jpg)
|
||||
|
||||
如果你想用指定的窗口大小打开图像,请使用 `-geometry` 标志:
|
||||
|
||||
```
|
||||
$ display -geometry 1000x600 ~/Downloads/bird.jpg
|
||||
```
|
||||
|
||||
你也可以通过 `display` 命令输入图像的位置信息。下面的命令可以从桌面的距顶部 800 像素和据左上角 800 像素处打开图像:
|
||||
|
||||
```
|
||||
$ display -geometry 1000x600+800+800 ~/Downloads/bird.jpg
|
||||
```
|
||||
|
||||
如果你想用 `display` 命令调整图像的大小,请使用以下格式:
|
||||
|
||||
```
|
||||
$ display -resize 600x400 ~/Downloads/bird.jp
|
||||
```
|
||||
|
||||
另外,你也可以使用百分比来调整图片的大小:
|
||||
|
||||
```
|
||||
$ display -resize 50% ~/Downloads/bird.jpg
|
||||
```
|
||||
|
||||
### 如何使用 fim 命令从终端查看图像
|
||||
|
||||
[FIM][10] 是一个专门为 Linux 设计的轻量级全局图像查看器。但它并不局限于 Linux,它也可配置在其他操作系统上运行,如 MS-Windows。
|
||||
|
||||
对于熟悉 VIM 文本编辑器等软件的用户来说,它是高度可定制和可脚本化的图像查看器。它可以全屏显示图像,并且可以使用键盘快捷键轻松控制。它是一款非常轻量级的工具,因为它只依赖于某些库。
|
||||
|
||||
它可以打开许多文件格式,它可以在以下视频模式下显示图像:
|
||||
|
||||
* 使用 Linux 帧缓冲设备图形化。
|
||||
* 在 X/Xorg 下,使用 SDL 库图形化
|
||||
* 在 X/Xorg 下,使用 Imlib2 库图形化。
|
||||
* 使用 AAlib 库,在任意文本控制台中以 ASCII 艺术形式呈现。
|
||||
|
||||
运行时自动检测或选择正确的视频模式,如果需要,可以在构建前配置时选择加入或去除。
|
||||
|
||||
FIM 是 “Fbi IMproved” 的缩写,是 Fbi Image Viewer 的复刻版本。
|
||||
|
||||
FIM 可以很容易地安装在基于 Debian/Ubuntu 的系统上,因为该软件包在发行版的官方仓库中是可用的。对于其他发行版,你可能需要从源码编译它:
|
||||
|
||||
```
|
||||
$ sudo apt install fim
|
||||
```
|
||||
|
||||
安装完毕后,你可以使用以下命令显示图像:
|
||||
|
||||
```
|
||||
$ fim bird.jpg
|
||||
```
|
||||
|
||||
你可以使用 `-a` 选项自动缩放图像:
|
||||
|
||||
```
|
||||
$ fim -a bird.jpg
|
||||
```
|
||||
|
||||
![](https://www.2daygeek.com/wp-content/uploads/2020/12/how-to-view-display-images-from-linux-terminal-3.jpg)
|
||||
|
||||
如果你要打开当前目录中的多个图像文件,请使用通配符将它们全部打开。使用 `PageUp`/`PageDown` 键盘快捷键移动到下一张或上一张图像:
|
||||
|
||||
```
|
||||
$ fim -a *.jpg
|
||||
```
|
||||
|
||||
要以 ASCII 格式查看图像,可以使用 `-t` 标志:
|
||||
|
||||
```
|
||||
$ fim -t bird.jpg
|
||||
```
|
||||
|
||||
下面的键盘快捷键可以让你控制图像:
|
||||
|
||||
* `PageUp`/`PageDown`:上一张/下一张图片。
|
||||
* `+`/`-`:放大/缩小
|
||||
* `a`:自动缩放
|
||||
* `w`:适应宽度
|
||||
* `ESC`/`q`:退出
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.2daygeek.com/how-to-view-display-images-from-linux-terminal/
|
||||
|
||||
作者:[Magesh Maruthamuthu][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.2daygeek.com/author/magesh/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.2daygeek.com/resize-convert-images-from-linux-command-line/
|
||||
[2]: https://imagemagick.org/
|
||||
[3]: https://www.2daygeek.com/install-development-tools-on-ubuntu-debian-arch-linux-mint-fedora-centos-rhel-opensuse/
|
||||
[4]: https://www.2daygeek.com/linux-yum-command-examples-manage-packages-rhel-centos-systems/
|
||||
[5]: https://www.2daygeek.com/linux-dnf-command-examples-manage-packages-fedora-centos-rhel-systems/
|
||||
[6]: https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/
|
||||
[7]: https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/
|
||||
[8]: https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/
|
||||
[9]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
|
||||
[10]: https://www.nongnu.org/fbi-improved/#docs
|
@ -1,98 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Get the most out of the Vi text editor)
|
||||
[#]: via: (https://opensource.com/article/20/12/vi-text-editor)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
|
||||
|
||||
Get the most out of the Vi text editor
|
||||
======
|
||||
Vi is the quintessential Unix text editor. Get to know it—or any of its
|
||||
incarnations, Vim, Neovim, gVim, nvi, or Elvis, for Linux, macOS,
|
||||
Windows, or BSD.
|
||||
![Business woman on laptop sitting in front of window][1]
|
||||
|
||||
Whether you know it as Vim, Neovim, gVim, nvi, or even Elvis, the quintessential Unix editor is easily Vi. Included in probably every Linux and BSD distribution, Vi is a lightweight and minimalist text editor that many users love for its simple and succinct keyboard shortcuts and dual-mode design.
|
||||
|
||||
The original Vi editor was an application written by Bill Joy, creator of the [C shell][2]. Modern incarnations of Vi have [added many features][3], including multiple levels of undo, better navigation while in insert mode, line folding, syntax highlighting, plugin support, and much more. Vim is regarded as the most popular modern implementation, and most people actually mean Vim when they refer to Vi.
|
||||
|
||||
All incarnations hearken back to the same goal, though, so this article looks at Vi in a generic sense. The implementation on your computer may differ slightly, but you can still benefit from editing text the Vi way.
|
||||
|
||||
### Install Vi
|
||||
|
||||
If you're running Linux, macOS, or BSD, then you already have the `vi` command installed. If you're on Windows, you can [download Vim and gVim][4].
|
||||
|
||||
![gVim][5]
|
||||
|
||||
(Seth Kenlon, [CC BY-SA 4.0][6])
|
||||
|
||||
On [NetBSD][7], nvi is a common alternative to Vi, while Slackware provides [Elvis][8] (and Vim), and the popular [Neovim][9] fork aims to help users extend Vim with [Lua][10].
|
||||
|
||||
### Launch Vi
|
||||
|
||||
Start Vi or Vim with the `vi` command in a terminal. If a `.vimrc` file is not found on your system, then Vim starts in Vi-compatibility mode (this can also be forced with the `-C` option). If you want to use gVim to have a graphical user interface (GUI), you can start it from your desktop's application menu.
|
||||
|
||||
If you're a new user just learning Vi, using a graphical user interface can be a nice way to provide yourself a buffer between how you might _expect_ a text editor to behave and how Vi was designed to behave. The GUI version has a menu bar, some mouse integration, a toolbar, and other features to help you find the basic functions you probably take for granted in a typical text editor but don't know how to do in Vi yet.
|
||||
|
||||
### How to use Vi
|
||||
|
||||
Probably the easiest way to learn Vi is with `vimtutor`, an interactive tutorial packaged with Vim. To start the tutorial, launch `vimtutor` and read through the instructions, trying each exercise. As the tutorial says, getting good with Vi is less about memorizing what key does what and more about establishing muscle memory to invoke common actions as you type.
|
||||
|
||||
#### Escape
|
||||
|
||||
One of the first things you learn about Vi is the importance of the **Esc** key. **Esc** is what activates _command mode_, and it doesn't take long to learn that whenever you're in doubt in Vi, just press **Esc**. Any key you press while in command mode is not entered into the text document you're working on; instead, it is interpreted by Vi as a command. For instance, to move your cursor left, you press the **H** key on your keyboard. If you're in _insert_ mode, then pressing **H** types the letter H, just as you'd expect. But in _command_ mode, pressing **H** moves left, **L** moves right, **J** moves down, and **K** moves up.
|
||||
|
||||
The separation between command mode and insert mode is a sharp contrast to the way any other text editor works, and for that reason, it's probably Vi's most significant differentiator. Interestingly, though, it's theoretically not so different from the way you probably already work. After all, when you take your hands off the keyboard to select text with a mouse, you're essentially placing yourself into a kind of command mode. With Vi, instead of moving your hands off the keyboard to move the mouse and press function keys or Ctrl, you put the _editor_ into a special mode of operation, such that it reassigns your key presses to commands instead of text input.
|
||||
|
||||
#### Extend Vi
|
||||
|
||||
Before Vim version 8.0, Vi was very much "just" a text editor. There were plugins for it, but installing them was a manual process that many users never thought to do. Luckily, Vim version 8 and higher offer support for plugin management, making it trivial to install and load plugins.
|
||||
|
||||
Installing plugins for Vim can be done with the `vim-plug` function. For instance, to install the Vi file browser [NERDTree][11]:
|
||||
|
||||
|
||||
```
|
||||
`:PlugInstall NERDTree`
|
||||
```
|
||||
|
||||
You can also update plugins:
|
||||
|
||||
|
||||
```
|
||||
`:PlugUpdate NERDTree`
|
||||
```
|
||||
|
||||
For more information on installing plugins and themes, both with `vim-plug` and manually, read my article [_How to install Vim plugins_][12].
|
||||
|
||||
### Vi as default
|
||||
|
||||
Vi isn't just popular; it's a [POSIX][13] standard. It's an application every sysadmin should know how to use, even if they don't intend to use it on an everyday basis. It's also a fast and simple editor, so once you get good at it, it may be the editor you've long been searching for.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/12/vi-text-editor
|
||||
|
||||
作者:[Seth Kenlon][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者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/seth
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/lenovo-thinkpad-laptop-concentration-focus-windows-office.png?itok=-8E2ihcF (Woman using laptop concentrating)
|
||||
[2]: https://opensource.com/article/20/8/tcsh
|
||||
[3]: https://vimhelp.org/vi_diff.txt.html#vi-differences
|
||||
[4]: https://www.vim.org/download.php
|
||||
[5]: https://opensource.com/sites/default/files/uploads/gvim.jpg (gVim)
|
||||
[6]: https://creativecommons.org/licenses/by-sa/4.0/
|
||||
[7]: https://opensource.com/article/19/3/netbsd-raspberry-pi
|
||||
[8]: https://github.com/mbert/elvis
|
||||
[9]: http://neovim.io
|
||||
[10]: https://opensource.com/article/20/2/lua-cheat-sheet
|
||||
[11]: https://www.vim.org/scripts/script.php?script_id=1658
|
||||
[12]: https://opensource.com/article/20/2/how-install-vim-plugins
|
||||
[13]: https://opensource.com/article/19/7/what-posix-richard-stallman-explains
|
@ -0,0 +1,59 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (10 lessons from sysadmins adapting to change in 2020)
|
||||
[#]: via: (https://opensource.com/article/20/12/sysadmin)
|
||||
[#]: author: (Alan Formy-Duval https://opensource.com/users/alanfdoss)
|
||||
|
||||
10 lessons from sysadmins adapting to change in 2020
|
||||
======
|
||||
Adapting to change was a major theme in 2020, and throughout all the
|
||||
turmoil, we could count on sysadmins to keep us up and running.
|
||||
![Tips and gears turning][1]
|
||||
|
||||
While 2020 will certainly be remembered for elections, protests, and most of all, the COVID-19 pandemic, a lot of other things changed in 2020, including a whole lot of cool changes in technology. Through it all, we could count on system administrators to do what they do best. Perhaps more so than ever, as we all moved from physical offices to working from home. We generated more load than ever on our infrastructure as more users relied on virtual private networks and videoconference tools to get their daily work done.
|
||||
|
||||
Every year, we publish many articles to help systems administrators do their jobs better. Of the many articles we published this year, we believe these 10 offer the best insights for sysadmins in 2020. Several provide good examples of the importance of keeping up with change—which, after all, is the only thing we could count on this year.
|
||||
|
||||
1. [Manage network connections from the Linux command line with nmcli][2]: Dave McKay gives an overview of NetworkManager's `nmcli` command for network management in Linux. Using `nmcli` in place of `ifconfig` is strongly recommended in the latest versions of Linux.
|
||||
2. [5 new sudo features you need to know in 2020][3]: Following the theme of keeping up with change, Peter Czanik shows five new features of the `sudo` command. This crucial sysadmin tool gains power with recording and auditing capabilities and support for Python.
|
||||
3. [Start using systemd as a troubleshooting tool][4]: It's clear that systemd is here to stay. Correspondent David Both invites us on his journey from SystemV to systemd in yet another example of how system administrators need to adapt. In this article (part of an ongoing series), David demonstrates how to troubleshoot a problematic Apache HTTP service using systemd logs and status output.
|
||||
4. [5 ops hacks for sysadmins][5]: Server counts continue to rise alongside the demands on system administrators managing bare-metal hosts, containers, or virtual machines. As Stephen Bancroft starts this article: "As a sysadmin, every day I am faced with problems I need to solve quickly because there are users and managers who expect things to run smoothly." He discusses five tools, some "oldies but goodies," that remain extremely useful in 2020.
|
||||
5. [Load balance network traffic with HAProxy][6]: Load balancers are an important component of a high-availability infrastructure. They can be deployed for anything from large distributed enterprise applications down to your home lab. A great option for the latter is HAProxy, and Jim O'Connell shows how to set it up.
|
||||
6. [An SRE's guide to Memcached for building scalable applications][7]: After reading about load balancers, check out this article by Correspondent Moshe Zadka, as he takes you deeper into the application stack with an overview of Memcached. Moshe, a site reliability engineer, explains Memcached's value for high-performance systems that must respond to repeated requests under heavy load.
|
||||
7. [Why making mistakes makes me a better sysadmin][8]: Ben Cotton, the Fedora Linux Project's program manager, reminds us that we can learn from our mistakes. He explains that we can learn to avoid repeating mistakes through practice and testing. Now if only 2020 had a dry-run option!
|
||||
8. [10 Ansible modules for Linux system automation][9]: Automation is a great way to avoid those mistakes Ben writes about. Ricardo Gerardi specializes in automation, and in this article, he shows how to use Ansible to automate daily Linux system administration tasks, such as package installation and user creation, that are repetitive and, therefore, error-prone.
|
||||
9. [How I use Cockpit for my home's Linux server management][10]: Cockpit is a fairly new graphical tool for Linux system management. It is browser-based and handles local and remote management equally well. After using similar tools over the years, I wrote this article because I am impressed at how quickly Cockpit can be put to use. Installation is simple, and it is easy for any busy system administrator to learn.
|
||||
10. [4 ways I contribute to open source as a Linux systems administrator][11]: Open source projects and the communities that support them have taken a prominent role in 2020. In this article, Elizabeth Joseph shares some ways to get involved. She encourages system administrators and other open source users to join and contribute to projects. So, get involved and help make 2021 an even better year!
|
||||
|
||||
|
||||
|
||||
What sysadmin topics would you like to learn about on Opensource.com? Please share your ideas in the comments. We're always looking for new contributors, so please check out our [Contributor guidelines][12] if you want to write an article you think our readers would enjoy.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/12/sysadmin
|
||||
|
||||
作者:[Alan Formy-Duval][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者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/alanfdoss
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/gears_devops_learn_troubleshooting_lightbulb_tips_520.png?itok=HcN38NOk (Tips and gears turning)
|
||||
[2]: https://opensource.com/article/20/7/nmcli
|
||||
[3]: https://opensource.com/article/20/10/sudo-19
|
||||
[4]: https://opensource.com/article/20/5/systemd-troubleshooting-tool
|
||||
[5]: https://opensource.com/article/20/1/ops-hacks-sysadmins
|
||||
[6]: https://opensource.com/article/20/11/load-balancing-haproxy
|
||||
[7]: https://opensource.com/article/20/3/sre-memcached
|
||||
[8]: https://opensource.com/article/20/8/sysadmin-mistakes
|
||||
[9]: https://opensource.com/article/20/10/ansible-modules-linux
|
||||
[10]: https://opensource.com/article/20/11/cockpit-server-management
|
||||
[11]: https://opensource.com/article/20/7/open-source-sysadmin
|
||||
[12]: https://opensource.com/how-submit-article
|
@ -0,0 +1,55 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (4 reasons businesses adopted open source in 2020)
|
||||
[#]: via: (https://opensource.com/article/20/12/open-source-survey)
|
||||
[#]: author: (Chris Grams https://opensource.com/users/cgrams)
|
||||
|
||||
4 reasons businesses adopted open source in 2020
|
||||
======
|
||||
Differences emerge based on company size, according to Tidelift's third
|
||||
managed open source survey.
|
||||
![Metrics and a graph illustration][1]
|
||||
|
||||
Companies are turning to open source during the pandemic, with 44% of organizations reporting they will increase their use of open source for application development, finds Tidelift's [third managed open source survey][2].
|
||||
|
||||
We've heard this lyric before; in previous recessions, organizations turned to open source [for cost savings][3] and stayed for its [other transformational benefits][4]. We wanted to understand which long-term benefits were most helpful to organizations of different sizes. Here's a summary of what we found.
|
||||
|
||||
**Open source is driving cost and time savings while improving efficiency.** A key driver, cited by 68% of organizations, is saving money and development time, as using open source reduces the time developers spend writing new code from scratch. Almost half (48%) report that it increases app development and maintenance efficiency. Organizations with more than 1,000 employees are far more likely to cite this as a reason to encourage the use of more open source (61% vs. 41% for organizations with less than 1,000).
|
||||
|
||||
![Graph showing reasons for using open source][5]
|
||||
|
||||
(Tidelift ©2020)
|
||||
|
||||
**Eliminating vendor lock-in is high on the list of reasons organizations are using more open source.** We found 40% of respondents cited this as a primary reason. Replacing expensive proprietary software with open source ensures that organizations can be more nimble and avoid dependency on vendors. Again, larger organizations favor this reason; 50% of organizations with over 1,000 employees identify this as a key benefit.
|
||||
|
||||
**Increasing developer satisfaction is another reason to use more open source, with 31% of organizations citing it.** As companies compete fiercely for talent, they understand the value of ensuring developers are happy in their work and with the tools they use. The survey found that the top three languages developers are using are JavaScript (78%), Python (52%), and Java (41%).
|
||||
|
||||
**Additionally, as open source usage increases, 83% of organizations continue to contribute to it, and nearly half have a policy in place to govern contributions**. These policies include contributions during work hours to projects an organization uses but doesn't sponsor or manage; contributions to projects they do sponsor or manage; contributions during personal time to non-job-related (personal) projects; and contributions during work hours to non-job-related (personal) projects.
|
||||
|
||||
While the long-term migration towards open source continues, it's clear that the impact of COVID-19 may be accelerating this process, and organizations continue to glean deeper value from using and contributing to it.
|
||||
|
||||
For more information, view all findings from the [2020 Managed Open Source Survey][2].
|
||||
|
||||
Developing your organization's story—the narrative that gives it its current identity and charts...
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/12/open-source-survey
|
||||
|
||||
作者:[Chris Grams][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者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/cgrams
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_graph_stats_blue.png?itok=OKCc_60D (Metrics and a graph illustration)
|
||||
[2]: https://www.tidelift.com/subscription/2020-managed-open-source-survey
|
||||
[3]: https://blog.tidelift.com/the-third-wave-of-open-source-migration?utm_source=opensource&utm_medium=referral&utm_campaign=2020-survey
|
||||
[4]: https://blog.tidelift.com/theres-one-thing-stopping-developers-from-using-open-source-even-more?utm_source=opensource&utm_medium=referral&utm_campaign=2020-survey
|
||||
[5]: https://opensource.com/sites/default/files/uploads/tidelift_reasons-for-using-open-source.png (Graph showing reasons for using open source)
|
@ -1,103 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Font Manager: A Simple Open-Source App for GTK+ Desktop)
|
||||
[#]: via: (https://itsfoss.com/font-manager/)
|
||||
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
|
||||
|
||||
Font Manager: A Simple Open-Source App for GTK+ Desktop
|
||||
======
|
||||
|
||||
_**Brief: A dead simple font manager app that lets you focus on tweaking the fonts on your Linux system.**_
|
||||
|
||||
If you are an experienced Linux user, you might be utilizing the terminal or the [tweak tool][1] to manage fonts on your Linux system.
|
||||
|
||||
Honestly, no matter how useful the GNOME tweak tool is — it could be a little too overwhelming just to manage fonts. So, a separate application would be perfectly fine to help you manage fonts.
|
||||
|
||||
### Font Manager: An Open-Source App To Help Manage Fonts
|
||||
|
||||
![][2]
|
||||
|
||||
Font Manager (that’s literally the name of the app) is a dedicated application to help you manage the fonts.
|
||||
|
||||
You get the details of the font family, variations available, and the ability to filter and tweak based on their height, width, spacing, and more. Considering it is a simple app, you do not find a bunch of features but I’ll briefly highlight a few things below.
|
||||
|
||||
### Features of Font Manager
|
||||
|
||||
![][3]
|
||||
|
||||
* Ability to add fonts
|
||||
* Ability to remove fonts
|
||||
* Easily filter fonts based on family, vendor, spacing, height, etc
|
||||
* Tweak the scaling factor of fonts
|
||||
* Adjust the anti-aliasing (softness/sharpness) of the font
|
||||
* Add font sources to preview them before installing it
|
||||
* Offers keyboard shortcuts to quickly manage things
|
||||
* Google fonts integration available out-of-the-box
|
||||
* Get detailed information on characters available in the family font, license, size of the font, vendor, file type, spacing, width, and style
|
||||
|
||||
|
||||
|
||||
![][4]
|
||||
|
||||
Overall, you can easily install or remove fonts. But, you get quite a few perks while managing the fonts as shown in the screenshot above.
|
||||
|
||||
### Installing Font Manager on Linux
|
||||
|
||||
You get a variety of options (depending on the Linux distro you use) for installation.
|
||||
|
||||
If you have an Ubuntu-based distro, you can easily add the PPA through the commands below to install font manager:
|
||||
|
||||
```
|
||||
sudo add-apt-repository ppa:font-manager/staging
|
||||
sudo apt update
|
||||
sudo apt install font-manager
|
||||
```
|
||||
|
||||
In case you’re not a fan of [PPAs][5] (which is how I prefer to install this), you can also install a [Flatpak package available][6] on any Linux distribution.
|
||||
|
||||
You just need to enable Flatpak on your Linux system and then search for it on your software center (if it supports Flatpak integration) or just type in the following command to install it:
|
||||
|
||||
```
|
||||
flatpak install flathub org.gnome.FontManager
|
||||
```
|
||||
|
||||
In case you’re an Arch user, you can find the [package][7] in the [AUR][8].
|
||||
|
||||
For further installation instructions, you might want to refer its [official website][9] and the [GitHub page][10].
|
||||
|
||||
[Download Font Manager][9]
|
||||
|
||||
### Wrapping Up
|
||||
|
||||
Font Manager is a simple solution for any GTK+ based desktop environment. Primarily for GNOME but you can also utilize it for other desktop environments as well.
|
||||
|
||||
You get a lot of useful information while being able to add or remove fonts and it is clearly a no-nonsense font manager, I think.
|
||||
|
||||
What do you think about Font Manager? Let me know your thoughts in the comments below!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/font-manager/
|
||||
|
||||
作者:[Ankush Das][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/ankush/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://itsfoss.com/gnome-tweak-tool/
|
||||
[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/12/font-manager.png?resize=800%2C565&ssl=1
|
||||
[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/12/font-manager-settings.jpg?resize=800%2C569&ssl=1
|
||||
[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/12/font-manager-showcase.png?resize=800%2C571&ssl=1
|
||||
[5]: https://itsfoss.com/ppa-guide/
|
||||
[6]: https://flathub.org/apps/details/org.gnome.FontManager
|
||||
[7]: https://aur.archlinux.org/packages/font-manager/
|
||||
[8]: https://itsfoss.com/aur-arch-linux/
|
||||
[9]: https://fontmanager.github.io/
|
||||
[10]: https://github.com/FontManager/font-manager
|
193
sources/tech/20201222 Learn Rust by writing a simple game.md
Normal file
193
sources/tech/20201222 Learn Rust by writing a simple game.md
Normal file
@ -0,0 +1,193 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Learn Rust by writing a simple game)
|
||||
[#]: via: (https://opensource.com/article/20/12/learn-rust)
|
||||
[#]: author: (Moshe Zadka https://opensource.com/users/moshez)
|
||||
|
||||
Learn Rust by writing a simple game
|
||||
======
|
||||
Start programming with a simple game you can try in multiple languages.
|
||||
![Ferris the crab under the sea, unofficial logo for Rust programming language][1]
|
||||
|
||||
When you want to learn a new programming language, it's good to focus on the things programming languages have in common:
|
||||
|
||||
* Variables
|
||||
* Expressions
|
||||
* Statements
|
||||
|
||||
|
||||
|
||||
These concepts are the basis of most programming languages. Once you understand them, you can start figuring the rest out.
|
||||
|
||||
Because programming languages usually share similarities, once you know one language, you can learn the basics of another by understanding its differences.
|
||||
|
||||
A good way to learn new languages is using a standard program that you can use to practice. This allows you to focus on the language, not the program's logic. I'm doing that in this article series using a "guess the number" program, in which the computer picks a number between one and 100 and asks you to guess it. The program loops until you guess the number correctly.
|
||||
|
||||
This program exercises several concepts in programming languages:
|
||||
|
||||
* Variables
|
||||
* Input
|
||||
* Output
|
||||
* Conditional evaluation
|
||||
* Loops
|
||||
|
||||
|
||||
|
||||
It's a great practical experiment to learn a new programming language.
|
||||
|
||||
### Install Rust
|
||||
|
||||
You can [install a Rust toolchain using Rustup][2], or you can [try Rust online][3] without installing it locally.
|
||||
|
||||
If you install it locally, you should update it periodically with `rustup update` to keep your toolchain fresh, and with `cargo update` to keep your libraries on their latest versions.
|
||||
|
||||
### Guess the number in Rust
|
||||
|
||||
[Rust][4] is a language that empowers anyone to build reliable and efficient software. You can explore Rust by writing a version of the "guess the number" game.
|
||||
|
||||
The first step is to write a `Cargo.toml` file. You can generate a skeleton `Cargo.toml` using the `cargo new` command. This is almost always the best way to start a Rust project.
|
||||
|
||||
|
||||
```
|
||||
$ cargo new guess
|
||||
$ cd guess
|
||||
$ ls -1
|
||||
Cargo.toml
|
||||
src/
|
||||
```
|
||||
|
||||
The `Cargo.toml` file names your package, gives it some metadata, and, most importantly, specifies that it depends on the `rand` [crate][5].
|
||||
|
||||
|
||||
```
|
||||
[package]
|
||||
name = "guess"
|
||||
version = "2020.11.0"
|
||||
authors = ["Moshe Zadka <[moshez@opensource.com][6]>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at <https://doc.rust-lang.org/cargo/reference/manifest.html>
|
||||
|
||||
[dependencies]
|
||||
rand = "*"
|
||||
```
|
||||
|
||||
Many things in Rust are not supplied by the language or the standard library. Instead, you get them from one of many external crates that are available to do many things.
|
||||
|
||||
The program logic goes in `src/main.rs`:
|
||||
|
||||
|
||||
```
|
||||
use rand::Rng;
|
||||
use std::io::BufRead;
|
||||
|
||||
fn main() {
|
||||
let mut rng = rand::thread_rng();
|
||||
let random = rng.gen_range(1..101);
|
||||
println!("Guess a number between 1 and 100");
|
||||
for line in std::io::stdin().lock().lines() {
|
||||
let parsed = line.ok().as_deref().map(str::parse::<i64>);
|
||||
if let Some(Ok(guess)) = parsed {
|
||||
match guess {
|
||||
_ if guess < random => println!("Too low"),
|
||||
_ if guess > random => println!("Too high"),
|
||||
_ => {
|
||||
println!("That's right");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The first two lines of the code declare what you are going to do. In this case, `rand::Rng` generates a guess and the [trait][7] `std::io::BufRead` enables reading from standard input.
|
||||
|
||||
The entry point to the Rust code is in the `main()` function, so the next step is to define `main()`.
|
||||
|
||||
To assign a value to a variable put `let`, then the variable's name, followed by the `=` sign. This creates an [immutable][8] variable.
|
||||
|
||||
Most of your variables will be immutable, but the `rng` object must be mutable. For example, the statement `let random = 0` assigns a zero value to the `random` variable.
|
||||
|
||||
The first line of the function creates a thread-safe `Rng` object and assigns it to the variable `rng`. Rust is built on thread and memory safety, so you must think about those things as soon as you start writing code.
|
||||
|
||||
The next line of the program reads the result of the function `gen_range()` and assigns it to the variable called `random`. The function takes a minimum (inclusive) and an upper bound (not inclusive). To make the upper bound inclusive, you can mark the greater number with an equal sign (for example, `1..=100`), or you can just set the upper bound to 1 above your intended maximum, as I've done in my code. In this case, the range is `1` to `100`, making the game just challenging enough.
|
||||
|
||||
The central loop iterates over the lines in `std::io::stdin()`. Since there are all sorts of corner cases that might result in a line not being read, Rust requires you to wrap a line with a `Result`. It might also be impossible for a line to parse an integer.
|
||||
|
||||
This code uses conditional pattern-matching to ignore all lines that would have caused errors:
|
||||
|
||||
|
||||
```
|
||||
let parsed = line.ok().as_deref().map(str::parse::<i64>);
|
||||
if let Some(Ok(guess)) = parsed {
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
The first line creates a `Result<Option<i64>, ...>` object because it might fail at the reading or parsing steps. Since the next line only matches on `Some(Ok(guess))`, whenever a line results in a value that does not match, it skips the `if` statement. This is a powerful way to ignore errors.
|
||||
|
||||
Rust supports conditional expressions and flow control, like loops. In the "guess the number" game, Rust continues looping as long as the value in the guess is not equal to `random`.
|
||||
|
||||
The body of the `if` statement contains a three-way branch using Rust's `match` statement. While `match` is most often used for pattern matching, it can also check arbitrary conditions. In this case, print an appropriate message and `break` the loop if the guess is correct.
|
||||
|
||||
### Sample output
|
||||
|
||||
Now that you've written your Rust program, you can run it to play the "guess the number" game. Every time you run the program, Rust will pick a different random number, so keep guessing until you find the correct number:
|
||||
|
||||
|
||||
```
|
||||
$ cargo run
|
||||
Compiling guess v2020.11.0 (/Users/mzadka/src/guess)
|
||||
Finished dev [unoptimized + debuginfo] target(s) in 0.70s
|
||||
Running `target/debug/guess`
|
||||
Guess a number between 1 and 100
|
||||
50
|
||||
Too high
|
||||
25
|
||||
Too high
|
||||
12
|
||||
Too low
|
||||
18
|
||||
Too high
|
||||
15
|
||||
Too high
|
||||
13
|
||||
Too low
|
||||
14
|
||||
That's right
|
||||
```
|
||||
|
||||
It is typical to test the program by running it with `cargo run`. Eventually, you'll probably use `cargo build` to [build an executable and run it][9] as two separate steps.
|
||||
|
||||
### Learn Rust
|
||||
|
||||
This "guess the number" game is a great introductory program for learning a new programming language because it exercises several common programming concepts in a pretty straightforward way. By implementing this simple game in different programming languages, you can demonstrate some core concepts of the languages and compare their details.
|
||||
|
||||
Do you have a favorite programming language? How would you write the "guess the number" game in it? Follow this article series to see examples of other programming languages that might interest you!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/12/learn-rust
|
||||
|
||||
作者:[Moshe Zadka][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者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/moshez
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rust_programming_crab_sea.png?itok=2eWLz8A5 (Ferris the crab under the sea, unofficial logo for Rust programming language)
|
||||
[2]: https://www.rust-lang.org/learn/get-started
|
||||
[3]: https://play.rust-lang.org/
|
||||
[4]: https://www.rust-lang.org/
|
||||
[5]: https://doc.rust-lang.org/book/ch07-01-packages-and-crates.html
|
||||
[6]: mailto:moshez@opensource.com
|
||||
[7]: https://doc.rust-lang.org/rust-by-example/trait.html
|
||||
[8]: https://en.wikipedia.org/wiki/Immutable_object
|
||||
[9]: https://opensource.com/article/20/3/rust-cargo
|
290
sources/tech/20201222 Learn to use the Sed text editor.md
Normal file
290
sources/tech/20201222 Learn to use the Sed text editor.md
Normal file
@ -0,0 +1,290 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Learn to use the Sed text editor)
|
||||
[#]: via: (https://opensource.com/article/20/12/sed)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
|
||||
|
||||
Learn to use the Sed text editor
|
||||
======
|
||||
Sed lacks the usual text boxes and instead writes directly on a file,
|
||||
directed by user commands.
|
||||
![Command line prompt][1]
|
||||
|
||||
Created for version 7 of AT&T’s original Unix operating system, the `sed` command has been included with probably every Unix and Linux OS since. The `sed` application is a _stream editor_, and unlike a text editor it doesn’t open a visual buffer into which a file’s data is loaded for processing. Instead, it operates on a file, line by line, according to either a command typed into a terminal or a series of commands in a script.
|
||||
|
||||
### Installing
|
||||
|
||||
If you’re using Linux, BSD, or macOS, then you already have GNU or BSD `sed` installed. These are two unique reimplementations of the original `sed` command, and while they’re similar, there can be minor differences. GNU `sed` is generally regarded to be the most feature-rich `sed` out there, and it’s widely available on any of these platforms.
|
||||
|
||||
If you can’t find GNU `sed` (often called `gsed` on non-Linux systems), then you can [download its source code from the GNU website][2]. The nice thing about having GNU `sed` installed is that it can be used for its extra functions, but it can also be constrained to conform to just the [POSIX][3] specifications of `sed`, should you require portability.
|
||||
|
||||
On Windows, you can [install][4] GNU `sed` with [Chocolatey][5].
|
||||
|
||||
### How Sed works
|
||||
|
||||
The `sed` application works on one line at a time. Because it has no visual display, it creates a pattern space—a space in memory containing the current line from the input stream (with any trailing newline character removed). Once the pattern space is populated, your instructions to `sed` are executed. Sometimes your commands are conditional, and other times they are absolute, so the results of these commands depend on how you’re using `sed`.
|
||||
|
||||
When the end of commands is reached, `sed` prints the contents of the pattern space to the output stream. The default output stream is **stdout**, but it can be redirected to a file or even back into the same file using the `--in-place=.bak` option.
|
||||
|
||||
Then the cycle begins again with the next input line.
|
||||
|
||||
The syntax for the `sed` command is:
|
||||
|
||||
|
||||
```
|
||||
`$ sed --options [optional SCRIPT] [INPUT FILE or STREAM]`
|
||||
```
|
||||
|
||||
#### Finding what you want to edit
|
||||
|
||||
In a visual editor, you usually locate what you want to change in a text file without thinking much about it. Your eye (or screen reader) scans the text, finds the word you want to change or the place you want to insert or remove text, and then you just start typing. There is no interactive mode for `sed`, though, so you must tell it what conditions must be met for it to run specific commands.
|
||||
|
||||
For these examples, assume that a file called `example.txt` contains this text:
|
||||
|
||||
|
||||
```
|
||||
hello
|
||||
world
|
||||
This is line three.
|
||||
Here is the final line.
|
||||
```
|
||||
|
||||
#### Line number
|
||||
|
||||
Specifying a line number tells `sed` to operate only on that specific line in the file.
|
||||
|
||||
For instance, this command selects line 1 of a file and prints it. Because `sed`’s default action after processing is also to print a line to **stdout**, this has the effect of duplicating the first line:
|
||||
|
||||
|
||||
```
|
||||
$ sed ‘1p’ example.txt
|
||||
hello
|
||||
hello
|
||||
world
|
||||
This is line three.
|
||||
Here is the final line.
|
||||
```
|
||||
|
||||
You can specify line numbers in steps, too. For instance, `1~2` indicates that every 2 lines are selected ("select every second line starting with the first"). The instruction `1~3` means to select every third line after the first:
|
||||
|
||||
|
||||
```
|
||||
$ sed ‘1p’ example.txt
|
||||
hello
|
||||
hello
|
||||
world
|
||||
This is line three.
|
||||
Here is the final line.
|
||||
Here is the final line.
|
||||
```
|
||||
|
||||
#### Line position
|
||||
|
||||
You can operate only on the last line of a file by using `$` as a selector:
|
||||
|
||||
|
||||
```
|
||||
$ sed ‘$p’ example.txt
|
||||
hello
|
||||
world
|
||||
This is line three.
|
||||
Here is the final line.
|
||||
Here is the final line.
|
||||
```
|
||||
|
||||
In GNU `sed`, you can select more than one line (`sed '1,$p'` prints the first and final line, for example).
|
||||
|
||||
#### Negation
|
||||
|
||||
Any selection by number or position, you can invert with the exclamation mark (`!`) character. This selects all lines _except_ the first line:
|
||||
|
||||
|
||||
```
|
||||
$ sed ‘1!p’ example.txt
|
||||
hello
|
||||
world
|
||||
world
|
||||
This is line three.
|
||||
This is line three.
|
||||
Here is the final line.
|
||||
Here is the final line.
|
||||
```
|
||||
|
||||
#### Pattern matching
|
||||
|
||||
You can think of a pattern match as a **find** operation in a word processor or a browser. You provide a word (a _pattern_), and the results are selected. The syntax for a pattern match is `/pattern/`.
|
||||
|
||||
|
||||
```
|
||||
$ sed ‘/hello/p’ example.txt
|
||||
hello
|
||||
hello
|
||||
world
|
||||
This is line three.
|
||||
Here is the final line.
|
||||
$ sed ‘/line/p’ example.txt
|
||||
hello
|
||||
world
|
||||
This is line three.
|
||||
This is line three.
|
||||
Here is the final line.
|
||||
Here is the final line.
|
||||
```
|
||||
|
||||
### Editing with Sed
|
||||
|
||||
Once you’ve found what you want to edit, you can perform whatever action you want. You perform edits with `sed` with commands. Commands in `sed` are different from the `sed` command itself. If it helps, think of them as "actions" or "verbs" or "instructions."
|
||||
|
||||
Commands in `sed` are single letters, such as the `p` for **print** command used in previous examples. They can be difficult to recall at first, but as with everything, you get to know them with practice.
|
||||
|
||||
#### p for print
|
||||
|
||||
The `p` instruction prints whatever is currently held in pattern space.
|
||||
|
||||
#### d for delete
|
||||
|
||||
The `d` instruction deletes the pattern space.
|
||||
|
||||
|
||||
```
|
||||
$ sed ‘$d’ example.txt
|
||||
hello
|
||||
world
|
||||
This is line three.
|
||||
$ sed ‘1d’ example.txt
|
||||
world
|
||||
This is line three.
|
||||
Here is the final line.
|
||||
```
|
||||
|
||||
#### s for search and replace
|
||||
|
||||
The `s` command searches for a pattern and replaces it with something else. This is probably the most popular and casual use for `sed`, and it’s often the first (and sometimes the only) `sed` command a user learns. It’s almost certainly the most useful command for text editing.
|
||||
|
||||
|
||||
```
|
||||
$ sed ‘s/world/opensource.com/’
|
||||
hello
|
||||
opensource.com
|
||||
This is line three.
|
||||
Here is the final line.
|
||||
```
|
||||
|
||||
There are special functions you can use in your replacement text, too. For instance, `\L` transforms the replacement text to lowercase and `\l` does the same for just the next character. There are others, which are listed in the `sed` documentation (you can view that with the `info sed` command).
|
||||
|
||||
The special character `&` in the replacement clause refers to the matched pattern:
|
||||
|
||||
|
||||
```
|
||||
$ sed ‘s/is/\U&/’ example.txt
|
||||
hello
|
||||
world
|
||||
ThIS is line three.
|
||||
Here IS the final line.
|
||||
```
|
||||
|
||||
You can also pass special flags to affect how `s` processes what it finds. The `g` (for _global_, presumably) flag tells `s` to apply the replacement to all matches found on the line and not just the first match:
|
||||
|
||||
|
||||
```
|
||||
$ sed ‘s/is/\U&/g’ example.txt
|
||||
hello
|
||||
world
|
||||
ThIS IS line three.
|
||||
Here IS the final line.
|
||||
```
|
||||
|
||||
Other important flags include a number to indicate which occurrence of a matched pattern to affect:
|
||||
|
||||
|
||||
```
|
||||
$ sed ‘s/is/\U&/2’ example.txt
|
||||
hello
|
||||
world
|
||||
This IS line three.
|
||||
Here is the final line.
|
||||
```
|
||||
|
||||
The `w` flag, followed by a filename, writes a matched line to a file _only if_ a change is made:
|
||||
|
||||
|
||||
```
|
||||
$ sed ‘s/is/\U&/w sed.log’ example.txt
|
||||
hello
|
||||
world
|
||||
ThIS is line three.
|
||||
Here IS the final line.
|
||||
$ cat sed.log
|
||||
ThIS is line three.
|
||||
Here IS the final line.
|
||||
```
|
||||
|
||||
Flags can be combined:
|
||||
|
||||
|
||||
```
|
||||
$ sed ‘s/is/\U&/2w sed.log’ example.txt
|
||||
hello
|
||||
world
|
||||
This IS line three.
|
||||
Here is the final line.
|
||||
$ cat sed.log
|
||||
This IS line three.
|
||||
```
|
||||
|
||||
### Scripts
|
||||
|
||||
There are lots of great sites out there with `sed` "one-liners." They give you task-oriented `sed` commands to solve common problems. However, learning `sed` for yourself enables you to write your own one-liners, and those can be tailored to your specific needs.
|
||||
|
||||
Scripts for `sed` can be written as lines in a terminal, or they can be saved to a file and executed with `sed` itself. I tend to write small scripts all as one command because I find myself rarely re-using `sed` commands in real life. When I write a `sed` script, it’s usually very specific to one file. For example, after writing the initial draft of this very article, I used `sed` to standardize the capitalization of "sed", and that’s a task I’ll probably never have to do again.
|
||||
|
||||
You can issue a series of distinct commands to `sed` separated by a semicolon (`;`).
|
||||
|
||||
|
||||
```
|
||||
$ sed ‘3t ; s/line/\U&/’ example.txt
|
||||
hello
|
||||
world
|
||||
This is LINE three.
|
||||
This is the final line.
|
||||
```
|
||||
|
||||
### Scope changes with braces
|
||||
|
||||
You can also limit which results are affected with braces (`{}`). When you enclose `sed` commands in braces, they apply only to a specific selection. For example, the word "line" appears in two lines of the sample text. You can force `sed` to affect only the final line by declaring the required match condition (`$` to indicate the final line) and placing the `s` command you want to be performed in braces immediately thereafter:
|
||||
|
||||
|
||||
```
|
||||
$ sed ‘$ {s/line/\U&/}’ example.txt
|
||||
hello
|
||||
world
|
||||
This is line three.
|
||||
This is the final LINE.
|
||||
```
|
||||
|
||||
### Learn Sed
|
||||
|
||||
You can do a lot more with `sed` than what’s explained in this article. I haven’t even gotten to branching (`b`), tests (`t`), the _hold_ space (`H`), and many other features. Like [`ed`][6], `sed` probably isn’t the text editor you’re going to use for document creation or even for every scripted task you need doing, but it is a powerful option you have as a POSIX user. Learning how `sed` commands are structured and how to write short scripts can make for quick changes to massive amounts of text. Read through the `info` pages of GNU `sed`, or the man pages of BSD `sed`, and find out what `sed` can do for you.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/12/sed
|
||||
|
||||
作者:[Seth Kenlon][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者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/seth
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/command_line_prompt.png?itok=wbGiJ_yg (Command line prompt)
|
||||
[2]: http://www.gnu.org/software/sed/
|
||||
[3]: https://opensource.com/article/19/7/what-posix-richard-stallman-explains
|
||||
[4]: https://chocolatey.org/packages/sed
|
||||
[5]: https://opensource.com/article/20/3/chocolatey
|
||||
[6]: https://opensource.com/article/20/12/gnu-ed
|
@ -1,193 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to View Images from the Linux Terminal)
|
||||
[#]: via: (https://www.2daygeek.com/how-to-view-display-images-from-linux-terminal/)
|
||||
[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/)
|
||||
|
||||
如何从 Linux 终端查看图像
|
||||
======
|
||||
|
||||
Linux 有很多用于查看图像的 GUI 应用。
|
||||
|
||||
但我从来没有尝试过用任何命令行应用来查看它。
|
||||
|
||||
幸运的是,在使用 **[ImageMagick 工具][1]**时,我得到了一个从终端查看图像的命令。
|
||||
|
||||
命令名是 **“display”**,它是 ImageMagick 工具的一部分。
|
||||
|
||||
这是一个很好的工具,允许类 UNIX 用户从终端查看图像。
|
||||
|
||||
此外,我还为此得到了另一个很好的工具,叫做 FIM。
|
||||
|
||||
我们将向你展示如何安装并使用它从 Linux 终端查看图像。
|
||||
|
||||
这些命令使用系统的帧缓冲直接从命令行显示图像。
|
||||
|
||||
### 如何使用 display 命令从终端查看图像
|
||||
|
||||
[ImageMagick][2] 是一个免费开源、功能丰富、基于命令行的图像处理工具。
|
||||
|
||||
它用于创建、编辑、合成或转换位图图像。
|
||||
|
||||
它可以读取和写入各种格式(超过 200 种)的图像,包括 PNG、JPEG、GIF、PDF、SVG 等。
|
||||
|
||||
它可以调整图像的大小、镜像、旋转、转换图像、调整图像颜色、应用各种特殊效果等。
|
||||
|
||||
它支持批处理,允许你一次处理所有图像。
|
||||
|
||||
### 如何安装 ImageMagick?
|
||||
|
||||
ImageMagick 软件包包含在大多数 Linux 发行版的官方仓库中。使用发行版软件包管理器来安装它。
|
||||
|
||||
**需要注意的是:**确保你的 Linux 系统上已经安装了 “**[Development Tools][3]**” 包,这是安装的前提条件。
|
||||
|
||||
对于 **RHEL/CentOS 6/7** 系统,请使用 **[yum 命令][4]** 安装 ImageMagick。
|
||||
|
||||
```
|
||||
$ sudo yum install -y ImageMagick ImageMagick-devel
|
||||
```
|
||||
|
||||
在 **RHEL/CentOS 8** 和 **Fedora** 系统,使用 **[dnf 命令][5]** 安装 ImageMagick。
|
||||
|
||||
```
|
||||
$ sudo dnf install -y ImageMagick ImageMagick-devel
|
||||
```
|
||||
|
||||
对于 **Debian/Ubuntu** 系统,使用 **[apt 命令][6]** 或 **[apt-get 命令][7]** 安装 ImageMagick。
|
||||
|
||||
```
|
||||
$ sudo apt-get update
|
||||
$ sudo apt-get install imagemagick
|
||||
```
|
||||
|
||||
对于 **openSUSE** 系统,使用 **[zypper 命令][8]** 安装 ImageMagick。
|
||||
|
||||
```
|
||||
$ sudo zypper install -y ImageMagick
|
||||
```
|
||||
|
||||
要查看任何图像文件,请运行 display 命令,如下所示。你可以按下 **“Esc/q”** 按钮关闭图像。
|
||||
|
||||
```
|
||||
$ display bird.jpg
|
||||
```
|
||||
|
||||
![][9]
|
||||
|
||||
如果你想用指定的窗口大小打开图像,请使用 **“-geometry”** 标志。
|
||||
|
||||
```
|
||||
$ display -geometry 1000x600 ~/Downloads/bird.jpg
|
||||
```
|
||||
|
||||
你也可以通过 display 命令输入图像的位置信息。下面的命令可以从桌面的距顶部 800 像素和据左上角 800 像素处打开图像。
|
||||
|
||||
```
|
||||
$ display -geometry 1000x600+800+800 ~/Downloads/bird.jpg
|
||||
```
|
||||
|
||||
如果你想用 display 命令调整图像的大小,请使用以下格式。
|
||||
|
||||
```
|
||||
$ display -resize 600x400 ~/Downloads/bird.jp
|
||||
```
|
||||
|
||||
另外,你也可以使用百分比来调整图片的大小。
|
||||
|
||||
```
|
||||
$ display -resize 50% ~/Downloads/bird.jpg
|
||||
```
|
||||
|
||||
### 如何使用 fim 命令从终端查看图像。
|
||||
|
||||
[FIM][10] 是一个专门为 Linux 设计的轻量级全局图像查看器。
|
||||
|
||||
但它并不局限于 Linux,它也可配置在其他操作系统上运行,如 MS-Windows。
|
||||
|
||||
对于熟悉 VIM 文本编辑器等软件的用户来说,它是高度可定制和可脚本化的图像查看器。
|
||||
|
||||
它可以全屏显示图像,并且可以使用键盘快捷键轻松控制。
|
||||
|
||||
它是一款非常轻量级的工具,因为它只依赖于某些库。
|
||||
|
||||
它可以打开许多文件格式,它可以在以下视频模式下显示图像。
|
||||
|
||||
* 使用 Linux 帧缓冲设备图形化。
|
||||
* 在 X/Xorg 下,使用 SDL 库图形化
|
||||
* 在 X/Xorg 下,使用 Imlib2 库图形化。
|
||||
* 使用 AAlib 库,在任意文本控制台中以 ASCII 艺术形式呈现。
|
||||
|
||||
|
||||
|
||||
正确的视频模式会在运行时自动检测或选择,如果需要,可以在构建前配置时选择加入或去除。
|
||||
|
||||
FIM 是 Fbi IMproved 的缩写,是 Fbi Image Viewer 的分支。
|
||||
|
||||
FIM 可以很容易地安装在基于 Debian/Ubuntu 的系统上,因为该软件包在发行版的官方仓库中是可用的。对于其他发行版,你可能需要从源码编译它。
|
||||
|
||||
```
|
||||
$ sudo apt install fim
|
||||
```
|
||||
|
||||
安装完毕后,你可以使用以下命令显示图像。
|
||||
|
||||
```
|
||||
$ fim bird.jpg
|
||||
```
|
||||
|
||||
你可以使用 **“-a”** 选项自动缩放图像。
|
||||
|
||||
```
|
||||
$ fim -a bird.jpg
|
||||
```
|
||||
|
||||
![][9]
|
||||
|
||||
如果你要打开当前目录中的多个图像文件,请使用通配符将它们全部打开。使用 **“Pageup/Down”** 键盘快捷键移动到下一张或上一张图像。
|
||||
|
||||
```
|
||||
$ fim -a *.jpg
|
||||
```
|
||||
|
||||
要查看 ASCII 格式的图像,可以使用 **“-t”** 标志。
|
||||
|
||||
```
|
||||
$ fim -t bird.jpg
|
||||
```
|
||||
|
||||
下面的键盘快捷键可以让你控制图像。
|
||||
|
||||
* PageUp/Down:上一张/下一张图片。
|
||||
* +/-:放大/缩小
|
||||
* a:自动标度
|
||||
* w:适应宽度
|
||||
* ESC/q:退出
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.2daygeek.com/how-to-view-display-images-from-linux-terminal/
|
||||
|
||||
作者:[Magesh Maruthamuthu][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.2daygeek.com/author/magesh/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.2daygeek.com/resize-convert-images-from-linux-command-line/
|
||||
[2]: https://imagemagick.org/
|
||||
[3]: https://www.2daygeek.com/install-development-tools-on-ubuntu-debian-arch-linux-mint-fedora-centos-rhel-opensuse/
|
||||
[4]: https://www.2daygeek.com/linux-yum-command-examples-manage-packages-rhel-centos-systems/
|
||||
[5]: https://www.2daygeek.com/linux-dnf-command-examples-manage-packages-fedora-centos-rhel-systems/
|
||||
[6]: https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/
|
||||
[7]: https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/
|
||||
[8]: https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/
|
||||
[9]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
|
||||
[10]: https://www.nongnu.org/fbi-improved/#docs
|
@ -0,0 +1,104 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Font Manager: A Simple Open-Source App for GTK+ Desktop)
|
||||
[#]: via: (https://itsfoss.com/font-manager/)
|
||||
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
|
||||
|
||||
Font Manager:一个简单的 GTK+ 桌面的开源应用
|
||||
======
|
||||
|
||||
_**简介:一个非常简单的字体管理器应用,让你专注于调整 Linux 系统上的字体。**_
|
||||
|
||||
如果你是一个有经验的 Linux 用户,你可能会利用终端或 [tweak 工具][1]来管理你的 Linux 系统的字体。
|
||||
|
||||
老实说,不管 GNOME tweak 工具有多有用,仅仅管理字体可能会让人有点受不了。因此,一个单独的应用可以很好地帮助你管理字体。
|
||||
|
||||
### Font Manager:一个帮助管理字体的开源应用
|
||||
|
||||
![][2]
|
||||
|
||||
Font Manager(这就是应用的字面名称)是一个专门帮助你管理字体的应用。
|
||||
|
||||
你可以获得字体家族的详细信息,可用的变体,以及根据字体的高度、宽度、间距等进行过滤和调整的功能。考虑到它是一个简单的应用,因此你找不到很多功能,但是我将在下面简要介绍一些功能。
|
||||
|
||||
### Font Manager 的功能
|
||||
|
||||
![][3]
|
||||
|
||||
* 可以添加字体
|
||||
* 可以删除字体
|
||||
* 根据家族、供应商、间距、高度等因素轻松过滤字体
|
||||
* 调整字体的缩放系数
|
||||
* 调整字体的抗锯齿(软度/锐度)
|
||||
* 添加字体源,以便在安装前进行预览
|
||||
* 提供快速管理的键盘快捷键
|
||||
* 开箱即用的谷歌字体集成
|
||||
* 获取关于家族字体中可用字符的详细信息、许可证、字体大小、供应商、文件类型、间距、宽度和样式
|
||||
|
||||
|
||||
|
||||
![][4]
|
||||
|
||||
总的来说,你可以轻松安装或删除字体。但是,当你管理字体时,你会得到相当多的好处,如上面的截图所示。
|
||||
|
||||
### 在 Linux 上安装 Font Manager
|
||||
|
||||
你有多种选择(取决于你使用的 Linux 发行版)进行安装。
|
||||
|
||||
如果你使用的是基于 Ubuntu 的发行版,你可以通过下面的命令轻松添加 PPA 来安装 Font Manager:
|
||||
|
||||
```
|
||||
sudo add-apt-repository ppa:font-manager/staging
|
||||
sudo apt update
|
||||
sudo apt install font-manager
|
||||
```
|
||||
|
||||
如果你不喜欢 [PPAs][5](我更喜欢这样安装),你也可以在任何 Linux 发行版上安装一个[可用的 Flatpak 包][6]。
|
||||
|
||||
你只需要在你的 Linux 系统上启用 Flatpak,然后在你的软件中心搜索它(如果它支持 Flatpak 集成的话),或者直接输入下面的命令安装它:
|
||||
|
||||
```
|
||||
flatpak install flathub org.gnome.FontManager
|
||||
```
|
||||
|
||||
如果你是 Arch 用户,你可以在 [AUR][8] 中找到[包][7]。
|
||||
|
||||
|
||||
更多的安装说明,你可以参考它的[官网][9]和 [GitHub 页面][10]。
|
||||
|
||||
[下载 Font Manager][9]
|
||||
|
||||
### 总结
|
||||
|
||||
Font Manager 是一个简单的解决方案,适用于任何基于 GTK+ 的桌面环境。主要用于 GNOME,但你在其他桌面环境使用它。
|
||||
|
||||
你可以得到很多有用的信息,同时可以添加或删除字体,我想这显然是一个不折不扣的字体管理器。
|
||||
|
||||
你对 Font Manager 有什么看法?在下面的评论中告诉我你的想法吧!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/font-manager/
|
||||
|
||||
作者:[Ankush Das][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/ankush/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://itsfoss.com/gnome-tweak-tool/
|
||||
[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/12/font-manager.png?resize=800%2C565&ssl=1
|
||||
[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/12/font-manager-settings.jpg?resize=800%2C569&ssl=1
|
||||
[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/12/font-manager-showcase.png?resize=800%2C571&ssl=1
|
||||
[5]: https://itsfoss.com/ppa-guide/
|
||||
[6]: https://flathub.org/apps/details/org.gnome.FontManager
|
||||
[7]: https://aur.archlinux.org/packages/font-manager/
|
||||
[8]: https://itsfoss.com/aur-arch-linux/
|
||||
[9]: https://fontmanager.github.io/
|
||||
[10]: https://github.com/FontManager/font-manager
|
Loading…
Reference in New Issue
Block a user