diff --git a/.gitignore b/.gitignore index d061f28..8caaf99 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,9 @@ .* +!.travis.yml +!.pylintrc +!.gitignore +!.gitattributes +!.coveragerc *~ *.pyc build diff --git a/.travis.yml b/.travis.yml index 1f0b1ef..5a408df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: python +dist: precise python: - 2.7 - 3.3 diff --git a/README.rst b/README.rst index 7cb2ad4..3afec2e 100644 --- a/README.rst +++ b/README.rst @@ -100,9 +100,9 @@ See `CONTROLS `_ Settings ======== -------------- -Configuration -------------- +------------------ +Configuration File +------------------ Configuration files are stored in the ``{HOME}/.config/rtv/`` directory @@ -112,9 +112,9 @@ See `rtv.cfg `_ to configure 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**) ------------ -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 `_, `lynx `_, and `elinks `_ are all good choices). -``$PAGER`` - Extra long comments and submissions can be opened using the system's pager. ``$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. -``$RTV_URLVIEWER`` - A url viewer is a tool that can be used to extract hyperlinks from inside of blocks of text. `urlview `_ and `urlscan `_ are known to be compatible with rtv. These applications don't come pre-installed, but are available through most systems' package managers. + | A program used to compose text submissions and comments, e.g. **vim**, **emacs**, **gedit** + | *If not specified, will fallback to ``$VISUAL`` and ``$EDITOR`` in that order.* ----- -Copy ----- -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 `_ or `xclip `_ commands to be installed in the system. +``$RTV_BROWSER`` + | 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_URLVIEWER`` + | A tool used to extract hyperlinks from blocks of text, e.g. `urlview `_, `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 `_ or `xclip `_. === FAQ diff --git a/rtv/__main__.py b/rtv/__main__.py index c4ef8db..994db2c 100644 --- a/rtv/__main__.py +++ b/rtv/__main__.py @@ -106,13 +106,16 @@ def main(): _logger.info('%s, %s', sys.executable, sys.version) env = [ ('$DISPLAY', os.getenv('DISPLAY')), + ('$TERM', os.getenv('TERM')), ('$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')), ('$PAGER', os.getenv('PAGER')), - ('$RTV_EDITOR', os.getenv('RTV_EDITOR')), - ('$RTV_URLVIEWER', os.getenv('RTV_URLVIEWER'))] + ('$VISUAL', os.getenv('VISUAL')), + ('$EDITOR', os.getenv('EDITOR'))] _logger.info('Environment: %s', env) - else: # Add an empty handler so the logger doesn't complain logging.root.addHandler(logging.NullHandler()) diff --git a/rtv/terminal.py b/rtv/terminal.py index 3ed9e64..eadec67 100644 --- a/rtv/terminal.py +++ b/rtv/terminal.py @@ -569,7 +569,10 @@ class Terminal(object): fp.write(data) _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] try: with self.suspend():