系统相关
首页 > 系统相关> > linux – Ranger文件管理器 – 打开gnome-terminal而不是xterm

linux – Ranger文件管理器 – 打开gnome-terminal而不是xterm

作者:互联网

我最近开始使用Ranger作为我的默认文件管理器,我真的很享受它.现在,我已经设法更改rifle.conf,这样当我从Ranger播放音频或视频时,mpv会在新的xterm窗口中打开并且媒体开始播放.

但是,如果可能的话,我希望Ranger打开gnome-terminal而不是xterm.在/.config/ranger/rifle.conf中,它表示使用t标志将在新终端中运行程序:

如果未定义$TERMCMD,则步枪将尝试从$TERM中提取它

我尝试在我的.profile和.bashrc文件中设置$TERMCMD,但即使echo $TERMCMD会打印“gnome-terminal”,Ranger仍会打开xterm.我也把$TERM设置为“gnome-terminal”,但这很混乱,我决定不管它.

有什么建议?谢谢!

解决方法:

截至2017年,源代码(runner.py)做到了这一点:

        term = os.environ.get('TERMCMD', os.environ.get('TERM'))
        if term not in get_executables():
            term = 'x-terminal-emulator'
        if term not in get_executables():
            term = 'xterm'
        if isinstance(action, str):
            action = term + ' -e ' + action
        else:
            action = [term, '-e'] + action

所以你应该能够在TERMCMD中放置任何xterm兼容的程序名称.但是,请注意使用-e(gnome-terminal与xterm的行为不匹配).如果您使用的是Debian / Ubuntu / etc,Debian打包程序试图提供一个包装器来隐藏x-terminal-emulator功能中的这种差异.如果这适用于您,您可以将TERMCMD设置为x-terminal-emulator.

跟进 – 虽然自2016年中期以来TERMCMD功能的设计没有明显改变,但源内的位置已发生变化:

> Refactor and improve the TERMCMD handling 将其移至ranger/ext/get_executables.py

这是在get_term实施的:

def get_term():
    """Get the user terminal executable name.
    Either $TERMCMD, $TERM, "x-terminal-emulator" or "xterm", in this order.
    """
    command = environ.get('TERMCMD', environ.get('TERM'))
    if shlex.split(command)[0] not in get_executables():
        command = 'x-terminal-emulator'
        if command not in get_executables():
            command = 'xterm'
    return command

它像以前一样使用x-terminal-emulator.

rifle.py中有一个相关的TERMCMD用途,用于执行命令而不是(如问题中所要求的)打开终端.无论哪种方式,使用游侠的关键是x-terminal-emulator,因为GNOME Terminal的开发人员没有记录他们的命令行界面,而Debian开发人员提供了这种解决方法.

引自Bug 701691 – -e accepts only one term; all other terminal emulators accept more than one term(开发人员拒绝修复,标记为“不是错误”):

Christian Persch 2013-06-06 16:02:54 UTC

There are no docs for the gnome-terminal command line options.

标签:gnome-terminal,linux,environment-variables,xterm,file-manager
来源: https://codeday.me/bug/20190810/1641290.html