Merge pull request #26405 from geekpi/translating

translated
This commit is contained in:
geekpi 2022-07-12 08:29:22 +08:00 committed by GitHub
commit a9f79d63b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 115 additions and 115 deletions

View File

@ -1,115 +0,0 @@
[#]: subject: "Manage your files in your Linux terminal with ranger"
[#]: via: "https://opensource.com/article/22/7/manage-files-linux-terminal-ranger"
[#]: author: "Sumantro Mukherjee https://opensource.com/users/sumantro"
[#]: collector: "lkxed"
[#]: translator: "geekpi"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
Manage your files in your Linux terminal with ranger
======
Try this lightweight open source tool to preview files without leaving the terminal.
![Filing cabinet for organization][1]
The most basic way to look at your files and folders is to use the commands `ls` and `ll`. But sometimes, I want to see not just the file metadata but also the contents of a file at a glance. For that, I use ranger.
If you love working out of your console and using [Vim][2] or Vi, and you dont want to leave your terminal for any reason, ranger is your new best friend. Ranger is a minimal file manager that allows you not only to navigate through the files but also to preview them. Ranger comes bundled with rifle, a file executor that can efficiently choose programs that work with a given file type.
### Installing ranger on Linux
Ranger can be installed in Fedora or any RPM-based distro by running
```
$ sudo dnf install ranger
```
Ranger is also available for [other distros and macOS][3].
### Using ranger for the first time
As a user, you can start ranger by simply typing `$ ranger` on your favorite terminal. The arrow keys give way to the navigation. This screenshot is an excellent example of how I can preview the code of the `config.example` file stored in `Kernel-tests`.
![Screenshot of terminal showing config.example highlighted and a preview of the file in the terminal to the right][4]
Picking any file and hitting F4 opens up your default editor and lets you edit the files right away!
### What about images and videos?
Using [rifle][5] with ranger lets you quickly find the program associated with a given file. Hovering over an image and then trying to open it is very simple; just hit Enter. Heres how that looks:
![Screenshot of a PNG file preview over a terminal window][6]
Hitting i on an image file will give the user all the EXIF data. Hitting **S****hift+Enter** will open the PDF file.
![A screenshot showing a preview of a PDF file (tickets to a museum) floating over the terminal window][7]
The same key combo will open and start playing videos in the system's default video player that supports the codec. The example below is an mp4 video, which plays just fine on [VLC][8].
![Screenshot of a Bugcrowd University Cross Site Scripting video in VLC media player, previewed over the terminal][9]
### File ops
The following key bindings work well unless otherwise configured by the Vim user.
j: Move down
k: Move up
h: Move to parent directory
gg: Go to the top of the list
i: Preview file
r: Open file
zh: View hidden files
cw: Rename current file
yy: Yank (copy) file
dd: Cut file
pp: Paste file
u: Undo
z: Change settings
dD: Delete file
### Console commands
Sometimes I have a folder that contains screenshots of a particular software when I am drafting articles. Selecting or marking files by hitting Space and then typing `:bulkrename` helps me move all the weird timestamps to, for example, lorax1, lorax2 , and so on. An example is below:
![Screenshot of terminal showing timestamped files that can be renamed with the bulkrename command][10]
Other useful console commands include:
`:openwith` : Open a select file with a program of your choice
`:touch FILENAME` : Create a file
`:mkdir FILENAME` : Create a directory
`:shell <command>` : Run a command in shell
`:delete` : Delete files
### Will it work in tty2/3/4?
As someone who works in quality assurance (QA), I've found that searching for logs and reading them has never been easier. Even when my Gnome Display Manager crashes, I can switch over to my tty2, log in with my username and password, and start ranger with superuser permission, and then I am all sorted to explore!
Ranger is a great tool for working with files without ever having to leave the terminal. Ranger is minimal and customizable, so give it go!
Image by: (Sumantro Mukherjee, CC BY-SA 4.0)
--------------------------------------------------------------------------------
via: https://opensource.com/article/22/7/manage-files-linux-terminal-ranger
作者:[Sumantro Mukherjee][a]
选题:[lkxed][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/sumantro
[b]: https://github.com/lkxed
[1]: https://opensource.com/sites/default/files/lead-images/files_documents_organize_letter.png
[2]: https://opensource.com/tags/vim
[3]: https://opensource.com/article/20/3/ranger-file-navigator
[4]: https://opensource.com/sites/default/files/2022-06/ranger%201.png
[5]: https://www.systutorials.com/docs/linux/man/1-rifle/
[6]: https://opensource.com/sites/default/files/2022-06/ranger%202.png
[7]: https://opensource.com/sites/default/files/2022-06/ranger%203.png
[8]: https://opensource.com/article/21/2/linux-media-players
[9]: https://opensource.com/sites/default/files/2022-06/ranger%204.png
[10]: https://opensource.com/sites/default/files/2022-06/ranger%205.png

View File

@ -0,0 +1,115 @@
[#]: subject: "Manage your files in your Linux terminal with ranger"
[#]: via: "https://opensource.com/article/22/7/manage-files-linux-terminal-ranger"
[#]: author: "Sumantro Mukherjee https://opensource.com/users/sumantro"
[#]: collector: "lkxed"
[#]: translator: "geekpi"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
用 ranger 在 Linux 终端管理你的文件
======
试试这个轻量级的开源工具,不用离开终端就可以预览文件。
![Filing cabinet for organization][1]
查看你的文件和文件夹的最基本方法是使用命令 `ls``ll`。但是有时候,我不仅想看到文件的元数据,还想一目了然地看到文件的内容。为此,我使用 ranger。
如果你喜欢在控制台中工作,并使用 [Vim][2] 或 Vi而且你不想因为任何原因离开你的终端那么 ranger 就是你最好的新朋友。Ranger 是一个最小的文件管理器它不仅可以让你浏览文件还可以预览它们。Ranger 与 rifle 捆绑在一起rifle 是一个文件执行器,可以有效地选择与特定文件类型相关的程序。
### 在 Linux 上安装 ranger
Ranger 可以在 Fedora 或任何基于 RPM 的发行版中安装,方法是运行:
```
$ sudo dnf install ranger
```
Ranger 也可以用于[其他发行版和 macOS][3]。
### 第一次使用 ranger
作为一个用户,你可以在你喜欢的终端上简单地输入 `$ ranger` 来启动 ranger。可以用方向键浏览。这张截图是一个很好的例子我可以预览存储在 `Kernel-tests` 中的 `config.example` 文件的代码。
![Screenshot of terminal showing config.example highlighted and a preview of the file in the terminal to the right][4]
选中任何文件并按下 F4 键,就可以打开你的默认编辑器,让你立即编辑这些文件!
### 图像和视频怎么办?
使用 [rifle][5] 和 ranger 可以让你快速找到与某一文件相关的程序。将鼠标悬停在图片上,然后试图打开它是非常简单的,只要点击回车即可。下面是它的样子:
![Screenshot of a PNG file preview over a terminal window][6]
在一个图像文件上点击 i 会给用户提供所有的 EXIF 数据。点击 **Shift+Enter** 将打开 PDF 文件。
![A screenshot showing a preview of a PDF file (tickets to a museum) floating over the terminal window][7]
同样的组合键将在系统默认的支持该编解码器的视频播放器中打开并开始播放视频。下面的例子是一个 mp4 视频,它在 [VLC][8] 上播放得很好。
![Screenshot of a Bugcrowd University Cross Site Scripting video in VLC media player, previewed over the terminal][9]
### 文件操作
除非 Vim 用户另有配置,否则下面的键绑定工作良好。
j下移
k上移
h: 移动到父目录
gg移到列表的顶部
i预览文件
r打开文件
zh查看隐藏文件
cw重命名当前文件
yy复制文件
dd剪切文件
pp粘贴文件
u撤销
z改变设置
dD删除文件
### 控制台命令
有时我在起草文章时,有一个文件夹包含某个软件的截图。通过点击空格选择或标记文件,然后输入 `:bulkrename`可以帮助我把所有奇怪的时间戳变成如lorax1、lorax2 等等。下面是一个例子。
![Screenshot of terminal showing timestamped files that can be renamed with the bulkrename command][10]
其他有用的控制台命令包括:
`:openwith`:用你选择的程序打开一个选择的文件
`:touch FILENAME`:创建一个文件
`:mkdir FILENAME`:创建一个目录
`:shell <command>`:在 shell 中运行一个命令
`:delete`:删除文件
### 在 tty2/3/4 中能工作吗?
作为一个从事质量保证QA工作的人我发现搜索日志和阅读日志从未如此简单。即使我的 Gnome 显示管理器崩溃了,我也可以切换到我的 tty2用我的用户名和密码登录并以超级用户权限启动 ranger然后我就可以尽情地探索了
Ranger 是一个很好的工具可以在不离开终端的情况下处理文件。Ranger 是最小的,也是可定制的,所以不妨一试吧!
图片来源Sumantro MukherjeeCC BY-SA 4.0
--------------------------------------------------------------------------------
via: https://opensource.com/article/22/7/manage-files-linux-terminal-ranger
作者:[Sumantro Mukherjee][a]
选题:[lkxed][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/sumantro
[b]: https://github.com/lkxed
[1]: https://opensource.com/sites/default/files/lead-images/files_documents_organize_letter.png
[2]: https://opensource.com/tags/vim
[3]: https://opensource.com/article/20/3/ranger-file-navigator
[4]: https://opensource.com/sites/default/files/2022-06/ranger%201.png
[5]: https://www.systutorials.com/docs/linux/man/1-rifle/
[6]: https://opensource.com/sites/default/files/2022-06/ranger%202.png
[7]: https://opensource.com/sites/default/files/2022-06/ranger%203.png
[8]: https://opensource.com/article/21/2/linux-media-players
[9]: https://opensource.com/sites/default/files/2022-06/ranger%204.png
[10]: https://opensource.com/sites/default/files/2022-06/ranger%205.png