about summary refs log tree commit diff stats
path: root/ranger/ext/rifle.py
diff options
context:
space:
mode:
authorguangzhi <xugzhi1987@gmail.com>2018-03-11 08:52:23 +0800
committerguangzhi <xugzhi1987@gmail.com>2018-03-11 08:52:23 +0800
commit5fc66210888db4d446989bab64eb5270d08b4bad (patch)
tree0fe72a6082efc7ebc5e2d4a64c6a8bed2084f02e /ranger/ext/rifle.py
parentf855979587bd918f0d32c0caba79ab4b4aa531cf (diff)
downloadranger-5fc66210888db4d446989bab64eb5270d08b4bad.tar.gz
Attempt to fix issue #1108 flag t problem
issue #1108: Rifle's flag t only works with urxvt (and xterm) (because
who cares about standards?).  Urxvt passes any arguments after -e
verbatim, most other terminals consume them as arguments.  Some
terminals use -e, others use -x.

Fix: in rifle.py, if $TERMCMD is set to gnome-terminal, xfce4-terminal
etc., give either -e or -x that pairs with the terminal. If $TERMCMD not
found in executables, fall back to xterm and -e.
Diffstat (limited to 'ranger/ext/rifle.py')
-rwxr-xr-xranger/ext/rifle.py29
1 files changed, 22 insertions, 7 deletions
diff --git a/ranger/ext/rifle.py b/ranger/ext/rifle.py
index 70215039..670d40a4 100755
--- a/ranger/ext/rifle.py
+++ b/ranger/ext/rifle.py
@@ -359,19 +359,34 @@ class Rifle(object):  # pylint: disable=too-many-instance-attributes
                         term = os.environ['TERM']
                         if term.startswith('rxvt-unicode'):
                             term = 'urxvt'
+                            cmdflag='-e'
                         elif term.startswith('rxvt-'):
                             # Sometimes urxvt calls itself "rxvt-256color"
                             if 'rxvt' in get_executables():
                                 term = 'rxvt'
                             else:
                                 term = 'urxvt'
-                        if term not in get_executables():
-                            self.hook_logger("Can not determine terminal command.  "
-                                             "Please set $TERMCMD manually.")
-                            # A fallback terminal that is likely installed:
-                            term = 'xterm'
-                        os.environ['TERMCMD'] = term
-                    cmd = [os.environ['TERMCMD'], '-e'] + cmd
+                            cmdflag='-e'
+                    else:
+                        term = os.environ['TERMCMD']
+                        if term in ['gnome-terminal', 'xfce4-terminal', 'mate-terminal',\
+                                'terminator']:
+                            cmdflag='-x'
+                        elif term in ['lxterminal',]:
+                            cmdflag='-e'
+                        else:
+                            cmdflag='-e'
+
+                    if term not in get_executables():
+                        self.hook_logger("Can not determine terminal command.  "
+                                         "Please set $TERMCMD manually.")
+                        # A fallback terminal that is likely installed:
+                        term = 'xterm'
+                        cmdflag='-e'
+
+                    os.environ['TERMCMD'] = term
+                    cmd = [os.environ['TERMCMD'], cmdflag] + cmd
+
                 if 'f' in flags or 't' in flags:
                     Popen_forked(cmd, env=self.hook_environment(os.environ))
                 else: