Browse Source

Merge branch 'master' of git.hammerle.me:fphammerle/config-xonsh

Fabian Peter Hammerle 5 years ago
parent
commit
29e63ecbf3
2 changed files with 43 additions and 2 deletions
  1. 29 0
      ranger-termite-termcmd
  2. 14 2
      rc.xsh

+ 29 - 0
ranger-termite-termcmd

@@ -0,0 +1,29 @@
+#!/usr/bin/env python3
+
+"""
+ranger/ext/rifle.py:
+> self.hook_before_executing(command, self._mimetype, self._app_flags)
+> try:
+>     if 'r' in flags:
+>         prefix = ['sudo', '-E', 'su', '-mc']
+>     else:
+>         prefix = ['/bin/sh', '-c']
+>
+>     cmd = prefix + [command]
+>     if 't' in flags:
+>         # ...
+>         cmd = [os.environ['TERMCMD'], '-e'] + cmd
+
+however termite expects the entire cmd as one single param
+"""
+
+import pipes
+import subprocess
+import sys
+
+assert sys.argv[1] == '-e', sys.argv
+
+subprocess.call([
+    'termite',
+    '--exec={}'.format(' '.join(pipes.quote(p) for p in sys.argv[2:])),
+])

+ 14 - 2
rc.xsh

@@ -24,10 +24,22 @@ $PROMPT = ''.join([
 ])
 $RIGHT_PROMPT = '{gitstatus}{env_name: {}}'
 
-import re as re
+import os
+import re
 
+$EDITOR = 'vim'
 # required by pinentry-tty when using gpg command:
-$GPG_TTY=$(tty)
+$GPG_TTY = $(tty)
+# wrapper for termite required when launching termite from ranger:
+$TERMCMD = os.path.join(os.path.dirname(__file__), 'ranger-termite-termcmd')
+
+def locate(*patterns, match_all=True, ignore_case=True):
+    params = []
+    if match_all:
+        params.insert(0, '--all')
+    if ignore_case:
+        params.insert(0, '--ignore-case')
+    return $(locate @(params) -- @(patterns)).split('\n')[:-1]
 
 aliases['ll'] = ['ls', '-l', '--all', '--indicator-style=slash', '--human-readable', '--time-style=long-iso', '--color=auto']