literate-dotfiles/docs/ranger.html
2020-05-26 08:40:15 +02:00

1014 lines
32 KiB
HTML

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2020-05-26 mar. 08:39 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Ranger Configuration</title>
<meta name="generator" content="Org mode" />
<meta name="author" content="Dehaeze Thomas" />
<link rel="stylesheet" type="text/css" href="./css/htmlize.css"/>
<link rel="stylesheet" type="text/css" href="./css/readtheorg.css"/>
<script type="text/javascript" src="./js/jquery.min.js"></script>
<script type="text/javascript" src="./js/bootstrap.min.js"></script>
<script type="text/javascript" src="./js/jquery.stickytableheaders.min.js"></script>
<script type="text/javascript" src="./js/readtheorg.js"></script>
</head>
<body>
<div id="org-div-home-and-up">
<a accesskey="h" href="./index.html"> UP </a>
|
<a accesskey="H" href="./index.html"> HOME </a>
</div><div id="content">
<h1 class="title">Ranger Configuration</h1>
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#orgb698ce8">Config</a>
<ul>
<li><a href="#orgb7bec10">Options</a></li>
<li><a href="#org951cbf1">Command Aliases in the Console</a></li>
<li><a href="#org100bad8">Some Custom Keybindings</a></li>
<li><a href="#org02a57c0">Scripts</a>
<ul>
<li><a href="#org8e29501">Extract Script</a></li>
<li><a href="#org1847974">Compress Script</a></li>
</ul>
</li>
<li><a href="#orgd08d096">Define keys for the browser</a>
<ul>
<li><a href="#orgff20aaa">Basic</a></li>
<li><a href="#org5904486">Open Shell in current directory</a></li>
<li><a href="#org0c81d35">Open With</a></li>
<li><a href="#orgada203d">Filter</a></li>
<li><a href="#orgb764b86">Tagging / Marking</a></li>
<li><a href="#orge2aa1a3">VIM-like</a></li>
<li><a href="#orgffebb62">Jumping around</a></li>
<li><a href="#orgd53d40d">Go to special folders</a></li>
<li><a href="#orge844226">Get size of folders</a></li>
<li><a href="#org09eae76">Yank path of directory/file</a></li>
<li><a href="#orgf96f786">Drag and Drop</a></li>
<li><a href="#org06db4c5">Rename files</a></li>
<li><a href="#orgb374e3c">Paste files</a></li>
<li><a href="#org2b7dea6">Delete and move files</a></li>
<li><a href="#orgb3c7fc8">Copy files</a></li>
<li><a href="#org71e2066">Searching</a></li>
<li><a href="#org553185e">Tabs</a></li>
<li><a href="#orgbaecc7e">Settings</a></li>
<li><a href="#orgc0b9c58">Bookmarks</a></li>
<li><a href="#org75b9bf9">FZF</a></li>
</ul>
</li>
<li><a href="#orgdcee9fb">Define keys for the console</a>
<ul>
<li><a href="#org04d9a89">Basic</a></li>
<li><a href="#orgb9d20bd">Move around</a></li>
<li><a href="#org357eb3a">Line Editing</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#org2e76cf4">Rifle</a></li>
<li><a href="#orga4ef9e0">Ranger Commands</a>
<ul>
<li><a href="#orgb5beb5c">Import</a></li>
<li><a href="#org72e240f">fzf_select</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div id="outline-container-orgb698ce8" class="outline-2">
<h2 id="orgb698ce8">Config</h2>
<div class="outline-text-2" id="text-orgb698ce8">
</div>
<div id="outline-container-orgb7bec10" class="outline-3">
<h3 id="orgb7bec10">Options</h3>
<div class="outline-text-3" id="text-orgb7bec10">
<div class="org-src-container">
<pre class="src src-conf"># Which viewmode should be used? Possible values are:
# miller: Use miller columns which show multiple levels of the hierarchy
# multipane: Midnight-commander like multipane view showing all tabs next
# to each other
set viewmode miller
# How many columns are there, and what are their relative widths?
set column_ratios 1,1
# Which files should be hidden? (regular expression)
set hidden_filter ^\.|\.(?:pyc|vrb|pyo|lof|bak|swp|aux|log|nav|out|snm|toc|bcf|run\.xml|synctex\.gz|blg|bbl)$|^lost\+found$|^__(py)?cache__$
# Show hidden files? You can toggle this by typing 'zh'
set show_hidden false
# Ask for a confirmation when running the "delete" command?
# Valid values are "always", "never", "multiple" (default)
# With "multiple", ranger will ask only if you delete multiple files at once.
set confirm_on_delete multiple
# Which script is used to generate file previews?
# ranger ships with scope.sh, a script that calls external programs (see
# README.md for dependencies) to preview images, archives, etc.
set preview_script /home/thomas/.config/ranger/scope.sh
# Use the external preview script or display simple plain text or image previews?
set use_preview_script true
# Automatically count files in the directory, even before entering them?
set automatically_count_files true
# Open all images in this directory when running certain image viewers
set open_all_images true
# Be aware of version control systems and display information.
set vcs_aware false
# Use one of the supported image preview protocols
set preview_images true
# Set the preview image method
set preview_images_method ueberzug
set colorscheme default
# Preview files on the rightmost column?
# And collapse (shrink) the last column if there is nothing to preview?
set preview_files true
set preview_directories true
set collapse_preview true
# Draw the status bar on top of the browser window (default: bottom)
set status_bar_on_top false
# Draw a progress bar in the status bar which displays the average state of all
# currently running tasks which support progress bars?
set draw_progress_bar_in_status_bar true
# Draw borders around columns?
set draw_borders true
# Display the directory name in tabs?
set dirname_in_tabs false
# Enable the mouse support?
set mouse_enabled true
# Display the file size in the main column or status bar?
set display_size_in_main_column true
set display_size_in_status_bar false
# Display files tags in all columns or only in main column?
set display_tags_in_all_columns false
# Set a title for the window?
set update_title false
# Set the title to "ranger" in the tmux program?
set update_tmux_title true
# Shorten the title if it gets long? The number defines how many
# directories are displayed at once, 0 turns off this feature.
set shorten_title 3
# Abbreviate $HOME with ~ in the titlebar (first line) of ranger?
set tilde_in_titlebar true
# 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? (Noticeable 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
set autosave_bookmarks false
set autoupdate_cumulative_size false
# Turning this on makes sense for screen readers:
set show_cursor false
# One of: size, natural, basename, atime, ctime, mtime, type, random
set sort natural
# Additional sorting options
set sort_reverse false
set sort_case_insensitive true
set sort_directories_first true
set sort_unicode false
# Enable this if key combinations with the Alt Key don't work for you.
# (Especially on xterm)
set xterm_alt_key false
# Whether to include bookmarks in cd command
set cd_bookmarks false
# Avoid previewing files larger than this size, in bytes. Use a value of 0 to
# disable this feature.
set preview_max_size 5000000
# Add the highlighted file to the path in the titlebar
set show_selection_in_titlebar true
# The delay that ranger idly waits for user input, in milliseconds, with a
# resolution of 100ms. Lower delay reduces lag between directory updates but
# increases CPU load.
set idle_delay 2000
# When the metadata manager module looks for metadata, should it only look for
# a ".metadata.json" file in the current directory, or do a deep search and
# check all directories above the current one as well?
set metadata_deep_search false
# Clear all existing filters when leaving a directory
set clear_filters_on_dir_change false
# Disable displaying line numbers in main column
set line_numbers false
</pre>
</div>
</div>
</div>
<div id="outline-container-org951cbf1" class="outline-3">
<h3 id="org951cbf1">Command Aliases in the Console</h3>
<div class="outline-text-3" id="text-org951cbf1">
<div class="org-src-container">
<pre class="src src-conf">alias q quit
alias filter scout -prt
alias find scout -aeit
alias mark scout -mr
alias unmark scout -Mr
alias search scout -rs
alias search_inc scout -rts
alias travel scout -aefiklst
</pre>
</div>
</div>
</div>
<div id="outline-container-org100bad8" class="outline-3">
<h3 id="org100bad8">Some Custom Keybindings</h3>
<div class="outline-text-3" id="text-org100bad8">
<p>
Extract
</p>
<div class="org-src-container">
<pre class="src src-conf">map ,x shell ~/.config/ranger/scripts/extract.sh %f
</pre>
</div>
<p>
Compress
</p>
<div class="org-src-container">
<pre class="src src-conf">map ,z shell ~/.config/ranger/scripts/compress.sh %f
</pre>
</div>
<p>
Get Bibtex from PDF
</p>
<div class="org-src-container">
<pre class="src src-conf">map ,b shell pdf2bib %f
</pre>
</div>
<p>
Delete first page of pdf
</p>
<div class="org-src-container">
<pre class="src src-conf">map ,d shell pdf-delete-first-page %f
</pre>
</div>
<p>
Convert PDF to PNG
</p>
<div class="org-src-container">
<pre class="src src-conf">map ,cp shell pdf2png %f
</pre>
</div>
<p>
Magit Status
</p>
<div class="org-src-container">
<pre class="src src-conf">map ,gs shell emacsclient -create-frame --alternate-editor="" -n --eval '(magit-status)'
</pre>
</div>
<p>
Upload with 0x0 (previously Tansfer.sh)
</p>
<div class="org-src-container">
<pre class="src src-conf">map ,t shell upload %f
</pre>
</div>
<p>
Open current folder with PCManFM
</p>
<div class="org-src-container">
<pre class="src src-conf">map ,o shell nohup pcmanfm %d &amp;
</pre>
</div>
<p>
Open with Emacs
</p>
<div class="org-src-container">
<pre class="src src-conf">map ,e shell emacsclient -create-frame --alternate-editor="" -n %f
</pre>
</div>
<p>
Print on Rnice
</p>
<div class="org-src-container">
<pre class="src src-conf">map ,p shell print-rnice %f &amp;
</pre>
</div>
</div>
</div>
<div id="outline-container-org02a57c0" class="outline-3">
<h3 id="org02a57c0">Scripts</h3>
<div class="outline-text-3" id="text-org02a57c0">
</div>
<div id="outline-container-org8e29501" class="outline-4">
<h4 id="org8e29501">Extract Script</h4>
<div class="outline-text-4" id="text-org8e29501">
<div class="org-src-container">
<pre class="src src-bash">if [ $TMUX ]; then
tmux split -v -l 2 atool -x $1 &amp;&amp; tmux select-pane -U
else
atool -x $1
fi
</pre>
</div>
</div>
</div>
<div id="outline-container-org1847974" class="outline-4">
<h4 id="org1847974">Compress Script</h4>
<div class="outline-text-4" id="text-org1847974">
<div class="org-src-container">
<pre class="src src-bash">if [ $TMUX ]; then
tmux split -v -l 2 apack ${1%.*}.zip $1 &amp;&amp; tmux select-pane -U
else
apack ${1%.*}.zip $1
fi
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-orgd08d096" class="outline-3">
<h3 id="orgd08d096">Define keys for the browser</h3>
<div class="outline-text-3" id="text-orgd08d096">
</div>
<div id="outline-container-orgff20aaa" class="outline-4">
<h4 id="orgff20aaa">Basic</h4>
<div class="outline-text-4" id="text-orgff20aaa">
<div class="org-src-container">
<pre class="src src-conf">map Q quit!
map q eval fm.execute_console("shell tmux detach") if 'TMUX' in os.environ.keys() else fm.execute_console("quit")
</pre>
</div>
<div class="org-src-container">
<pre class="src src-conf">map &lt;C-c&gt; abort
map &lt;esc&gt; change_mode normal
map ~ set viewmode!
</pre>
</div>
<div class="org-src-container">
<pre class="src src-conf">map ? help
</pre>
</div>
<div class="org-src-container">
<pre class="src src-conf">map : console
map ; console
</pre>
</div>
<div class="org-src-container">
<pre class="src src-conf">map ! console shell%space
</pre>
</div>
<div class="org-src-container">
<pre class="src src-conf">map @ console -p6 shell %%s
</pre>
</div>
</div>
</div>
<div id="outline-container-org5904486" class="outline-4">
<h4 id="org5904486">Open Shell in current directory</h4>
<div class="outline-text-4" id="text-org5904486">
<div class="org-src-container">
<pre class="src src-conf">map s shell $SHELL
map S shell nohup $TERMINAL &amp;
</pre>
</div>
</div>
</div>
<div id="outline-container-org0c81d35" class="outline-4">
<h4 id="org0c81d35">Open With</h4>
<div class="outline-text-4" id="text-org0c81d35">
<div class="org-src-container">
<pre class="src src-conf">map O chain draw_possible_programs; console open_with%space
</pre>
</div>
</div>
</div>
<div id="outline-container-orgada203d" class="outline-4">
<h4 id="orgada203d">Filter</h4>
<div class="outline-text-4" id="text-orgada203d">
<div class="org-src-container">
<pre class="src src-conf">map f console filter%space
# Reset filter
map F filter
</pre>
</div>
</div>
</div>
<div id="outline-container-orgb764b86" class="outline-4">
<h4 id="orgb764b86">Tagging / Marking</h4>
<div class="outline-text-4" id="text-orgb764b86">
<div class="org-src-container">
<pre class="src src-conf">map &lt;Space&gt; mark_files toggle=True
map v mark_files all=True toggle=True
</pre>
</div>
</div>
</div>
<div id="outline-container-orge2aa1a3" class="outline-4">
<h4 id="orge2aa1a3">VIM-like</h4>
<div class="outline-text-4" id="text-orge2aa1a3">
<div class="org-src-container">
<pre class="src src-conf">copymap &lt;UP&gt; k
copymap &lt;DOWN&gt; j
copymap &lt;LEFT&gt; h
copymap &lt;RIGHT&gt; l
copymap &lt;HOME&gt; gg
copymap &lt;END&gt; G
</pre>
</div>
</div>
</div>
<div id="outline-container-orgffebb62" class="outline-4">
<h4 id="orgffebb62">Jumping around</h4>
<div class="outline-text-4" id="text-orgffebb62">
<div class="org-src-container">
<pre class="src src-conf">map H history_go -1
map L history_go 1
</pre>
</div>
<div class="org-src-container">
<pre class="src src-conf">map ] move_parent 1
map [ move_parent -1
</pre>
</div>
<div class="org-src-container">
<pre class="src src-conf">map } traverse
</pre>
</div>
<div class="org-src-container">
<pre class="src src-conf">map cd console cd%space
</pre>
</div>
</div>
</div>
<div id="outline-container-orgd53d40d" class="outline-4">
<h4 id="orgd53d40d">Go to special folders</h4>
<div class="outline-text-4" id="text-orgd53d40d">
<div class="org-src-container">
<pre class="src src-conf">map gh cd ~/
map gb cd ~/Cloud/brain
map gm cd ~/Cloud/thesis
map gp cd ~/Pictures
map gP cd ~/Cloud/personal
map gT cd ~/.local/share/Trash/files
map gd cd ~/Downloads
map gc cd ~/Cloud
map gV cd ~/.config/literate-dotfiles
</pre>
</div>
</div>
</div>
<div id="outline-container-orge844226" class="outline-4">
<h4 id="orge844226">Get size of folders</h4>
<div class="outline-text-4" id="text-orge844226">
<div class="org-src-container">
<pre class="src src-conf"># Get size of all folders
map du shell -p du --max-depth=1 -h --apparent-size
# Get size of all folders and sort them
map dU shell -p du --max-depth=1 -h --apparent-size | sort -rh
</pre>
</div>
</div>
</div>
<div id="outline-container-org09eae76" class="outline-4">
<h4 id="org09eae76">Yank path of directory/file</h4>
<div class="outline-text-4" id="text-org09eae76">
<div class="org-src-container">
<pre class="src src-conf"># Yank path of current directory/file
map yp shell -f echo -n %d/%f | xsel -i; xsel -o | xsel -i -b
# Yank path of directory
map yd shell -f echo -n %d | xsel -i; xsel -o | xsel -i -b
# Yank filename
map yn shell -f echo -n %f | xsel -i; xsel -o | xsel -i -b
</pre>
</div>
</div>
</div>
<div id="outline-container-orgf96f786" class="outline-4">
<h4 id="orgf96f786">Drag and Drop</h4>
<div class="outline-text-4" id="text-orgf96f786">
<div class="org-src-container">
<pre class="src src-conf">map D shell dragon-drag-and-drop -a -x %p
</pre>
</div>
</div>
</div>
<div id="outline-container-org06db4c5" class="outline-4">
<h4 id="org06db4c5">Rename files</h4>
<div class="outline-text-4" id="text-org06db4c5">
<div class="org-src-container">
<pre class="src src-conf">map a rename_append
map C eval fm.execute_console("bulkrename") if fm.thisdir.marked_items else fm.open_console("rename ")
map A eval fm.open_console('rename ' + fm.thisfile.relative_path.replace("%", "%%"))
map I eval fm.open_console('rename ' + fm.thisfile.relative_path.replace("%", "%%"), position=7)
</pre>
</div>
</div>
</div>
<div id="outline-container-orgb374e3c" class="outline-4">
<h4 id="orgb374e3c">Paste files</h4>
<div class="outline-text-4" id="text-orgb374e3c">
<div class="org-src-container">
<pre class="src src-conf">map pp paste
map po paste overwrite=True
map pP paste append=True
map pO paste overwrite=True append=True
map pl paste_symlink relative=False
map pL paste_symlink relative=True
map phl paste_hardlink
map pht paste_hardlinked_subtree
</pre>
</div>
</div>
</div>
<div id="outline-container-org2b7dea6" class="outline-4">
<h4 id="org2b7dea6">Delete and move files</h4>
<div class="outline-text-4" id="text-org2b7dea6">
<div class="org-src-container">
<pre class="src src-conf">map dD shell -s trash-put %s
map dd cut
map du uncut
</pre>
</div>
</div>
</div>
<div id="outline-container-orgb3c7fc8" class="outline-4">
<h4 id="orgb3c7fc8">Copy files</h4>
<div class="outline-text-4" id="text-orgb3c7fc8">
<div class="org-src-container">
<pre class="src src-conf">map yy copy
map yu uncut
</pre>
</div>
</div>
</div>
<div id="outline-container-org71e2066" class="outline-4">
<h4 id="org71e2066">Searching</h4>
<div class="outline-text-4" id="text-org71e2066">
<div class="org-src-container">
<pre class="src src-conf">map / console search%space
map n search_next
map N search_next forward=False
</pre>
</div>
</div>
</div>
<div id="outline-container-org553185e" class="outline-4">
<h4 id="org553185e">Tabs</h4>
<div class="outline-text-4" id="text-org553185e">
<div class="org-src-container">
<pre class="src src-conf">map &lt;C-n&gt; tab_new ~
map &lt;C-w&gt; tab_close
map &lt;TAB&gt; tab_move 1
map &lt;S-TAB&gt; tab_move -1
map gn tab_new ~
map gt tab_move 1
</pre>
</div>
</div>
</div>
<div id="outline-container-orgbaecc7e" class="outline-4">
<h4 id="orgbaecc7e">Settings</h4>
<div class="outline-text-4" id="text-orgbaecc7e">
<div class="org-src-container">
<pre class="src src-conf">map zh set show_hidden!
map zi set preview_images!
map zv set use_preview_script!
</pre>
</div>
</div>
</div>
<div id="outline-container-orgc0b9c58" class="outline-4">
<h4 id="orgc0b9c58">Bookmarks</h4>
<div class="outline-text-4" id="text-orgc0b9c58">
<div class="org-src-container">
<pre class="src src-conf">map `&lt;any&gt; enter_bookmark %any
map '&lt;any&gt; enter_bookmark %any
map m&lt;any&gt; set_bookmark %any
map um&lt;any&gt; unset_bookmark %any
map m&lt;bg&gt; draw_bookmarks
copymap m&lt;bg&gt; um&lt;bg&gt; `&lt;bg&gt; '&lt;bg&gt;
</pre>
</div>
</div>
</div>
<div id="outline-container-org75b9bf9" class="outline-4">
<h4 id="org75b9bf9">FZF</h4>
<div class="outline-text-4" id="text-org75b9bf9">
<div class="org-src-container">
<pre class="src src-conf">map &lt;C-f&gt; fzf_select
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-orgdcee9fb" class="outline-3">
<h3 id="orgdcee9fb">Define keys for the console</h3>
<div class="outline-text-3" id="text-orgdcee9fb">
</div>
<div id="outline-container-org04d9a89" class="outline-4">
<h4 id="org04d9a89">Basic</h4>
<div class="outline-text-4" id="text-org04d9a89">
<div class="org-src-container">
<pre class="src src-conf">cmap &lt;tab&gt; eval fm.ui.console.tab()
cmap &lt;s-tab&gt; eval fm.ui.console.tab(-1)
cmap &lt;ESC&gt; eval fm.ui.console.close()
cmap &lt;CR&gt; eval fm.ui.console.execute()
cmap &lt;C-l&gt; redraw_window
copycmap &lt;ESC&gt; &lt;C-c&gt;
copycmap &lt;CR&gt; &lt;C-j&gt;
</pre>
</div>
</div>
</div>
<div id="outline-container-orgb9d20bd" class="outline-4">
<h4 id="orgb9d20bd">Move around</h4>
<div class="outline-text-4" id="text-orgb9d20bd">
<div class="org-src-container">
<pre class="src src-conf">cmap &lt;up&gt; eval fm.ui.console.history_move(-1)
cmap &lt;down&gt; eval fm.ui.console.history_move(1)
cmap &lt;left&gt; eval fm.ui.console.move(left=1)
cmap &lt;right&gt; eval fm.ui.console.move(right=1)
cmap &lt;home&gt; eval fm.ui.console.move(right=0, absolute=True)
cmap &lt;end&gt; eval fm.ui.console.move(right=-1, absolute=True)
</pre>
</div>
</div>
</div>
<div id="outline-container-org357eb3a" class="outline-4">
<h4 id="org357eb3a">Line Editing</h4>
<div class="outline-text-4" id="text-org357eb3a">
<div class="org-src-container">
<pre class="src src-conf">cmap &lt;backspace&gt; eval fm.ui.console.delete(-1)
cmap &lt;delete&gt; eval fm.ui.console.delete(0)
cmap &lt;C-w&gt; eval fm.ui.console.delete_word()
cmap &lt;C-y&gt; eval fm.ui.console.paste()
copycmap &lt;home&gt; &lt;C-a&gt;
copycmap &lt;end&gt; &lt;C-e&gt;
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="outline-container-org2e76cf4" class="outline-2">
<h2 id="org2e76cf4">Rifle</h2>
<div class="outline-text-2" id="text-org2e76cf4">
<div class="org-src-container">
<pre class="src src-conf"># 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:
# &lt;condition1&gt; , &lt;condition2&gt; , ... = 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 &lt;regexp&gt; | The regexp matches $1
# ext &lt;regexp&gt; | The regexp matches the extension of $1
# mime &lt;regexp&gt; | The regexp matches the mime type of $1
# name &lt;regexp&gt; | The regexp matches the basename of $1
# path &lt;regexp&gt; | The regexp matches the absolute path of $1
# has &lt;program&gt; | The program is installed (i.e. located in $PATH)
# env &lt;variable&gt; | The environment variable "variable" is non-empty
# file | $1 is a file
# directory | $1 is a directory
# number &lt;n&gt; | 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 &lt;flags&gt; | Change how the program is run. See below.
# label &lt;label&gt; | Assign a label or name to the command so it can
# | be started with :open_with &lt;label&gt; in ranger
# | or `rifle -p &lt;label&gt;` in the standalone executable.
# else | Always true.
#
# Flags are single characters which slightly transform the command:
# f | Fork the program, make it run in the background.
# | New command = setsid $command &gt;&amp; /dev/null &amp;
# r | Execute the command with root permissions
# | New command = sudo $command
# t | Run the program in a new terminal. If $TERMCMD is not defined,
# | rifle will attempt to extract it from $TERM.
# | New command = $TERMCMD -e $command
# Note: The "New command" serves only as an illustration, the exact
# implementation may differ.
# Note: When using rifle in ranger, there is an additional flag "c" for
# only running the current file even if you have marked multiple files.
#-------------------------------------------
# Websites
#-------------------------------------------
# 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 qutebrowser, X, flag f = qutebrowser -- "$@"
ext x?html?, has firefox, X, flag f = firefox -- "$@"
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 "$@"
#Spreadsheets for scim
ext sc|csv|sxc|xlsx?|xlt|xlw|gnm|gnumeric, = sc-im -- "$@"
#-------------------------------------------
# Misc
#-------------------------------------------
ext org = emacsclient -c "$1"
# Define the "editor" for text files as first action
mime ^text, label editor = $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 pager, ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$PAGER" -- "$@"
ext 1 = man "$1"
ext s[wmf]c, has zsnes, X = zsnes "$1"
ext s[wmf]c, has snes9x-gtk,X = snes9x-gtk "$1"
ext nes, has fceux, X = fceux "$1"
ext exe = wine "$1"
name ^[mM]akefile$ = make
#--------------------------------------------
# Code
#-------------------------------------------
ext py = python -- "$1"
ext pl = perl -- "$1"
ext rb = ruby -- "$1"
ext js = node -- "$1"
ext sh = sh -- "$1"
ext php = php -- "$1"
#--------------------------------------------
# Video/Audio with a GUI
#-------------------------------------------
mime ^video, has mpv, X, flag f = mpv -- "$@"
mime ^video, has mpv, X, flag f = mpv --fs -- "$@"
mime ^video, has mpv, X, flag f = mpv --loop -- "$@"
#--------------------------------------------
# Audio without X
#-------------------------------------------
mime ^audio|ogg$, terminal, has mpv = mpv --no-audio-display -- "$@"
mime ^audio|ogg$ = tag "$@"
mime ^audio|ogg$, terminal, has mpv = mpv -- "$@"
#--------------------------------------------
# Video without X:
#-------------------------------------------
mime ^video, terminal, !X, has mpv = mpv -- "$@"
mime ^video, terminal, !X, has mplayer2 = mplayer2 -- "$@"
mime ^video, terminal, !X, has mplayer = mplayer -- "$@"
#-------------------------------------------
# Documents
#-------------------------------------------
ext pdf, has zathura, X, flag f = zathura -- "$@"
ext pdf, has llpp, X, flag f = llpp "$@"
ext pdf, has mupdf, X, flag f = mupdf "$@"
ext pdf, has mupdf, X, flag f = mupdf -I "$@"
ext pdf, has mupdf-x11,X, flag f = mupdf-x11 "$@"
ext pdf, has apvlv, X, flag f = apvlv -- "$@"
ext pdf, has xpdf, X, flag f = xpdf -- "$@"
ext pdf, has evince, X, flag f = evince -- "$@"
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 epub, has zathura, X, flag f = zathura -- "$@"
ext epub, has mupdf, X, flag f = mupdf "$@"
ext docx?, has wps, X, flag f = wps "$@"
ext docx?, has catdoc, terminal = catdoc -- "$@" | "$PAGER"
ext pptx?|od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has wpp, X, flag f = wpp "$@"
ext sxc|xlsx?|xlt|xlw|gnm|gnumeric, has gnumeric, X, flag f = gnumeric -- "$@"
ext sxc|xlsx?|xlt|xlw|gnm|gnumeric, has kspread, X, flag f = kspread -- "$@"
ext pptx?|od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has libreoffice, X, flag f = libreoffice "$@"
ext pptx?|od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has soffice, X, flag f = soffice "$@"
ext pptx?|od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has ooffice, X, flag f = ooffice "$@"
ext djvu, has zathura,X, flag f = zathura -- "$@"
ext djvu, has evince, X, flag f = evince -- "$@"
ext djvu, has atril, X, flag f = atril -- "$@"
#-------------------------------------------
# Image Viewing:
#-------------------------------------------
mime ^image/svg, has inkscape, X, flag f = inkscape -- "$@"
mime ^image/svg, has display, X, flag f = display -- "$@"
mime ^image/gif, has mpv, X, flag f = mpv --loop -- "$@"
mime ^image/gif, has viewnior, X, flag f = viewnior -- "$@"
mime ^image/gif, has qutebrowser, X, flag f = qutebrowser -- "$@"
ext xcf, X, flag f = gimp -- "$@"
mime ^image, has sxiv, X, flag f = sxiv -- "$@"
mime ^image, has feh, X, flag f = feh --scale-down --auto-zoom --image-bg black -- "$@"
mime ^image, has feh, X, flag f = feh --scale-down --auto-zoom -- "$@"
mime ^image, has mirage, X, flag f = mirage -- "$@"
mime ^image, has ristretto, X, flag f = ristretto "$@"
mime ^image, has eog, X, flag f = eog -- "$@"
mime ^image, has eom, X, flag f = eom -- "$@"
mime ^image, has gimp, X, flag f = gimp -- "$@"
mime ^image, has pinta, X, flag f = pinta -- "$@"
mime ^image, has mypaint, X, flag f = mypaint -- "$@"
mime ^image, has kolourpaint, X, flag f = kolourpaint -- "$@"
#-------------------------------------------
# Archives
#-------------------------------------------
# This requires atool
ext jar = java -jar "$@"
ext 7z|ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has als = als -- "$@" | "$PAGER"
ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has als = als -- "$@" | "$PAGER"
ext 7z|ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has aunpack = aunpack -- "$@"
ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has aunpack = aunpack -- "$@"
# Fallback:
ext tar|gz, has tar = tar vvtf "$@" | "$PAGER"
ext tar|gz, has tar = tar vvxf "$@"
#-------------------------------------------
# Misc
#-------------------------------------------
label wallpaper, number 11, mime ^image, has feh, X = feh --bg-scale "$1"
label wallpaper, number 12, mime ^image, has feh, X = feh --bg-tile "$1"
label wallpaper, number 13, mime ^image, has feh, X = feh --bg-center "$1"
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 pager, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$PAGER" -- "$@"
ext blend, has blender, X, flag f = blender -- "$@"
has dragon-drag-and-drop, X, flag f = dragon-drag-and-drop -a -x "$@"
</pre>
</div>
</div>
</div>
<div id="outline-container-orga4ef9e0" class="outline-2">
<h2 id="orga4ef9e0">Ranger Commands</h2>
<div class="outline-text-2" id="text-orga4ef9e0">
</div>
<div id="outline-container-orgb5beb5c" class="outline-3">
<h3 id="orgb5beb5c">Import</h3>
<div class="outline-text-3" id="text-orgb5beb5c">
<div class="org-src-container">
<pre class="src src-python">from ranger.api.commands import *
import os
</pre>
</div>
</div>
</div>
<div id="outline-container-org72e240f" class="outline-3">
<h3 id="org72e240f">fzf_select</h3>
<div class="outline-text-3" id="text-org72e240f">
<div class="org-src-container">
<pre class="src src-python">class fzf_select(Command):
"""
:fzf_select
Find a file using fzf.
With a prefix argument select only directories.
See: https://github.com/junegunn/fzf
"""
def execute(self):
import subprocess
import os.path
if self.quantifier:
# match only directories
command="find -L . \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) -prune \
-o -type d -print 2&gt; /dev/null | sed 1d | cut -b3- | fzf +m"
else:
# match files and directories
command="find -L . \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) -prune \
-o -print 2&gt; /dev/null | sed 1d | cut -b3- | fzf +m"
fzf = self.fm.execute_command(command, universal_newlines=True, stdout=subprocess.PIPE)
stdout, stderr = fzf.communicate()
if fzf.returncode == 0:
fzf_file = os.path.abspath(stdout.rstrip('\n'))
if os.path.isdir(fzf_file):
self.fm.cd(fzf_file)
else:
self.fm.select_file(fzf_file)
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="postamble" class="status">
<p class="author">Author: Dehaeze Thomas</p>
<p class="date">Created: 2020-05-26 mar. 08:39</p>
</div>
</body>
</html>