From 385e185a0dfe92ffdb5214e86be159183c35cfd5 Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Sat, 23 Feb 2013 18:49:44 +0100 Subject: [PATCH] Ranger: improved config for 1.6. --- .config/ranger/apps.py | 147 ---------------------------- .config/ranger/rc.conf | 96 +++++++++++++++---- .config/ranger/rifle.conf | 195 ++++++++++++++++++++++++++++++++++++++ .config/ranger/scope.sh | 109 ++++++++++----------- .shell.d/main_rc | 4 + 5 files changed, 330 insertions(+), 221 deletions(-) delete mode 100644 .config/ranger/apps.py create mode 100644 .config/ranger/rifle.conf diff --git a/.config/ranger/apps.py b/.config/ranger/apps.py deleted file mode 100644 index b02debb8..00000000 --- a/.config/ranger/apps.py +++ /dev/null @@ -1,147 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2009, 2010, 2011 Roman Zimbelmann -# This configuration file is licensed under the same terms as ranger. -# =================================================================== - -# In order to add application definitions "on top of" the default ones -# in your ~/.config/ranger/apps.py, you should subclass the class defined -# here like this: - -import ranger -from ranger.api.apps import * -from ranger.ext.get_executables import get_executables - -from ranger.defaults.apps import CustomApplications as DefaultApps -class CustomApplications(DefaultApps): - def app_default(self, c): - """How to determine the default application?""" - f = c.file - - if f.basename.lower() == 'makefile' and c.mode == 1: - made = self.either(c, 'make') - if made: return made - - if f.extension is not None: - - if f.extension in ('pdf', ): - c.flags += 'd' - return self.either(c, 'llpp', 'zathura', 'mupdf', 'apvlv', - 'evince', 'okular', 'epdfview') - - # CUSTOM - if f.extension == 'djvu': - c.flags += 'd' - return self.either(c, 'zathura', 'evince') - - # CUSTOM - if f.extension == 'chm': - c.flags += 'd' - return self.either(c, 'xchm') - - if f.extension == 'ps': - c.flags += 'd' - return self.either(c, 'zathura', 'evince') - - # CUSTOM - if f.extension == 'svg': - c.flags += 'd' - return self.either(c, 'inkscape') - - # CUSTOM - if f.extension == 'm2ts': - c.flags += 'd' - return self.either(c, 'mplayer2', 'mplayer', 'smplayer', 'vlc') - - if f.extension in ('xml', 'csv'): - return self.either(c, 'editor') - - if f.extension == 'mid': - return self.either(c, 'wildmidi') - - if f.extension in ('html', 'htm', 'xhtml') or f.extension == 'swf': - c.flags += 'd' - handler = self.either(c, - 'dwb', 'luakit', 'uzbl', 'vimprobable', 'vimprobable2', 'jumanji', - 'firefox', 'seamonkey', 'iceweasel', 'opera', - 'surf', 'midori', 'epiphany', 'konqueror') - # Only return if some program was found: - if handler: - return handler - if f.extension in ('html', 'htm', 'xhtml'): - # These browsers can't handle flash, so they're not called above. - c.flags += 'D' - return self.either(c, 'elinks', 'links', 'links2', 'lynx', 'w3m') - - if f.extension == 'nes': - return self.either(c, 'fceux') - - if f.extension in ('swc', 'smc', 'sfc'): - return self.either(c, 'zsnes') - - if f.extension == 'doc': - c.flags += 'd' - return self.either(c, 'abiword', 'libreoffice', - 'soffice', 'ooffice') - if f.extension in ('odt', 'ods', 'odp', 'odf', 'odg', 'sxc', - 'stc', 'xls', 'xlsx', 'xlt', 'xlw', 'gnm', 'gnumeric'): - c.flags += 'd' - return self.either(c, 'gnumeric', 'kspread', - 'libreoffice', 'soffice', 'ooffice') - - if f.mimetype is not None: - if INTERPRETED_LANGUAGES.match(f.mimetype): - return self.either(c, 'edit_or_run') - - if f.container: - return self.either(c, 'aunpack', 'file_roller') - - # CUSTOM - if f.video or f.audio: - if f.video: - c.flags += 'd' - return self.either(c, 'mplayer2', 'mplayer', 'smplayer', 'vlc', - 'totem') - - # CUSTOM - if f.image: - if c.mode in (11, 12, 13, 14): - return self.either(c, 'set_bg_with_feh') - else: - return self.either(c, 'sxiv', 'feh', 'gpicview' , 'eog', 'mirage') - - if f.document or f.filetype.startswith('text') or f.size == 0: - return self.either(c, 'editor') - - # You can put this at the top of the function and mimeopen will - # always be used for every file. - return self.either(c, 'mimeopen') - - - # ----------------------------------------- application definitions - # Note: Trivial application definitions are at the bottom - - # CUSTOM - @depends_on('feh', 'X') - def app_feh(self, c): - c.flags += 'd' - if c.mode is 0 and len(c.files) is 1 and self.fm.env.cwd: - # view all files in the cwd - images = [f.basename for f in self.fm.env.cwd.files if f.image] - return 'feh', '-Z', '-.', '--start-at', c.file.basename, images - return 'feh', '-Z', '-.', c - -# Forked applications -CustomApplications.generic( - 'dwb', 'luakit', 'uzbl', 'vimprobable', 'vimprobable2', 'jumanji', - 'firefox', 'seamonkey', 'iceweasel', 'opera', - 'surf', 'midori', 'epiphany', 'konqueror', - 'evince', 'zathura', 'apvlv', 'okular', 'epdfview', 'mupdf', 'llpp', - 'eog', 'mirage', 'gimp', - 'libreoffice', 'soffice', 'ooffice', 'gnumeric', 'kspread', 'abiword', - 'gmplayer', 'smplayer', 'vlc', - flags='d', deps=['X']) - -INTERPRETED_LANGUAGES = re.compile(r''' - ^(text|application)/x-( - haskell|perl|python|ruby|sh - )$''', re.VERBOSE) diff --git a/.config/ranger/rc.conf b/.config/ranger/rc.conf index dedf9add..255ec6fc 100644 --- a/.config/ranger/rc.conf +++ b/.config/ranger/rc.conf @@ -3,20 +3,86 @@ # To change them, it is recommended to create the file # ~/.config/ranger/rc.conf and add your custom commands there. # -# If you copy this whole file there, add this line to your options.py -# so it is not loaded twice: +# If you copy this whole file there, you may want to set the environment +# variable RANGER_LOAD_DEFAULT_RC to FALSE to avoid loading it twice. # -# load_default_rc = False -# -# The purpose of this file is mainly to define keybindings. For -# changing settings or running more complex python code, use the -# configuation file "options.py" or define commands in "commands.py". +# The purpose of this file is mainly to define keybindings and settings. +# For running more complex python code, please create a plugin in "plugins/" or +# a command in "commands.py". # # Each line is a command that will be run before the user interface # is initialized. As a result, you can not use commands which rely # on the UI such as :delete or :mark. # =================================================================== +# =================================================================== +# == Options +# =================================================================== + +# Which files should be hidden? (regular expression) +set hidden_filter ^\. + +# Preview images in full color with the external command "w3mimgpreview"? +# This requires the console web browser "w3m" and a supported terminal. +# It has been successfully tested with "xterm" and "urxvt" without tmux. +set preview_images true + +# Display the directory name in tabs? +set dirname_in_tabs true + +# Enable the mouse support? +set mouse_enabled false + +# How many directory-changes or console-commands should be kept in history? +set max_history_size 20 +set max_console_history_size 50 + +# Try to keep so much space between the top/bottom border when scrolling: +set scroll_offset 8 + +# Flush the input after each key hit? (Noticable when ranger lags) +set flushinput true + +# Padding on the right when there's no preview? +# This allows you to click into the space to run the file. +set padding_right true + +# Save bookmarks (used with mX and `X) instantly? +# This helps to synchronize bookmarks between multiple ranger +# instances but leads to *slight* performance loss. +# When false, bookmarks are saved when ranger is exited. +set autosave_bookmarks false + +# One of: size, basename, mtime, type +set sort natural + +# Additional sorting options +set sort_reverse false +set sort_case_insensitive true +set sort_directories_first true + +# Enable this if key combinations with the Alt Key don't work for you. +# (Especially on xterm) +set xterm_alt_key false + +# =================================================================== +# == Local Options +# =================================================================== +# You can set local options that only affect a single directory. + +# Examples: +# setlocal path=~/downloads sort mtime + +# =================================================================== +# == Command Aliases in the Console +# =================================================================== + +alias e edit +alias q quit +alias q! quitall +alias qall quitall +alias setl setlocal + # =================================================================== # == Define keys for the browser # =================================================================== @@ -28,15 +94,6 @@ map ! console shell -w map bulkrename map console shell -w file "%f" map console touch -map console mkdir -map console delete seriously? -map exit - -# =================================================================== -# == Personal options -# =================================================================== - -set dirname_in_tabs true # =================================================================== # == Personal shorcuts @@ -48,8 +105,7 @@ set dirname_in_tabs true ## Move to trash (with Trash-CLI) map DD shell trash-put -- %s -## Extraction. Ranger uses '1l', but does not work when extension is not -## right. Using atools instead. +## Extraction using atools. map ex shell aunpack -e %s map eeg shell aunpack -e %s -X "$HOME/games/" @@ -69,12 +125,10 @@ map es shell -w submarine %f ## Audio map ea shell cmus-remote -P %s -## Mount iSO +## Mount ISO map em shell fuseiso -p %f ~/iso map eu shell fusermount -qu ~/iso # Quick moves map K move up=5 map J move down=5 -#map tab_move 1 -#map tab_move -1 diff --git a/.config/ranger/rifle.conf b/.config/ranger/rifle.conf new file mode 100644 index 00000000..9eef8da2 --- /dev/null +++ b/.config/ranger/rifle.conf @@ -0,0 +1,195 @@ +# vim: ft=cfg +# +# This is the configuration file of "rifle", ranger's file executor/opener. +# Each line consists of conditions and a command. For each line the conditions +# are checked and if they are met, the respective command is run. +# +# Syntax: +# , , ... = command +# +# The command can contain these environment variables: +# $1-$9 | The n-th selected file +# $@ | All selected files +# +# If you use the special command "ask", rifle will ask you what program to run. +# +# Prefixing a condition with "!" will negate its result. +# These conditions are currently supported: +# match | The regexp matches $1 +# ext | The regexp matches the extension of $1 +# mime | The regexp matches the mime type of $1 +# name | The regexp matches the basename of $1 +# path | The regexp matches the absolute path of $1 +# has | The program is installed (i.e. located in $PATH) +# file | $1 is a file +# directory | $1 is a directory +# number | change the number of this command to n +# terminal | stdin, stderr and stdout are connected to a terminal +# X | $DISPLAY is not empty (i.e. Xorg runs) +# +# There are also pseudo-conditions which have a "side effect": +# flag | Change how the program is run. See below. +# label