Browse Source

def dpkg_listfiles & dpkg_welse; alias dpkg-welse

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

+ 12 - 1
rc.xsh

@@ -44,6 +44,12 @@ if shutil.which('gpgconf'):
 # wrapper for termite required when launching termite from ranger:
 $TERMCMD = os.path.join(os.path.dirname(__file__), 'ranger-termite-termcmd')
 
+def dpkg_listfiles(pkg_name):
+    assert isinstance(pkg_name, str)
+    paths = $(dpkg --listfiles @(pkg_name)).split('\n')[:-1]
+    assert len(paths) > 0, 'pkg {!r} not installed'.format(pkg_name)
+    return paths
+
 def dpkg_search(path_search_pattern):
     assert isinstance(path_search_pattern, str)
     return re.findall(
@@ -52,6 +58,10 @@ def dpkg_search(path_search_pattern):
         flags=re.MULTILINE,
     )
 
+def dpkg_welse(cmd):
+    pkg_name, cmd_path = dpkg_which(cmd)
+    return dpkg_listfiles(pkg_name)
+
 def dpkg_which(cmd):
     cmd_path = shutil.which(cmd)
     assert cmd_path, 'cmd {!r} not found'.format(cmd)
@@ -73,7 +83,8 @@ def timestamp_iso():
     # the system local timezone for the target timezone
     return dt.datetime.now().astimezone().strftime('%Y%m%dT%H%M%S%z')
 
-aliases['dpkg-which'] = lambda args: str(dpkg_which(args[0]))
+aliases['dpkg-welse'] = lambda args: '\n'.join(dpkg_welse(args[0]))
+aliases['dpkg-which'] = lambda args: '\t'.join(dpkg_which(args[0]))
 aliases['g'] = ['git']
 aliases['ll'] = ['ls', '-l', '--all', '--indicator-style=slash',
                  '--human-readable', '--time-style=long-iso', '--color=auto']