View raw gemtext with `cat raw` & `less raw`.

This commit is contained in:
nervuri 2021-12-25 13:28:49 +00:00
parent e79438c2e2
commit 596d2c48ad
1 changed files with 15 additions and 5 deletions

20
av98.py
View File

@ -1390,15 +1390,25 @@ Use 'ls -l' to see URLs."""
### Stuff that does something to most recently viewed item
@needs_gi
def do_cat(self, *args):
"""Run most recently visited item through "cat" command."""
subprocess.call(shlex.split("cat %s" % self._get_active_tmpfile()))
"""Run most recently visited item through "cat" command.
'cat raw' displays the raw version of the item."""
tmp_file = self.tmp_filename if args[0] == 'raw'\
else self._get_active_tmpfile()
subprocess.call(shlex.split("cat %s" % tmp_file))
@needs_gi
def do_less(self, *args):
"""Run most recently visited item through "less" command."""
"""Run most recently visited item through "less" command.
'less raw' displays the raw version of the item."""
if args[0] == 'raw':
tmp_file = self.tmp_filename
less_opt = '-R'
else:
tmp_file = self._get_active_tmpfile()
less_opt = '-r'
cmd_str = self._get_handler_cmd(self.mime)
cmd_str = cmd_str % self._get_active_tmpfile()
subprocess.call("%s | less -R" % cmd_str, shell=True)
cmd_str = cmd_str % tmp_file
subprocess.call("%s | less %s" % (cmd_str, less_opt), shell=True)
@needs_gi
def do_fold(self, *args):