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.
|
# Be aware of version control systems and display information.
|
||||||
set vcs_aware false
|
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
|
# disabled, local (only show local info), enabled (show local and remote
|
||||||
# information).
|
# information).
|
||||||
set vcs_backend_git enabled
|
set vcs_backend_git enabled
|
||||||
set vcs_backend_hg disabled
|
set vcs_backend_hg disabled
|
||||||
set vcs_backend_bzr disabled
|
set vcs_backend_bzr disabled
|
||||||
|
set vcs_backend_svn disabled
|
||||||
|
|
||||||
# Use one of the supported image preview protocols
|
# Use one of the supported image preview protocols
|
||||||
set preview_images true
|
set preview_images true
|
||||||
|
@ -80,6 +81,10 @@ set preview_images true
|
||||||
# (http://iterm2.com/images.html). This requires using iTerm2 compiled
|
# (http://iterm2.com/images.html). This requires using iTerm2 compiled
|
||||||
# with image preview support.
|
# 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:
|
# * urxvt:
|
||||||
# Preview images in full color using urxvt image backgrounds. This
|
# Preview images in full color using urxvt image backgrounds. This
|
||||||
# requires using urxvt compiled with pixbuf support.
|
# requires using urxvt compiled with pixbuf support.
|
||||||
|
@ -89,6 +94,10 @@ set preview_images true
|
||||||
# whole terminal window.
|
# whole terminal window.
|
||||||
set preview_images_method w3m
|
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?
|
# Use a unicode "..." character to mark cut-off filenames?
|
||||||
set unicode_ellipsis false
|
set unicode_ellipsis false
|
||||||
|
|
||||||
|
@ -116,7 +125,7 @@ set status_bar_on_top false
|
||||||
set draw_progress_bar_in_status_bar true
|
set draw_progress_bar_in_status_bar true
|
||||||
|
|
||||||
# Draw borders around columns?
|
# Draw borders around columns?
|
||||||
set draw_borders true
|
set draw_borders false
|
||||||
|
|
||||||
# Display the directory name in tabs?
|
# Display the directory name in tabs?
|
||||||
set dirname_in_tabs false
|
set dirname_in_tabs false
|
||||||
|
@ -199,8 +208,9 @@ set cd_bookmarks true
|
||||||
# Changes case sensitivity for the cd command tab completion
|
# Changes case sensitivity for the cd command tab completion
|
||||||
set cd_tab_case sensitive
|
set cd_tab_case sensitive
|
||||||
|
|
||||||
# Use smart tab completion with less typing? E.g. ":cd /f/b/b<tab>" yields ":cd /foo/bar/baz".
|
# Use fuzzy tab completion with the "cd" command. For example,
|
||||||
set cd_tab_smart false
|
# ":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
|
# Avoid previewing files larger than this size, in bytes. Use a value of 0 to
|
||||||
# disable this feature.
|
# disable this feature.
|
||||||
|
@ -225,6 +235,9 @@ set clear_filters_on_dir_change false
|
||||||
# Disable displaying line numbers in main column
|
# Disable displaying line numbers in main column
|
||||||
set line_numbers false
|
set line_numbers false
|
||||||
|
|
||||||
|
# Start line numbers from 1 instead of 0
|
||||||
|
set one_indexed false
|
||||||
|
|
||||||
# Save tabs on exit
|
# Save tabs on exit
|
||||||
set save_tabs_on_exit false
|
set save_tabs_on_exit false
|
||||||
|
|
||||||
|
@ -270,7 +283,7 @@ alias travel scout -aefklst
|
||||||
# ===================================================================
|
# ===================================================================
|
||||||
|
|
||||||
# Basic
|
# Basic
|
||||||
map Q quit!
|
map Q quitall
|
||||||
map q quit
|
map q quit
|
||||||
copymap q ZZ ZQ
|
copymap q ZZ ZQ
|
||||||
|
|
||||||
|
@ -318,7 +331,7 @@ map uV toggle_visual_mode reverse=True
|
||||||
|
|
||||||
# For the nostalgics: Midnight Commander bindings
|
# For the nostalgics: Midnight Commander bindings
|
||||||
map <F1> help
|
map <F1> help
|
||||||
map <F2> console rename%space
|
map <F2> rename_append
|
||||||
map <F3> display_file
|
map <F3> display_file
|
||||||
map <F4> edit
|
map <F4> edit
|
||||||
map <F5> copy
|
map <F5> copy
|
||||||
|
|
|
@ -67,7 +67,9 @@ 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-browser, X, flag f = uzbl-browser -- "$@"
|
||||||
ext x?html?, has uzbl-core, X, flag f = uzbl-core -- "$@"
|
ext x?html?, has uzbl-core, X, flag f = uzbl-core -- "$@"
|
||||||
ext x?html?, has midori, X, flag f = midori -- "$@"
|
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 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 opera, X, flag f = opera -- "$@"
|
||||||
ext x?html?, has firefox, X, flag f = firefox -- "$@"
|
ext x?html?, has firefox, X, flag f = firefox -- "$@"
|
||||||
ext x?html?, has seamonkey, X, flag f = seamonkey -- "$@"
|
ext x?html?, has seamonkey, X, flag f = seamonkey -- "$@"
|
||||||
|
@ -84,9 +86,9 @@ ext x?html?, has w3m, terminal = w3m "$@"
|
||||||
# Misc
|
# Misc
|
||||||
#-------------------------------------------
|
#-------------------------------------------
|
||||||
# Define the "editor" for text files as first action
|
# 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 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" -- "$@"
|
!mime ^text, label pager, ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$PAGER" -- "$@"
|
||||||
|
|
||||||
ext 1 = man "$1"
|
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 okular, X, flag f = okular -- "$@"
|
||||||
ext pdf, has epdfview, X, flag f = epdfview -- "$@"
|
ext pdf, has epdfview, X, flag f = epdfview -- "$@"
|
||||||
ext pdf, has qpdfview, X, flag f = qpdfview "$@"
|
ext pdf, has qpdfview, X, flag f = qpdfview "$@"
|
||||||
|
ext pdf, has open, X, flat f = open "$@"
|
||||||
|
|
||||||
ext docx?, has catdoc, terminal = catdoc -- "$@" | "$PAGER"
|
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
|
# 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
|
!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" -- "$@"
|
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:
|
# The very last action, so that it's never triggered accidentally, is to execute a program:
|
||||||
|
|
|
@ -103,6 +103,15 @@ handle_image() {
|
||||||
|
|
||||||
# Image
|
# 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),
|
# `w3mimgdisplay` will be called for all images (unless overriden as above),
|
||||||
# but might fail for unsupported types.
|
# but might fail for unsupported types.
|
||||||
exit 7;;
|
exit 7;;
|
||||||
|
@ -114,8 +123,14 @@ handle_image() {
|
||||||
exit 1;;
|
exit 1;;
|
||||||
|
|
||||||
# PDF
|
# PDF
|
||||||
application/pdf)
|
# application/pdf)
|
||||||
pdftoppm -jpeg -singlefile "$path" "${cached//.jpg}" && exit 6;;
|
# 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
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +151,7 @@ handle_mime() {
|
||||||
local highlight_format='ansi'
|
local highlight_format='ansi'
|
||||||
fi
|
fi
|
||||||
highlight --replace-tabs="${HIGHLIGHT_TABWIDTH}" --out-format="${highlight_format}" \
|
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
|
# pygmentize -f "${pygmentize_format}" -O "style=${PYGMENTIZE_STYLE}" -- "${FILE_PATH}" && exit 5
|
||||||
exit 2;;
|
exit 2;;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user