Browse Source

added function 'locate' wrapping mlocate

Fabian Peter Hammerle 5 years ago
parent
commit
ffed893e4b
1 changed files with 9 additions and 1 deletions
  1. 9 1
      rc.xsh

+ 9 - 1
rc.xsh

@@ -27,6 +27,14 @@ $RIGHT_PROMPT = '{gitstatus}{env_name: {}}'
 import re as re
 
 # required by pinentry-tty when using gpg command:
-$GPG_TTY=$(tty)
+$GPG_TTY = $(tty)
+
+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]
 
 # vim: filetype=python