Update ranger configuration
This commit is contained in:
		
							parent
							
								
									c9c8c36c5c
								
							
						
					
					
						commit
						751ef9c97b
					
				@ -1,62 +0,0 @@
 | 
			
		||||
# This is a sample commands.py.  You can add your own commands here.
 | 
			
		||||
#
 | 
			
		||||
# Please refer to commands_full.py for all the default commands and a complete
 | 
			
		||||
# documentation.  Do NOT add them all here, or you may end up with defunct
 | 
			
		||||
# commands when upgrading ranger.
 | 
			
		||||
 | 
			
		||||
# A simple command for demonstration purposes follows.
 | 
			
		||||
# -----------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
from __future__ import (absolute_import, division, print_function)
 | 
			
		||||
 | 
			
		||||
# You can import any python module as needed.
 | 
			
		||||
import os
 | 
			
		||||
 | 
			
		||||
# You always need to import ranger.api.commands here to get the Command class:
 | 
			
		||||
from ranger.api.commands import Command
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Any class that is a subclass of "Command" will be integrated into ranger as a
 | 
			
		||||
# command.  Try typing ":my_edit<ENTER>" in ranger!
 | 
			
		||||
class my_edit(Command):
 | 
			
		||||
    # The so-called doc-string of the class will be visible in the built-in
 | 
			
		||||
    # help that is accessible by typing "?c" inside ranger.
 | 
			
		||||
    """:my_edit <filename>
 | 
			
		||||
 | 
			
		||||
    A sample command for demonstration purposes that opens a file in an editor.
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    # The execute method is called when you run this command in ranger.
 | 
			
		||||
    def execute(self):
 | 
			
		||||
        # self.arg(1) is the first (space-separated) argument to the function.
 | 
			
		||||
        # This way you can write ":my_edit somefilename<ENTER>".
 | 
			
		||||
        if self.arg(1):
 | 
			
		||||
            # self.rest(1) contains self.arg(1) and everything that follows
 | 
			
		||||
            target_filename = self.rest(1)
 | 
			
		||||
        else:
 | 
			
		||||
            # self.fm is a ranger.core.filemanager.FileManager object and gives
 | 
			
		||||
            # you access to internals of ranger.
 | 
			
		||||
            # self.fm.thisfile is a ranger.container.file.File object and is a
 | 
			
		||||
            # reference to the currently selected file.
 | 
			
		||||
            target_filename = self.fm.thisfile.path
 | 
			
		||||
 | 
			
		||||
        # This is a generic function to print text in ranger.
 | 
			
		||||
        self.fm.notify("Let's edit the file " + target_filename + "!")
 | 
			
		||||
 | 
			
		||||
        # Using bad=True in fm.notify allows you to print error messages:
 | 
			
		||||
        if not os.path.exists(target_filename):
 | 
			
		||||
            self.fm.notify("The given file does not exist!", bad=True)
 | 
			
		||||
            return
 | 
			
		||||
 | 
			
		||||
        # This executes a function from ranger.core.acitons, a module with a
 | 
			
		||||
        # variety of subroutines that can help you construct commands.
 | 
			
		||||
        # Check out the source, or run "pydoc ranger.core.actions" for a list.
 | 
			
		||||
        self.fm.edit_file(target_filename)
 | 
			
		||||
 | 
			
		||||
    # The tab method is called when you press tab, and should return a list of
 | 
			
		||||
    # suggestions that the user will tab through.
 | 
			
		||||
    # tabnum is 1 for <TAB> and -1 for <S-TAB> by default
 | 
			
		||||
    def tab(self, tabnum):
 | 
			
		||||
        # This is a generic tab-completion function that iterates through the
 | 
			
		||||
        # content of the current directory.
 | 
			
		||||
        return self._tab_directory_content()
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@ -58,12 +58,13 @@ set open_all_images true
 | 
			
		||||
# Be aware of version control systems and display information.
 | 
			
		||||
set vcs_aware false
 | 
			
		||||
 | 
			
		||||
# State of the three backends git, hg, bzr. The possible states are
 | 
			
		||||
# State of the four backends git, hg, bzr, svn. The possible states are
 | 
			
		||||
# disabled, local (only show local info), enabled (show local and remote
 | 
			
		||||
# information).
 | 
			
		||||
set vcs_backend_git enabled
 | 
			
		||||
set vcs_backend_hg disabled
 | 
			
		||||
set vcs_backend_bzr disabled
 | 
			
		||||
set vcs_backend_svn disabled
 | 
			
		||||
 | 
			
		||||
# Use one of the supported image preview protocols
 | 
			
		||||
set preview_images true
 | 
			
		||||
@ -80,6 +81,10 @@ set preview_images true
 | 
			
		||||
#   (http://iterm2.com/images.html). This requires using iTerm2 compiled
 | 
			
		||||
#   with image preview support.
 | 
			
		||||
#
 | 
			
		||||
#   This feature relies on the dimensions of the terminal's font.  By default, a
 | 
			
		||||
#   width of 8 and height of 11 are used.  To use other values, set the options
 | 
			
		||||
#   iterm2_font_width and iterm2_font_height to the desired values.
 | 
			
		||||
#
 | 
			
		||||
# * urxvt:
 | 
			
		||||
#   Preview images in full color using urxvt image backgrounds. This
 | 
			
		||||
#   requires using urxvt compiled with pixbuf support.
 | 
			
		||||
@ -89,6 +94,10 @@ set preview_images true
 | 
			
		||||
#   whole terminal window.
 | 
			
		||||
set preview_images_method w3m
 | 
			
		||||
 | 
			
		||||
# Default iTerm2 font size (see: preview_images_method: iterm2)
 | 
			
		||||
set iterm2_font_width 8
 | 
			
		||||
set iterm2_font_height 11
 | 
			
		||||
 | 
			
		||||
# Use a unicode "..." character to mark cut-off filenames?
 | 
			
		||||
set unicode_ellipsis false
 | 
			
		||||
 | 
			
		||||
@ -116,7 +125,7 @@ set status_bar_on_top false
 | 
			
		||||
set draw_progress_bar_in_status_bar true
 | 
			
		||||
 | 
			
		||||
# Draw borders around columns?
 | 
			
		||||
set draw_borders true
 | 
			
		||||
set draw_borders false
 | 
			
		||||
 | 
			
		||||
# Display the directory name in tabs?
 | 
			
		||||
set dirname_in_tabs false
 | 
			
		||||
@ -199,8 +208,9 @@ set cd_bookmarks true
 | 
			
		||||
# Changes case sensitivity for the cd command tab completion
 | 
			
		||||
set cd_tab_case sensitive
 | 
			
		||||
 | 
			
		||||
# Use smart tab completion with less typing? E.g. ":cd /f/b/b<tab>" yields ":cd /foo/bar/baz".
 | 
			
		||||
set cd_tab_smart false
 | 
			
		||||
# Use fuzzy tab completion with the "cd" command. For example,
 | 
			
		||||
# ":cd /u/lo/b<tab>" expands to ":cd /usr/local/bin".
 | 
			
		||||
set cd_tab_fuzzy false
 | 
			
		||||
 | 
			
		||||
# Avoid previewing files larger than this size, in bytes.  Use a value of 0 to
 | 
			
		||||
# disable this feature.
 | 
			
		||||
@ -225,6 +235,9 @@ set clear_filters_on_dir_change false
 | 
			
		||||
# Disable displaying line numbers in main column
 | 
			
		||||
set line_numbers false
 | 
			
		||||
 | 
			
		||||
# Start line numbers from 1 instead of 0
 | 
			
		||||
set one_indexed false
 | 
			
		||||
 | 
			
		||||
# Save tabs on exit
 | 
			
		||||
set save_tabs_on_exit false
 | 
			
		||||
 | 
			
		||||
@ -270,7 +283,7 @@ alias travel     scout -aefklst
 | 
			
		||||
# ===================================================================
 | 
			
		||||
 | 
			
		||||
# Basic
 | 
			
		||||
map     Q quit!
 | 
			
		||||
map     Q quitall
 | 
			
		||||
map     q quit
 | 
			
		||||
copymap q ZZ ZQ
 | 
			
		||||
 | 
			
		||||
@ -318,7 +331,7 @@ map uV      toggle_visual_mode reverse=True
 | 
			
		||||
 | 
			
		||||
# For the nostalgics: Midnight Commander bindings
 | 
			
		||||
map <F1> help
 | 
			
		||||
map <F2> console rename%space
 | 
			
		||||
map <F2> rename_append
 | 
			
		||||
map <F3> display_file
 | 
			
		||||
map <F4> edit
 | 
			
		||||
map <F5> copy
 | 
			
		||||
 | 
			
		||||
@ -55,38 +55,40 @@ has xdg-open, flag f = xdg-open "$1"
 | 
			
		||||
# Rarely installed browsers get higher priority; It is assumed that if you
 | 
			
		||||
# install a rare browser, you probably use it.  Firefox/konqueror/w3m on the
 | 
			
		||||
# other hand are often only installed as fallback browsers.
 | 
			
		||||
ext x?html?, has surf,           X, flag f = surf -- file://"$1"
 | 
			
		||||
ext x?html?, has vimprobable,    X, flag f = vimprobable -- "$@"
 | 
			
		||||
ext x?html?, has vimprobable2,   X, flag f = vimprobable2 -- "$@"
 | 
			
		||||
ext x?html?, has qutebrowser,    X, flag f = qutebrowser -- "$@"
 | 
			
		||||
ext x?html?, has dwb,            X, flag f = dwb -- "$@"
 | 
			
		||||
ext x?html?, has jumanji,        X, flag f = jumanji -- "$@"
 | 
			
		||||
ext x?html?, has luakit,         X, flag f = luakit -- "$@"
 | 
			
		||||
ext x?html?, has uzbl,           X, flag f = uzbl -- "$@"
 | 
			
		||||
ext x?html?, has uzbl-tabbed,    X, flag f = uzbl-tabbed -- "$@"
 | 
			
		||||
ext x?html?, has uzbl-browser,   X, flag f = uzbl-browser -- "$@"
 | 
			
		||||
ext x?html?, has uzbl-core,      X, flag f = uzbl-core -- "$@"
 | 
			
		||||
ext x?html?, has midori,         X, flag f = midori -- "$@"
 | 
			
		||||
ext x?html?, has chromium,       X, flag f = chromium -- "$@"
 | 
			
		||||
ext x?html?, has opera,          X, flag f = opera -- "$@"
 | 
			
		||||
ext x?html?, has firefox,        X, flag f = firefox -- "$@"
 | 
			
		||||
ext x?html?, has seamonkey,      X, flag f = seamonkey -- "$@"
 | 
			
		||||
ext x?html?, has iceweasel,      X, flag f = iceweasel -- "$@"
 | 
			
		||||
ext x?html?, has epiphany,       X, flag f = epiphany -- "$@"
 | 
			
		||||
ext x?html?, has konqueror,      X, flag f = konqueror -- "$@"
 | 
			
		||||
ext x?html?, has elinks,          terminal = elinks "$@"
 | 
			
		||||
ext x?html?, has links2,          terminal = links2 "$@"
 | 
			
		||||
ext x?html?, has links,           terminal = links "$@"
 | 
			
		||||
ext x?html?, has lynx,            terminal = lynx -- "$@"
 | 
			
		||||
ext x?html?, has w3m,             terminal = w3m "$@"
 | 
			
		||||
ext x?html?, has surf,             X, flag f = surf -- file://"$1"
 | 
			
		||||
ext x?html?, has vimprobable,      X, flag f = vimprobable -- "$@"
 | 
			
		||||
ext x?html?, has vimprobable2,     X, flag f = vimprobable2 -- "$@"
 | 
			
		||||
ext x?html?, has qutebrowser,      X, flag f = qutebrowser -- "$@"
 | 
			
		||||
ext x?html?, has dwb,              X, flag f = dwb -- "$@"
 | 
			
		||||
ext x?html?, has jumanji,          X, flag f = jumanji -- "$@"
 | 
			
		||||
ext x?html?, has luakit,           X, flag f = luakit -- "$@"
 | 
			
		||||
ext x?html?, has uzbl,             X, flag f = uzbl -- "$@"
 | 
			
		||||
ext x?html?, has uzbl-tabbed,      X, flag f = uzbl-tabbed -- "$@"
 | 
			
		||||
ext x?html?, has uzbl-browser,     X, flag f = uzbl-browser -- "$@"
 | 
			
		||||
ext x?html?, has uzbl-core,        X, flag f = uzbl-core -- "$@"
 | 
			
		||||
ext x?html?, has midori,           X, flag f = midori -- "$@"
 | 
			
		||||
ext x?html?, has chromium-browser, X, flag f = chromium-browser -- "$@"
 | 
			
		||||
ext x?html?, has chromium,         X, flag f = chromium -- "$@"
 | 
			
		||||
ext x?html?, has google-chrome,    X, flag f = google-chrome -- "$@"
 | 
			
		||||
ext x?html?, has opera,            X, flag f = opera -- "$@"
 | 
			
		||||
ext x?html?, has firefox,          X, flag f = firefox -- "$@"
 | 
			
		||||
ext x?html?, has seamonkey,        X, flag f = seamonkey -- "$@"
 | 
			
		||||
ext x?html?, has iceweasel,        X, flag f = iceweasel -- "$@"
 | 
			
		||||
ext x?html?, has epiphany,         X, flag f = epiphany -- "$@"
 | 
			
		||||
ext x?html?, has konqueror,        X, flag f = konqueror -- "$@"
 | 
			
		||||
ext x?html?, has elinks,            terminal = elinks "$@"
 | 
			
		||||
ext x?html?, has links2,            terminal = links2 "$@"
 | 
			
		||||
ext x?html?, has links,             terminal = links "$@"
 | 
			
		||||
ext x?html?, has lynx,              terminal = lynx -- "$@"
 | 
			
		||||
ext x?html?, has w3m,               terminal = w3m "$@"
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------
 | 
			
		||||
# Misc
 | 
			
		||||
#-------------------------------------------
 | 
			
		||||
# Define the "editor" for text files as first action
 | 
			
		||||
mime ^text,  label editor = $EDITOR -- "$@"
 | 
			
		||||
mime ^text,  label editor = ${VISUAL:-$EDITOR} -- "$@"
 | 
			
		||||
mime ^text,  label pager  = "$PAGER" -- "$@"
 | 
			
		||||
!mime ^text, label editor, ext xml|json|csv|tex|py|pl|rb|js|sh|php = $EDITOR -- "$@"
 | 
			
		||||
!mime ^text, label editor, ext xml|json|csv|tex|py|pl|rb|js|sh|php = ${VISUAL:-$EDITOR} -- "$@"
 | 
			
		||||
!mime ^text, label pager,  ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$PAGER" -- "$@"
 | 
			
		||||
 | 
			
		||||
ext 1                         = man "$1"
 | 
			
		||||
@ -150,6 +152,7 @@ ext pdf, has atril,    X, flag f = atril -- "$@"
 | 
			
		||||
ext pdf, has okular,   X, flag f = okular -- "$@"
 | 
			
		||||
ext pdf, has epdfview, X, flag f = epdfview -- "$@"
 | 
			
		||||
ext pdf, has qpdfview, X, flag f = qpdfview "$@"
 | 
			
		||||
ext pdf, has open,     X, flat f = open "$@"
 | 
			
		||||
 | 
			
		||||
ext docx?, has catdoc,       terminal = catdoc -- "$@" | "$PAGER"
 | 
			
		||||
 | 
			
		||||
@ -216,7 +219,7 @@ label wallpaper, number 14, mime ^image, has feh, X = feh --bg-fill "$1"
 | 
			
		||||
 | 
			
		||||
# Define the editor for non-text files + pager as last action
 | 
			
		||||
              !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php  = ask
 | 
			
		||||
label editor, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php  = $EDITOR -- "$@"
 | 
			
		||||
label editor, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php  = ${VISUAL:-$EDITOR} -- "$@"
 | 
			
		||||
label pager,  !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php  = "$PAGER" -- "$@"
 | 
			
		||||
 | 
			
		||||
# The very last action, so that it's never triggered accidentally, is to execute a program:
 | 
			
		||||
 | 
			
		||||
@ -103,6 +103,15 @@ handle_image() {
 | 
			
		||||
 | 
			
		||||
        # Image
 | 
			
		||||
        image/*)
 | 
			
		||||
            local orientation
 | 
			
		||||
            orientation="$( identify -format '%[EXIF:Orientation]\n' -- "${FILE_PATH}" )"
 | 
			
		||||
            # If orientation data is present and the image actually
 | 
			
		||||
            # needs rotating ("1" means no rotation)...
 | 
			
		||||
            if [[ -n "$orientation" && "$orientation" != 1 ]]; then
 | 
			
		||||
                # ...auto-rotate the image according to the EXIF data.
 | 
			
		||||
                convert -- "${FILE_PATH}" -auto-orient "${IMAGE_CACHE_PATH}" && exit 6
 | 
			
		||||
            fi
 | 
			
		||||
 | 
			
		||||
            # `w3mimgdisplay` will be called for all images (unless overriden as above),
 | 
			
		||||
            # but might fail for unsupported types.
 | 
			
		||||
            exit 7;;
 | 
			
		||||
@ -114,8 +123,14 @@ handle_image() {
 | 
			
		||||
            exit 1;;
 | 
			
		||||
        
 | 
			
		||||
        # PDF
 | 
			
		||||
        application/pdf)
 | 
			
		||||
            pdftoppm -jpeg -singlefile "$path" "${cached//.jpg}" && exit 6;;
 | 
			
		||||
        # application/pdf)
 | 
			
		||||
        #     pdftoppm -f 1 -l 1 \
 | 
			
		||||
        #              -scale-to-x 1920 \
 | 
			
		||||
        #              -scale-to-y -1 \
 | 
			
		||||
        #              -singlefile \
 | 
			
		||||
        #              -jpeg -tiffcompression jpeg \
 | 
			
		||||
        #              -- "${FILE_PATH}" "${IMAGE_CACHE_PATH%.*}" \
 | 
			
		||||
        #         && exit 6 || exit 1;;
 | 
			
		||||
    esac
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -136,7 +151,7 @@ handle_mime() {
 | 
			
		||||
                local highlight_format='ansi'
 | 
			
		||||
            fi
 | 
			
		||||
            highlight --replace-tabs="${HIGHLIGHT_TABWIDTH}" --out-format="${highlight_format}" \
 | 
			
		||||
                --style="${HIGHLIGHT_STYLE}" -- "${FILE_PATH}" && exit 5
 | 
			
		||||
                --style="${HIGHLIGHT_STYLE}" --force -- "${FILE_PATH}" && exit 5
 | 
			
		||||
            # pygmentize -f "${pygmentize_format}" -O "style=${PYGMENTIZE_STYLE}" -- "${FILE_PATH}" && exit 5
 | 
			
		||||
            exit 2;;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user