通过cygwin在windows中使用ranger正确打开文件(rifle.py) [英] Using ranger in windows through cygwin to open files correctly(rifle.py)

查看:125
本文介绍了通过cygwin在windows中使用ranger正确打开文件(rifle.py)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您在 windows 中安装了 Cygwin,并且在其中安装了 ranger,那么您可能无法通过 ranger 打开文件,因为 Cygwin 中的路径与 windows 中的路径不同.

If you installed Cygwin in windows, and also ranger inside it, then probably you can't open files via ranger, because paths in Cygwin is different with paths in windows.

在 Cygwin 中,路径类似于:/cygdrive/c/go/to/path 但在 Windows 中:c:/go/to/path 而对于这种差异,您无法在 Ranger 中打开您的文件(安装在 Cygwin 中).

In Cygwin paths are like: /cygdrive/c/go/to/path but in windows: c:/go/to/path and for this difference you can't open your files inside ranger(installed in Cygwin).

现在我们如何使用 ranger 在 windows 中正确打开我们的文件?

推荐答案

这是我用来解决这个问题的一个技巧.

Here is a trick that I'm using for solving this problem.

  1. 打开步枪文件

如果你不知道它在哪里,你需要通过使用这个命令运行 ranger 来创建默认的: ranger --copy-config all 它将复制您的主目录中的默认配置文件(home/.config/ranger/CONFIG_FILES)

  1. 编辑命令(例如:文本编辑器)
  1. Edit commands(ex: text editor)

这是主要部分,找到包含此内容的行:

Here is the main section, find the line with this content:

mime ^text, label editor = ${VISUAL:-$EDITOR} -- "$@"

"$@" 指的是选中文件的路径,但是不对,需要改成这样:

the "$@" refers to the path of the selected file, but it's wrong, you need to change it like this:

mime ^text, label editor = runemacs.exe -- `sed 's%/cygdrive/e/%e:/%g' <<<"$@"`

  • 如您所见,我将 ${VISUAL:-$EDITOR} 变量更改为我自己的程序(runemacs.exe)

  • As you can see, I changed the ${VISUAL:-$EDITOR} variable to my own program(runemacs.exe)

`commands` 是命令替代(在 Linux 中),将为我们打印其命令的输出

`commands` is command substitute(in Linux) and will print the output of its commands for us

<<< 是这里的文档(同样是 Linux 功能)

<<< is the here doc(again it's a Linux feature)

sed 是一个搜索/替换命令

sed is a command for search/replace

sed 's%/cygdrive/e/%e:/%g' 表示搜索[使用 s 命令] 用于 /cygdrive/e/[你可以将此路径更改为你自己的],并将其替换为 e:/,以及 g> 表示全局搜索并替换它.

sed 's%/cygdrive/e/%e:/%g' means that search[using s command] for /cygdrive/e/[you can change this path to your own], and replace it with e:/, and also the g means globally search and replace it.

  1. 完成

这篇关于通过cygwin在windows中使用ranger正确打开文件(rifle.py)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆