Merge pull request #405 from michael-lazar/VISUAL

Add $VISUAL
This commit is contained in:
Michael Lazar
2017-08-03 01:04:02 -04:00
committed by GitHub
5 changed files with 42 additions and 26 deletions

5
.gitignore vendored
View File

@@ -1,4 +1,9 @@
.* .*
!.travis.yml
!.pylintrc
!.gitignore
!.gitattributes
!.coveragerc
*~ *~
*.pyc *.pyc
build build

View File

@@ -1,4 +1,5 @@
language: python language: python
dist: precise
python: python:
- 2.7 - 2.7
- 3.3 - 3.3

View File

@@ -100,9 +100,9 @@ See `CONTROLS <https://github.com/michael-lazar/rtv/blob/master/CONTROLS.rst>`_
Settings Settings
======== ========
------------- ------------------
Configuration Configuration File
------------- ------------------
Configuration files are stored in the ``{HOME}/.config/rtv/`` directory Configuration files are stored in the ``{HOME}/.config/rtv/`` directory
@@ -112,9 +112,9 @@ See `rtv.cfg <https://github.com/michael-lazar/rtv/blob/master/rtv/templates/rtv
$ rtv --copy-config $ rtv --copy-config
----- -------------------
Media Viewing Media Links
----- -------------------
You can use `mailcap <https://en.wikipedia.org/wiki/Media_type#Mailcap>`_ to configure You can use `mailcap <https://en.wikipedia.org/wiki/Media_type#Mailcap>`_ to configure
how RTV will open different types of links how RTV will open different types of links
@@ -134,26 +134,30 @@ This template contains examples for common MIME types that work with popular red
Once you've setup your mailcap file, enable it by launching rtv with the ``rtv --enable-media`` flag (or set it in your **rtv.cfg**) Once you've setup your mailcap file, enable it by launching rtv with the ``rtv --enable-media`` flag (or set it in your **rtv.cfg**)
----------- ---------------------
Environment Environment Variables
----------- ---------------------
RTV will respect the following environment variables when accessing external programs The default programs that RTV interacts with can be configured through environment variables
``$BROWSER``
Submission links will be opened inside of your web browser. On most systems, the default web browser will pop up in a new window. If you prefer the complete terminal experience, try using a console-based web browser (`w3m <http://w3m.sourceforge.net/>`_, `lynx <http://lynx.isc.org/>`_, and `elinks <http://elinks.or.cz/>`_ are all good choices).
``$PAGER``
Extra long comments and submissions can be opened using the system's pager.
``$RTV_EDITOR`` ``$RTV_EDITOR``
Composing posts and replying to comments is done using your preferred text editor. If not specified, the default system ``$EDITOR`` (or *nano*) will be used. | A program used to compose text submissions and comments, e.g. **vim**, **emacs**, **gedit**
``$RTV_URLVIEWER`` | *If not specified, will fallback to ``$VISUAL`` and ``$EDITOR`` in that order.*
A url viewer is a tool that can be used to extract hyperlinks from inside of blocks of text. `urlview <https://github.com/sigpipe/urlview>`_ and `urlscan <https://github.com/firecat53/urlscan>`_ are known to be compatible with rtv. These applications don't come pre-installed, but are available through most systems' package managers.
---- ``$RTV_BROWSER``
Copy | A program used to open links to external websites, e.g. **firefox**, **google-chrome**, **w3m**, **lynx**, **elinks**
---- | *If not specified, will fallback to ``$BROWSER``, or try to intelligently choose a browser supported by your system.*
RTV supports copying submission links to the OS clipboard. For macOS it is supported out of the box,
in Linux systems RTV will need `xsel <http://www.vergenet.net/~conrad/software/xsel/>`_ or `xclip <https://sourceforge.net/projects/xclip/>`_ commands to be installed in the system. ``$RTV_URLVIEWER``
| A tool used to extract hyperlinks from blocks of text, e.g. `urlview <https://github.com/sigpipe/urlview>`_, `urlscan <https://github.com/firecat53/urlscan>`_
| *If not specified, will fallback to urlview if it is installed.*
------------------------
Copying to the Clipboard
------------------------
RTV supports copying submission links to the OS clipboard.
On macOS this is supported out of the box.
On Linux systems you will need to install either `xsel <http://www.vergenet.net/~conrad/software/xsel/>`_ or `xclip <https://sourceforge.net/projects/xclip/>`_.
=== ===
FAQ FAQ

View File

@@ -106,13 +106,16 @@ def main():
_logger.info('%s, %s', sys.executable, sys.version) _logger.info('%s, %s', sys.executable, sys.version)
env = [ env = [
('$DISPLAY', os.getenv('DISPLAY')), ('$DISPLAY', os.getenv('DISPLAY')),
('$TERM', os.getenv('TERM')),
('$XDG_CONFIG_HOME', os.getenv('XDG_CONFIG_HOME')), ('$XDG_CONFIG_HOME', os.getenv('XDG_CONFIG_HOME')),
('$RTV_EDITOR', os.getenv('RTV_EDITOR')),
('$RTV_URLVIEWER', os.getenv('RTV_URLVIEWER')),
('$RTV_BROWSER', os.getenv('RTV_BROWSER')),
('$BROWSER', os.getenv('BROWSER')), ('$BROWSER', os.getenv('BROWSER')),
('$PAGER', os.getenv('PAGER')), ('$PAGER', os.getenv('PAGER')),
('$RTV_EDITOR', os.getenv('RTV_EDITOR')), ('$VISUAL', os.getenv('VISUAL')),
('$RTV_URLVIEWER', os.getenv('RTV_URLVIEWER'))] ('$EDITOR', os.getenv('EDITOR'))]
_logger.info('Environment: %s', env) _logger.info('Environment: %s', env)
else: else:
# Add an empty handler so the logger doesn't complain # Add an empty handler so the logger doesn't complain
logging.root.addHandler(logging.NullHandler()) logging.root.addHandler(logging.NullHandler())

View File

@@ -569,7 +569,10 @@ class Terminal(object):
fp.write(data) fp.write(data)
_logger.info('File created: %s', filepath) _logger.info('File created: %s', filepath)
editor = os.getenv('RTV_EDITOR') or os.getenv('EDITOR') or 'nano' editor = (os.getenv('RTV_EDITOR') or
os.getenv('VISUAL') or
os.getenv('EDITOR') or
'nano')
command = shlex.split(editor) + [filepath] command = shlex.split(editor) + [filepath]
try: try:
with self.suspend(): with self.suspend():