code:
local utils = require 'mp.utils'
local settings = {

    --filetypes,{'mp4','mkv'} for specific or {''} for all filetypes
    filetypes = {'mkv', 'avi', 'mp4', 'ogv', 'webm', 'rmvb', 'flv', 'wmv', 'mpeg', 'mpg', 'm4v', '3gp',
'mp3', 'wav', 'ogv', 'flac', 'm4a', 'wma', 'jpg', 'gif', 'png', 'jpeg', 'webp'},

    --linux(true)/windows(false)/auto(nil)
    linux_over_windows = nil,

    --at end of directory jump to start and vice versa
    allow_looping = true,

}
--check os
if settings.linux_over_windows==nil then
  local o = {}
  if mp.get_property_native('options/vo-mmcss-profile', o) ~= o then
    settings.linux_over_windows = false
  else
    settings.linux_over_windows = true
  end
end

function nexthandler()
    movetofile(true)
end

function prevhandler()
    movetofile(false)
end

function escapepath(dir, escapechar)
  return string.gsub(dir, escapechar, '\\'..escapechar)
end

function movetofile(forward)
    if mp.get_property('filename'):match("^%a%a+:%/%/") then return end
    local pwd = mp.get_property('working-directory')
    local relpath = mp.get_property('path')
    if not pwd or not relpath then return end

    local path = utils.join_path(pwd, relpath)
    local file = mp.get_property("filename")
    local dir = utils.split_path(path)

    local search = ' '
    for w in pairs(settings.filetypes) do
        if settings.linux_over_windows then
            search = search.."*."..settings.filetypes[w]..' '
        else
            search = search..'"'..escapepath(dir, '"').."*."..settings.filetypes[w]..'" '
        end
    end

    local popen, err = nil, nil
    if settings.linux_over_windows then
        popen, err = io.popen('cd "'..escapepath(dir, '"')..'";ls -1p'..search..'2>/dev/null')
    else
        popen, err = io.popen('dir /b'..(search:gsub("/", "\\")))
    end
    if popen then
        local found = false
        local memory = nil
        local lastfile = true
        local firstfile = nil
        for dirx in popen:lines() do
            if found == true then
                mp.commandv("loadfile", dir..dirx, "replace")
                lastfile=false
                break
            end
            if dirx == file then
                found = true
                if not forward then
                    lastfile=false
                    if settings.allow_looping and firstfile==nil then
                        found=false
                    else
                        if firstfile==nil then break end
                        mp.commandv("loadfile", dir..memory, "replace")
                        break
                    end
                end
            end
            memory = dirx
            if firstfile==nil then firstfile=dirx end
        end
        if lastfile and firstfile and settings.allow_looping then
            mp.commandv("loadfile", dir..firstfile, "replace")
        end
        if not found and memory then
            mp.commandv("loadfile", dir..memory, "replace")
        end
        popen:close()
    else
        mp.msg.error("could not scan for files: "..(err or ""))
    end
end

mp.add_key_binding('shift+RIGHT', 'nextfile', nexthandler)
mp.add_key_binding('shift+LEFT', 'previousfile', prevhandler)


code:
ncmpcpp_directory = "~/.ncmpcpp"
lyrics_directory = "~/.lyrics"
execute_on_song_change = "~/.bin/mnuc"

mpd_host = "localhost"
mpd_port = "6600"
mpd_music_dir = "/media/data/Metal"
mpd_connection_timeout = "5"
#mpd_crossfade_time = "5"

audio_output {
    type "fifo"
    name "mpd_fifo"
    path "/tmp/mpd.fifo"
    format "44100:16:2"
}

visualizer_in_stereo = "no"
visualizer_fifo_path = "/tmp/mpd.fifo"
visualizer_output_name = "mpd_fifo"
visualizer_sync_interval = 10
visualizer_type = "spectrum" (spectrum/wave)
visualizer_look = "||"

playlist_disable_highlight_delay = "5"
message_delay_time = "3"

song_list_format = "(6f)[withe]{l} (25)[green]{a} (5)[]{n} (40)[]{t|f} (30)[yellow]{b}"
song_status_format = "{(%l) }{%a - }{%t}|{%f}"
song_library_format = "{%n - }{%t}|{%f}"
media_library_primary_tag = "artist"
tags_separator = " | "
now_playing_prefix = "$b$u"
now_playing_suffix = "$/b$/u"
locked_screen_width_part = 50
ask_for_locked_screen_width_part = no

browser_sort_mode = "format"

alternative_header_first_line_format = "{$b$2%t$9$/b}"
alternative_header_second_line_format ="$8{%a} - {%b}"

playlist_shorten_total_times = "no"
playlist_display_mode = "columns" (classic/columns)
browser_display_mode = "columns" (classic/columns)
search_engine_display_mode = "columns" (classic/columns)

incremental_seeking = "yes"
seek_time = "1"
autocenter_mode = "yes"
centered_cursor = "no"

progressbar_look = "━━─"
progressbar_boldness = "yes"
default_place_to_search_in = "database" (database/playlist)

user_interface = "alternative" (classic/alternative)

default_find_mode = "wrapped" (wrapped/normal)
default_tag_editor_pattern = "%n - %t"

header_visibility = "no"
statusbar_visibility = "yes"
titles_visibility = no
header_text_scrolling = "yes"
cyclic_scrolling = "no"
lines_scrolled = "5"
follow_now_playing_lyrics = "no"
store_lyrics_in_song_dir = "no"

jump_to_now_playing_song_at_start = "yes"

clock_display_seconds = "yes"
display_volume_level = "yes"
display_bitrate = "yes"
display_remaining_time = "no"
regular_expressions = "extended" (basic/extended)
ignore_leading_the = "yes"
mouse_support = "yes"
mouse_list_scroll_whole_page = "yes"
empty_tag_marker = " -- ‼ -- "
enable_window_title = yes
search_engine_default_search_mode = "2"

external_editor = "emacsclient -t"
use_console_editor = "yes"

colors_enabled = "yes"
empty_tag_color = "blue"
header_window_color = "white"
volume_color = "white"
state_line_color = "blue"
state_flags_color = "blue"
main_window_color = "white"
color1 = "blue"
color2 = "white"
main_window_highlight_color = "white"
progressbar_color = "cyan"
statusbar_color = "white"
alternative_ui_separator_color = "black"
active_column_color = "cyan"
active_window_border = "blue"
window_border_color = "blue"

license: unknown


code:
" Pentadactyl color file
"
" Mantainer: Edison Ibañez <edison@opmbx.org>
" Version: 0.1
" Name: Darkness

hi clear
" Section: Javascript - General{{{1
hi -a Boolean   color: #AE81FF;
hi -a Function  color: #A6E22E;
hi -a Null      color: #AE81FF; font-weight: bold;
hi -a Number    color: #AE81FF;
hi -a Object    color: #66D9EF;
hi -a String    color: #E6DB74;
hi -a Comment   color: #75715E;
hi -a Key       font-weight:bold;
hi -a Indicator color: #66D9EF;
hi -a Keyword   color: #F92672;
hi -a URL       color: #BCBCBC;
hi -a URLExtra  color: #BCBCBC;
hi -a Title     color: #F92672;
hi -a Tag       color: #66D9EF;
hi -a Disabled  color: #960050;
hi -a FontCode  font-family: "Hack", "Sans"; font-size:8pt;
" Normal{{{2
hi -a Normal background: #181818 !important;
hi -a Normal color: #F8F8F2 !important;
hi -a Normal font-size: 8pt;
" ErrorMsg{{{2
hi -a ErrorMsg background: #181818 !important;
hi -a ErrorMsg color: #F92672 !important;
" InfoMsg{{{2
hi -a InfoMsg background: #181818 !important;
hi -a InfoMsg color: #E6DB74 !important;
" LineNr{{{2
hi -a LineNr background: #181818 !important;
hi -a InfoMsg color: #960050 !important;
" NonText{{{2
hi -a NonText background: #181818 !important;
hi -a NonText color:#BCBCBC !important;
" Question{{{2
hi -a Question background: #181818 !important;
hi -a Question color:#66D9EF !important;
" StatusQuestion{{{2
hi -a StatusQuestion color:#F92672 !important;
" WarningMsg{{{2
hi -a WarningMsg background:#FD971F !important;
hi -a WarningMsg color:#F8F8F2 !important;
" StatusWarningMsg{{{2
hi -a StatusWarningMsg: color:#FD971F !important;
" Bell {{{2
hi -a border:0 none; background: #181818
" Completition{{{2
hi -a CompTitle color: #F8F8F2; background: #181818; font-weight: bold;
hi -a CompTitleSep background: -moz-linear-gradient(60dg, #455354, #F92672);
hi -a CompItem:nth-child(2n+1) background:#181818;
hi -a CompItem[selected] background:#121212;
hi -a CompItem background:#181818;
hi -a Comp border-top: 0px;
" Section: Status Line{{{1
" StatusModeMsg{{{2
hi -a StatusModeMsg background: #181818 !important;
hi -a StatusModeMsg color: #E6DB74;
" ModeMsg{{{2
hi -a ModeMsg background: #181818 !important;
hi -a ModeMsg color: #E6DB74;
" MoreMsg{{{2
hi -a MoreMsg background: #181818 !important;
hi -a MoreMsg color: #E6DB74;
" Normal{{{2
hi -a StatusLineNormal background: #181818 !important;
hi -a StatusLineNormal color: #F8F8F2 !important;
" Secure{{{2
hi -a StatusLineSecure background: #181818 !important;
hi -a StatusLineSecure color: #F8F8F2 !important;
" Broken{{{2
hi -a StatusLineBroken background: #181818 !important;
hi -a StatusLineBroken color: #F92672 !important;
" Extended{{{2
hi -a StatusLineExtended background: #181818 !important;
hi -a StatusLineExtended color: #A6E22E !important;
" Section: Hint{{{1
hi -a Hint font-family: "Hack", "Sans"; font-size: 9px; font-weight: bold;
hi -a Hint border: 0 none;
hi -a Hint padding:2px;
hi -a Hint::after content: attr(number);
hi -a Hint color: #A6E22E !important;
hi -a Hint background-color: rgba(35, 37, 38, .8) !important;
hi -a HintActive background-color: #66D9EF !important; color: #F8F8F2 !important;
hi -a HintElem background-color: inherit !important;
hi -a HintElem -moz-box-shadow: 0px 0px 2px 2px rgba(102, 217, 239, .5);
hi -a HintImage opacity: .5;
" -*- vim -*- vim:set ft=vim et sw=2 sts=2:


code:
set complete=lsf
set editor='/usr/bin/emacsclient -c <file>'

highlight -a Hint text-transform: uppercase

" M-x enters command mode
map -b <A-x> :

" Emacs navigation in command line and insert mode
cmap <C-n> <Tab>
cmap <C-p> <S-Tab>
cmap <C-f> <Right>
cmap <C-b> <Left>
cmap <C-j> <CR>
map -b <C-j> <CR>
imap -b <C-j> <CR>
imap -b <C-n> <Down>
imap -b <C-p> <Up>
imap -b <C-f> <Right>
imap -b <C-b> <Left>

" Use C-f and C-b for tab browsing
map -b <C-f> <C-n>
map -b <C-b> <C-p>

" Or use them to go to the absolute left/right of the document
map -b <C-a> 0
map -b <C-e> $

" Use C-p and C-n for up/down
map -b <C-p> 2k
map -b <C-n> 2j

" Use C-v and M-v for jump scrolling
map -b <C-v> <C-d>
map -b <A-v> <C-u>

" Goto the top of the document with M-<
map -b <A-<> gg

" Goto the end of the document with M->
map -b <A->> G

" Map C-x C-s to save
map -b <C-x><C-s> <C-s>

" Use C-s and C-r for searching (n/N for next/prev as in less)
map -b <C-s> /
map -b <C-r> ?

" Copy the current URL to the clipboard with M-w
map -b <A-w> y
"
" Copy selected text to the clipboard with C-w
map -b <C-w> Y

" Paste the current clipboard selection to a new buffer with C-y
map -b <C-y> P

" Use current URL as a start for a new location with C-x C-v
map -b <C-x><C-v> O

" C-g as cancel (C-q is stop)
cmap <C-g> <Esc>
imap <C-g> <Esc>
map -b <C-g> <Esc>

" Avoid Find dialog when canceling a started command, C-x C-g
map -b <C-x><C-g> <Esc>
"
" Avoid quit on C-q, and it's more suitable for Stop here
map -b <C-q> :stop<CR>

" Kill the buffer with C-x k
map -b <C-x>k d

" Undo close tab with C-_ (also with C-Shift-t, as C-t is new tab)
map -b <C-/> u

" Exit and save the session with C-x C-c
javascript <<END_OF_SCRIPT
	userContext.confirm_and_quit = function confirm_and_quit() {
		quit = confirm("Quit Pentadactyl?");
		if (quit)
			commands.get("quitall").action();
	};
END_OF_SCRIPT

map -b <C-x><C-c> :js confirm_and_quit()<CR>

" Buffer lists with C-x b and C-x C-b
map -b <C-x>b b
map -b <C-x><C-b> B

" Open a link in a new tab with C-x t
" Open a link in the current tab with C-x l
map -b <C-x>t :t<SPACE>
map -b <C-x>l :o<SPACE>

" Switch hints to letter "j", for right hand usage
map -b j f
map -b J F
"
" Extended hint mode with M-j
"  ; - focus link, a - save, y - copy link, O - :open query, T - for :tabopen ...
map -b <A-j> ;

" We can now also use F for Shift+b/f as back/forward
map -b F L
map -b B H

" Back with Backspace as well
map <BS> H

" Use C-h i to start help
map -b <C-x>? i :help<CR>

" Close all other windows ("delete all other frames") with C-x 5 1
map -builtin <C-x>51 :winonly<CR>

" Switch to previously selected tab ("switch cursor to other window") with C-x o
map -builtin <C-x>o <C-6>

" Duplicate tab ("split window") with C-x 2
map -builtin <C-x>2 T<CR>

" Duplicate window ("split frame") with C-x 5 2
map -builtin <C-x>52 W<CR>

" Open a URL in the current buffer with C-x C-f
map -builtin <C-x><C-f> :open<SPACE>

" Open a URL based on current location in the current buffer with C-x C-v
" ("replace the contents of this buffer with new URL")
map -builtin <C-x><C-v> O

" Open a URL in a new window with C-x 5 f
map -builtin <C-x>5f :winopen<SPACE>

" Open a URL in a new background tab with C-x t
map -builtin <C-x>t t<SPACE>

" Open a URL based on current location in new background tab with C-x T
map -builtin <C-x>T T

" Open a URL in a new focussed tab with C-x C-t
"                                  with C-x 4 f
map -builtin <C-x><C-t> t!<SPACE>
map -builtin <C-x>4f t!<SPACE>

" QuickHint mode bindings
" Follow link using l to open in current buffer
" Follow link using L to open in new background tab
" Follow link using M-l to open in new focussed tab
" [Alt: Follow link using C-x l to open in new focussed tab]
" Use neighbouring ; to open extended hint mode (as per standard vimperator)
map -builtin l f
map -builtin L F
map -builtin <A-l> ;t
" map -builtin <C-x>l ;t

" Use C-h r to start pentadactyl help
" Use C-h i to go to pentadactyl index
" Use C-h t to go to pentadactyl quickstart tutorial
" Use C-h I to go to emacslik pentadactyl quickreference card
map -builtin <C-h>r :help<CR>
map -builtin <C-h>i o<SPACE>dactyl://help/index<CR>
map -builtin <C-h>t o<SPACE>dactyl://help/tutorial<CR>
map -builtin <C-h>I o<SPACE>http://www.jnanam.net/pentadactylemacs/pentadactylemacs.html<CR>

" Record a key sequence into a macro with C-x (
map -b <C-x>( q

" Play a macro with C-x e
map -b <C-x>e @

" Set a mark at the cursor with C-x r m
map -b <C-x>rm m

" Jump to the mark in the current buffer with C-x r b
map -b <C-x>rb '

" C-v was pass-next, remap to bind with default keys
map -b <C-d> <C-v>
"
" C-x C-f starts the "Open File" dialog (C-x C-s is Save)
map <C-x><C-f> <C-d><C-o>

" M-Up/Dn toggles the toolbar and scrollbars
map <A-Down> :set go+=brT<CR>
map <A-Up> :set go-=brT<CR>

" Sidebar selection with s, close with S
map -b s :sidebar<SPACE>
map -b S :sbclose<CR>

" Dialog selection with d
map d :dialog<SPACE>

" Focus the address bar with C-l
map <C-l> <C-d><C-l>

" Focus last used input field with C-c i
map <C-c>i gi

" Add a bookmark with C-c a (dialog)
map <C-c>a <C-d><C-d>

" Bookmarks search, and search by tag
map <C-c>q :bmarks<SPACE>
map <C-c>w :bmarks -tags=

" View source with C-c g, and
map <C-c>g gf
" ... in an editor with C-c e
map <C-c>e gF

" Open picture location with C-c p
map <C-c>p ;i

" Open context menu with C-c m
map <C-c>m ;c

" Open home directory with C-c f
map <C-c>f ~

" Go to home page with C-c h
map <C-c>h gh

" Go to parent directory with C-c u
map <C-c>u gu

" Go to the root of the website with C-c C-u
map <C-c><C-u> gU

" Restart with C-c C-r
map <C-c><C-r> :restart<CR>

" Tab moving helpers
map -b <A-m> :tabmove<SPACE>
map -b <A-Left> :tabmove! -1<CR>
map -b <A-Right> :tabmove! +1<CR>

" Turn off certain keybindings

map D <Nop>
map u <Nop>
map w <Nop>
map W <Nop>
map <C-u> <Nop>
map <C-d> <Nop>
map <C-u> <Nop>
map <C-x> <Nop>
map <C-h> <Nop>
map <C-x><C-f> <Nop>
map : <Nop>
map ~ <Nop>
map / <Nop>
map ? <Nop>
map $ <Nop>
map 0 <Nop>
map b <Nop>
map d <Nop>
map gg <Nop>
map gh <Nop>
map gi <Nop>
map gU <Nop>
map G <Nop>
map j <Nop>
map k <Nop>
map o <Nop>
map O <Nop>
map p <Nop>
map P <Nop>
map q <Nop>
map r <Nop>
map t <Nop>
map u <Nop>
map w <Nop>
map y <Nop>
map Y <Nop>
map ZZ <Nop>


code:
" Load the plugins
loadplugins '\.(js|penta)$'
group user

set titlestring="Pentadactyl"

" Colorscheme
colorscheme darkness

" Faster navigation
map -count -modes=n j -builtin <count>3j
map -count -modes=n k -builtin <count>3k

" Use duckduckgo to search by default
map -builtin -modes=n s :open duckduckgo !g
map -builtin -modes=n S :tabopen duckduckgo !g

" Use livestreamer to view video streams
map -builtin -modes=n v :livestreamer<CR>

" I never use marks, but always use quickmarks
nmap -builtin "'" go
nmap -builtin '"' gn

" Highlight all search matches, not just the first
set hlfind

" Configure the command line and the look
set maxitems=20
set showtabline=never
set showstatuslinks=command
set guioptions=Cs

" Set the default motor search
set defsearch=duckduckgo

map -b <F9> :js document.getElementById('nav-bar').collapsed ^= 1;<CR>

command! private-tab -nargs=+ -description "Open Private Tab" -javascript <<EOF
  privateTab.readyToOpenTab(true);
  gBrowser.addTab("about:home");
  dactyl.execute(":tablast");
  dactyl.execute(":open " + args);
  privateTab.stopToOpenTabs();
EOF

map -b <C-x>h :private-tab about:home<CR>


code:
[colors]
bg_focus = "#b3020202"
bg_normal = "#b3020202"
bg_urgent = "#2A1F1EAA"
bg_warning = "#2A1F1EAA"
fg_focus = "#DDDCFF"
fg_normal = "#747474"
fg_underline = "#00FF65"
fg_urgent = "#CC9393"
fg_warning = #ffa900

[bar/top]
clickareas = 16
height = 16
monitor = ${env:MONITOR}
width = 100%

tray-background = ${colors.bg_normal}
tray-position = right

background = ${colors.bg_normal}
foreground = ${colors.fg_normal}

dpi = 96
separator = ""

overline-color = ${colors.fg_urgent}
overline-size = 0
underline-color = ${colors.bg_urgent}
underline-size = 2

locale = es_EC.UTF-8

font-0 = Misc Termsyn:size=10;1
font-1 = Wuncon Siji:size=12;1
font-2 = FontAwesome:pixelsize=8;1

modules-left = ws title
modules-center =
modules-right = wireless wired volume battery fs date

wm-restack = bspwm

[module/ws]
type = internal/bspwm
inline-mode = false
fuzzy-match = true

pin-workspaces = true
ws-icon-0 = 0;
ws-icon-1 = 1;
ws-icon-2 = 2;
ws-icon-3 = 3;
ws-icon-4 = 4;
ws-icon-5 = 5;
ws-icon-6 = 6;
ws-icon-7 = 7;
ws-icon-8 = 8;
ws-icon-9 = 9;
ws-icon-10 = 10;
ws-icon-11 = 11;
ws-icon-12 = 12;
ws-icon-default = 

format = <label-state> <label-mode>

label-dimmed-underline = ${colors.fg_normal}

label-focused = %icon%
label-focused-background = ${colors.bg_focus}
label-focused-foreground = ${colors.fg_focus}
label-focused-padding = 1
label-focused-underline = ${colors.fg_underline}

label-occupied = %icon%
label-occupied-foreground = ${colors.fg_normal}
label-occupied-padding = 1
label-occupied-underline = ${colors.fg_normal}

label-urgent = %icon%
label-urgent-background = ${colors.bg_normal}
label-urgent-foreground = ${colors.fg_normal}
label-urgent-padding = 1
label-urgent-underline = ${colors.fg_urgent}

label-empty =

[module/battery]
type = internal/battery
full-at = 100
time-format = %H:%M

format-charging = <animation-charging> <label-charging>
format-discharging = <ramp-capacity> <label-discharging>
format-full = <ramp-capacity> <label-full>

label-charging = %{F#fff}%percentage%%%{F-} (%{F#fff}%time%%{F-})
label-discharging = %{F#fff}%percentage%%%{F-} (%{F#fff}%time%%{F-})

ramp-capacity-0 = 
ramp-capacity-0-foreground = ${colors.fg_urgent}
ramp-capacity-1 = 
ramp-capacity-1-foreground = ${colors.fg_warning}
ramp-capacity-2 = 
ramp-capacity-3 = 
ramp-capacity-4 = 
ramp-capacity-5 = 
ramp-capacity-6 = 
ramp-capacity-7 = 
ramp-capacity-8 = 

animation-charging-0 = 
animation-charging-1 = 
animation-charging-2 = 
animation-charging-3 = 
animation-charging-4 = 
animation-charging-5 = 
animation-charging-6 = 
animation-charging-7 = 
animation-charging-8 = 
animation-charging-framerate = 750

[module/date]
type = internal/date
date =  %%{F#fff}W%W, %Y/%m/%d%{F-}
format = <label>
label = %{A1:urxvtcd --geometry 100x30 -e calcurse:}%date%%{A} %time%
time = %{F#fff}%R%{F-}

[module/wireless]
type = internal/network
interface = wlan0
interval = 1.0
ping-interval = 10

animation-packetloss-0 = 
animation-packetloss-0-foreground = ${colors.fg_warning}
animation-packetloss-1 = 
animation-packetloss-1-foreground = ${colors.fg_normal}
animation-packetloss-framerate = 500

format-connected = <ramp-signal> <label-connected>

label-connected = %{F#fff}%{A1:networkmanager_dmenu:}%essid%%{A}%{F-} (%{F#fff}%signal%%%{F-}) %{F#fff}%downspeed%%{F-}%{F#fff}%upspeed%%{F-}
label-disconnected = %{A1:networkmanager_dmenu:}%{A}
label-disconnected-foreground = #66

ramp-signal-0 = 
ramp-signal-1 = 
ramp-signal-2 = 
ramp-signal-3 = 
ramp-signal-4 = 

[module/wired]
type = internal/network
interface = net0
interval = 1.0

animation-packetloss-0 = 
animation-packetloss-0-foreground = ${colors.fg_warning}
animation-packetloss-1 = 
animation-packetloss-1-foreground = ${colors.fg_normal}
animation-packetloss-framerate = 500

format-connected = <ramp-signal> <label-connected>

label-connected = %{F#fff}%{A1:networkmanager_dmenu:}%local_ip%%{A}%{F-} %{F#fff}%downspeed%%{F-}%{F#fff}%upspeed%%{F-}
label-disconnected =

ramp-signal-0 = 

[module/volume]
type = internal/pulseaudio

format-muted-prefix = " "
format-volume = <ramp-volume> <label-volume>

label-muted = %{F#920}%percentage%M%{F-}
label-volume = %{F#fff}%percentage%%%{F-}

ramp-volume-0 = 
ramp-volume-1 = 

[module/fs]
type = internal/fs
fixed-values = true
interval = 10
mount-0 = /media/data
mount-1 = /

spacing = 1

format-mounted = <label-mounted>
format-unmounted = <label-unmounted>

label-mounted =  %{F#fff}%mountpoint%: %free%%{F-}
label-unmounted =

[module/title]
type = internal/xwindow
label = %title:0:35:...%


code:
# -*- coding: utf-8 -*-
# Copyright (C) 2009-2013  Roman Zimbelmann <hut@lavabit.com>
# This configuration file is licensed under the same terms as ranger.
# ===================================================================
# This file contains ranger's commands.
# It's all in python; lines beginning with # are comments.
#
# Note that additional commands are automatically generated from the methods
# of the class ranger.core.actions.Actions.
#
# You can customize commands in the file ~/.config/ranger/commands.py.
# It has the same syntax as this file.  In fact, you can just copy this
# file there with `ranger --copy-config=commands' and make your modifications.
# But make sure you update your configs when you update ranger.
#
# ===================================================================
# Every class defined here which is a subclass of `Command' will be used as a
# command in ranger.  Several methods are defined to interface with ranger:
#   execute(): called when the command is executed.
#   cancel():  called when closing the console.
#   tab():     called when <TAB> is pressed.
#   quick():   called after each keypress.
#
# The return values for tab() can be either:
#   None: There is no tab completion
#   A string: Change the console to this string
#   A list/tuple/generator: cycle through every item in it
#
# The return value for quick() can be:
#   False: Nothing happens
#   True: Execute the command afterwards
#
# The return value for execute() and cancel() doesn't matter.
#
# ===================================================================
# Commands have certain attributes and methods that facilitate parsing of
# the arguments:
#
# self.line: The whole line that was written in the console.
# self.args: A list of all (space-separated) arguments to the command.
# self.quantifier: If this command was mapped to the key "X" and
#      the user pressed 6X, self.quantifier will be 6.
# self.arg(n): The n-th argument, or an empty string if it doesn't exist.
# self.rest(n): The n-th argument plus everything that followed.  For example,
#      if the command was "search foo bar a b c", rest(2) will be "bar a b c"
# self.start(n): Anything before the n-th argument.  For example, if the
#      command was "search foo bar a b c", start(2) will be "search foo"
#
# ===================================================================
# And this is a little reference for common ranger functions and objects:
#
# self.fm: A reference to the "fm" object which contains most information
#      about ranger.
# self.fm.notify(string): Print the given string on the screen.
# self.fm.notify(string, bad=True): Print the given string in RED.
# self.fm.reload_cwd(): Reload the current working directory.
# self.fm.thisdir: The current working directory. (A File object.)
# self.fm.thisfile: The current file. (A File object too.)
# self.fm.thistab.get_selection(): A list of all selected files.
# self.fm.execute_console(string): Execute the string as a ranger command.
# self.fm.open_console(string): Open the console with the given string
#      already typed in for you.
# self.fm.move(direction): Moves the cursor in the given direction, which
#      can be something like down=3, up=5, right=1, left=1, to=6, ...
#
# File objects (for example self.fm.thisfile) have these useful attributes and
# methods:
#
# cf.path: The path to the file.
# cf.basename: The base name only.
# cf.load_content(): Force a loading of the directories content (which
#      obviously works with directories only)
# cf.is_directory: True/False depending on whether it's a directory.
#
# For advanced commands it is unavoidable to dive a bit into the source code
# of ranger.
# ===================================================================

import os
import re

from ranger.api.commands import *
from ranger.core.loader import CommandLoader
from ranger.core.runner import ALLOWED_FLAGS
from ranger.ext.get_executables import get_executables

class alias(Command):
    """:alias <newcommand> <oldcommand>

    Copies the oldcommand as newcommand.
    """

    context = 'browser'
    resolve_macros = False

    def execute(self):
        if not self.arg(1) or not self.arg(2):
            self.fm.notify('Syntax: alias <newcommand> <oldcommand>', bad=True)
        else:
            self.fm.commands.alias(self.arg(1), self.rest(2))

class cd(Command):
    """:cd [-r] <dirname>

    The cd command changes the directory.
    The command 'cd -' is equivalent to typing ``.
    Using the option "-r" will get you to the real path.
    """

    def execute(self):
        import os.path
        if self.arg(1) == '-r':
            self.shift()
            destination = os.path.realpath(self.rest(1))
            if os.path.isfile(destination):
                destination = os.path.dirname(destination)
        else:
            destination = self.rest(1)

        if not destination:
            destination = '~'

        if destination == '-':
            self.fm.enter_bookmark('`')
        else:
            self.fm.cd(destination)

    def tab(self):
        import os
        from os.path import dirname, basename, expanduser, join

        cwd = self.fm.thisdir.path
        rel_dest = self.rest(1)

        bookmarks = [v.path for v in self.fm.bookmarks.dct.values()
                     if rel_dest in v.path]

        # expand the tilde into the user directory
        if rel_dest.startswith('~'):
            rel_dest = expanduser(rel_dest)

        # define some shortcuts
        abs_dest = join(cwd, rel_dest)
        abs_dirname = dirname(abs_dest)
        rel_basename = basename(rel_dest)
        rel_dirname = dirname(rel_dest)

        try:
            # are we at the end of a directory?
            if rel_dest.endswith('/') or rel_dest == '':
                _, dirnames, _ = next(os.walk(abs_dest))

            # are we in the middle of the filename?
            else:
                _, dirnames, _ = next(os.walk(abs_dirname))
                dirnames = [dn for dn in dirnames
                            if dn.startswith(rel_basename)]
        except (OSError, StopIteration):
            # os.walk found nothing
            pass
        else:
            dirnames.sort()
            dirnames = bookmarks + dirnames

            # no results, return None
            if len(dirnames) == 0:
                return

            # one result. since it must be a directory, append a slash.
            if len(dirnames) == 1:
                return self.start(1) + join(rel_dirname, dirnames[0]) + '/'

            # more than one result. append no slash, so the user can
            # manually type in the slash to advance into that directory
            return (self.start(1) + join(rel_dirname, dirname) for dirname in dirnames)

class chain(Command):
    """:chain <command1>; <command2>; ...

    Calls multiple commands at once, separated by semicolons.
    """

    def execute(self):
        for command in self.rest(1).split(";"):
            self.fm.execute_console(command)

class shell(Command):
    escape_macros_for_shell = True

    def execute(self):
        if self.arg(1) and self.arg(1)[0] == '-':
            flags = self.arg(1)[1:]
            command = self.rest(2)
        else:
            flags = ''
            command = self.rest(1)

        if not command and 'p' in flags:
            command = 'cat %f'
        if command:
            if '%' in command:
                command = self.fm.substitute_macros(command, escape=True)
            self.fm.execute_command(command, flags=flags)

    def tab(self):
        from ranger.ext.get_executables import get_executables
        if self.arg(1) and self.arg(1)[0] == '-':
            command = self.rest(2)
        else:
            command = self.rest(1)
        start = self.line[0:len(self.line) - len(command)]

        try:
            position_of_last_space = command.rindex(" ")
        except ValueError:
            return (start + program + ' ' for program
                    in get_executables() if program.startswith(command))
        if position_of_last_space == len(command) - 1:
            selection = self.fm.thistab.get_selection()
            if len(selection) == 1:
                return self.line + selection[0].shell_escaped_basename + ' '
            else:
                return self.line + '%s '
        else:
            before_word, start_of_word = self.line.rsplit(' ', 1)
            return (before_word + ' ' + file.shell_escaped_basename
                    for file in self.fm.thisdir.files
                    if file.shell_escaped_basename.startswith(start_of_word))

class open_with(Command):

    def execute(self):
        app, flags, mode = self._get_app_flags_mode(self.rest(1))
        self.fm.execute_file(
            files=[f for f in self.fm.thistab.get_selection()],
            app=app,
            flags=flags,
            mode=mode)

    def tab(self):
        return self._tab_through_executables()

    def _get_app_flags_mode(self, string):
        """Extracts the application, flags and mode from a string.

        examples:
        "mplayer f 1" => ("mplayer", "f", 1)
        "aunpack 4" => ("aunpack", "", 4)
        "p" => ("", "p", 0)
        "" => None
        """

        app = ''
        flags = ''
        mode = 0
        split = string.split()

        if len(split) == 0:
            pass

        elif len(split) == 1:
            part = split[0]
            if self._is_app(part):
                app = part
            elif self._is_flags(part):
                flags = part
            elif self._is_mode(part):
                mode = part

        elif len(split) == 2:
            part0 = split[0]
            part1 = split[1]

            if self._is_app(part0):
                app = part0
                if self._is_flags(part1):
                    flags = part1
                elif self._is_mode(part1):
                    mode = part1
            elif self._is_flags(part0):
                flags = part0
                if self._is_mode(part1):
                    mode = part1
            elif self._is_mode(part0):
                mode = part0
                if self._is_flags(part1):
                    flags = part1

        elif len(split) >= 3:
            part0 = split[0]
            part1 = split[1]
            part2 = split[2]

            if self._is_app(part0):
                app = part0
                if self._is_flags(part1):
                    flags = part1
                    if self._is_mode(part2):
                        mode = part2
                elif self._is_mode(part1):
                    mode = part1
                    if self._is_flags(part2):
                        flags = part2
            elif self._is_flags(part0):
                flags = part0
                if self._is_mode(part1):
                    mode = part1
            elif self._is_mode(part0):
                mode = part0
                if self._is_flags(part1):
                    flags = part1

        return app, flags, int(mode)

    def _is_app(self, arg):
        return not self._is_flags(arg) and not arg.isdigit()

    def _is_flags(self, arg):
        from ranger.core.runner import ALLOWED_FLAGS
        return all(x in ALLOWED_FLAGS for x in arg)

    def _is_mode(self, arg):
        return all(x in '0123456789' for x in arg)

class set_(Command):
    """:set <option name>=<python expression>

    Gives an option a new value.
    """
    name = 'set'  # don't override the builtin set class

    def execute(self):
        name = self.arg(1)
        name, value, _ = self.parse_setting_line()
        self.fm.set_option_from_string(name, value)

    def tab(self):
        name, value, name_done = self.parse_setting_line()
        settings = self.fm.settings
        if not name:
            return sorted(self.firstpart + setting for setting in settings)
        if not value and not name_done:
            return (self.firstpart + setting for setting in settings
                    if setting.startswith(name))
        if not value:
            return self.firstpart + str(settings[name])
        if bool in settings.types_of(name):
            if 'true'.startswith(value.lower()):
                return self.firstpart + 'True'
            if 'false'.startswith(value.lower()):
                return self.firstpart + 'False'

class setlocal(set_):
    """:setlocal path=<python string> <option name>=<python expression>

    Gives an option a new value.
    """
    PATH_RE = re.compile(r'^\s*path="?(.*?)"?\s*$')

    def execute(self):
        import os.path
        match = self.PATH_RE.match(self.arg(1))
        if match:
            path = os.path.normpath(os.path.expanduser(match.group(1)))
            self.shift()
        elif self.fm.thisdir:
            path = self.fm.thisdir.path
        else:
            path = None

        if path:
            name = self.arg(1)
            name, value, _ = self.parse_setting_line()
            self.fm.set_option_from_string(name, value, localpath=path)

class setintag(setlocal):
    """:setintag <tag or tags> <option name>=<option value>

    Sets an option for directories that are tagged with a specific tag.
    """

    def execute(self):
        tags = self.arg(1)
        self.shift()
        name, value, _ = self.parse_setting_line()
        self.fm.set_option_from_string(name, value, tags=tags)

class quit(Command):
    """:quit

    Closes the current tab.  If there is only one tab, quit the program.
    """

    def execute(self):
        if len(self.fm.tabs) <= 1:
            self.fm.exit()
        self.fm.tab_close()

class quitall(Command):
    """:quitall

    Quits the program immediately.
    """

    def execute(self):
        self.fm.exit()

class quit_bang(quitall):
    """:quit!

    Quits the program immediately.
    """
    name = 'quit!'
    allow_abbrev = False

class terminal(Command):
    """:terminal

    Spawns an "x-terminal-emulator" starting in the current directory.
    """

    def execute(self):
        import os
        from ranger.ext.get_executables import get_executables
        command = os.environ.get('TERMCMD', os.environ.get('TERM'))
        if command not in get_executables():
            command = 'x-terminal-emulator'
        if command not in get_executables():
            command = 'xterm'
        self.fm.run(command, flags='f')

class delete(Command):
    """:delete

    Tries to delete the selection.

    "Selection" is defined as all the "marked files" (by default, you
    can mark files with space or v). If there are no marked files,
    use the "current file" (where the cursor is)

    When attempting to delete non-empty directories or multiple
    marked files, it will require a confirmation.
    """

    allow_abbrev = False

    def execute(self):
        import os
        if self.rest(1):
            self.fm.notify("Error: delete takes no arguments! It deletes "
                           "the selected file(s).", bad=True)
            return

        cwd = self.fm.thisdir
        cf = self.fm.thisfile
        if not cwd or not cf:
            self.fm.notify("Error: no file selected for deletion!", bad=True)
            return

        confirm = self.fm.settings.confirm_on_delete
        many_files = (cwd.marked_items or (cf.is_directory and not cf.is_link
                                           and len(os.listdir(cf.path)) > 0))

        if confirm != 'never' and (confirm != 'multiple' or many_files):
            self.fm.ui.console.ask("Confirm deletion of: %s (y/N)" %
                                   ', '.join(f.basename for f in self.fm.thistab.get_selection()),
                                   self._question_callback, ('n', 'N', 'y', 'Y'))
        else:
            # no need for a confirmation, just delete
            self.fm.delete()

    def _question_callback(self, answer):
        if answer == 'y' or answer == 'Y':
            self.fm.delete()

class mark_tag(Command):
    """:mark_tag [<tags>]

    Mark all tags that are tagged with either of the given tags.
    When leaving out the tag argument, all tagged files are marked.
    """
    do_mark = True

    def execute(self):
        cwd = self.fm.thisdir
        tags = self.rest(1).replace(" ", "")
        if not self.fm.tags:
            return
        for fileobj in cwd.files:
            try:
                tag = self.fm.tags.tags[fileobj.realpath]
            except KeyError:
                continue
            if not tags or tag in tags:
                cwd.mark_item(fileobj, val=self.do_mark)
        self.fm.ui.status.need_redraw = True
        self.fm.ui.need_redraw = True

class console(Command):
    """:console <command>

    Open the console with the given command.
    """

    def execute(self):
        position = None
        if self.arg(1)[0:2] == '-p':
            try:
                position = int(self.arg(1)[2:])
                self.shift()
            except:
                pass
        self.fm.open_console(self.rest(1), position=position)

class load_copy_buffer(Command):
    """:load_copy_buffer

    Load the copy buffer from confdir/copy_buffer
    """
    copy_buffer_filename = 'copy_buffer'

    def execute(self):
        from ranger.container.file import File
        from os.path import exists
        try:
            fname = self.fm.confpath(self.copy_buffer_filename)
            f = open(fname, 'r')
        except:
            return self.fm.notify("Cannot open %s" %
                                  (fname or self.copy_buffer_filename), bad=True)
        self.fm.copy_buffer = set(File(g)
                                  for g in f.read().split("\n") if exists(g))
        f.close()
        self.fm.ui.redraw_main_column()

class save_copy_buffer(Command):
    """:save_copy_buffer

    Save the copy buffer to confdir/copy_buffer
    """
    copy_buffer_filename = 'copy_buffer'

    def execute(self):
        fname = None
        try:
            fname = self.fm.confpath(self.copy_buffer_filename)
            f = open(fname, 'w')
        except:
            return self.fm.notify("Cannot open %s" %
                                  (fname or self.copy_buffer_filename), bad=True)
        f.write("\n".join(f.path for f in self.fm.copy_buffer))
        f.close()

class unmark_tag(mark_tag):
    """:unmark_tag [<tags>]

    Unmark all tags that are tagged with either of the given tags.
    When leaving out the tag argument, all tagged files are unmarked.
    """
    do_mark = False

class mkdir(Command):
    """:mkdir <dirname>

    Creates a directory with the name <dirname>.
    """

    def execute(self):
        from os.path import join, expanduser, lexists
        from os import mkdir

        dirname = join(self.fm.thisdir.path, expanduser(self.rest(1)))
        if not lexists(dirname):
            mkdir(dirname)
        else:
            self.fm.notify("file/directory exists!", bad=True)

    def tab(self):
        return self._tab_directory_content()

class touch(Command):
    """:touch <fname>

    Creates a file with the name <fname>.
    """

    def execute(self):
        from os.path import join, expanduser, lexists

        fname = join(self.fm.thisdir.path, expanduser(self.rest(1)))
        if not lexists(fname):
            open(fname, 'a').close()
        else:
            self.fm.notify("file/directory exists!", bad=True)

    def tab(self):
        return self._tab_directory_content()

class edit(Command):
    """:edit <filename>

    Opens the specified file in vim
    """

    def execute(self):
        if not self.arg(1):
            self.fm.edit_file(self.fm.thisfile.path)
        else:
            self.fm.edit_file(self.rest(1))

    def tab(self):
        return self._tab_directory_content()

class eval_(Command):
    """:eval [-q] <python code>

    Evaluates the python code.
    `fm' is a reference to the FM instance.
    To display text, use the function `p'.

    Examples:
    :eval fm
    :eval len(fm.directories)
    :eval p("Hello World!")
    """
    name = 'eval'
    resolve_macros = False

    def execute(self):
        if self.arg(1) == '-q':
            code = self.rest(2)
            quiet = True
        else:
            code = self.rest(1)
            quiet = False
        import ranger
        global cmd, fm, p, quantifier
        fm = self.fm
        cmd = self.fm.execute_console
        p = fm.notify
        quantifier = self.quantifier
        try:
            try:
                result = eval(code)
            except SyntaxError:
                exec(code)
            else:
                if result and not quiet:
                    p(result)
        except Exception as err:
            p(err)

class rename(Command):
    """:rename <newname>

    Changes the name of the currently highlighted file to <newname>
    """

    def execute(self):
        from ranger.container.file import File
        from os import access

        new_name = self.rest(1)

        if not new_name:
            return self.fm.notify('Syntax: rename <newname>', bad=True)

        if new_name == self.fm.thisfile.basename:
            return

        if access(new_name, os.F_OK):
            return self.fm.notify("Can't rename: file already exists!", bad=True)

        self.fm.rename(self.fm.thisfile, new_name)
        f = File(new_name)
        self.fm.thisdir.pointed_obj = f
        self.fm.thisfile = f

    def tab(self):
        return self._tab_directory_content()

class chmod(Command):
    """:chmod <octal number>

    Sets the permissions of the selection to the octal number.

    The octal number is between 0 and 777. The digits specify the
    permissions for the user, the group and others.

    A 1 permits execution, a 2 permits writing, a 4 permits reading.
    Add those numbers to combine them. So a 7 permits everything.
    """

    def execute(self):
        mode = self.rest(1)
        if not mode:
            mode = str(self.quantifier)

        try:
            mode = int(mode, 8)
            if mode < 0 or mode > 0o777:
                raise ValueError
        except ValueError:
            self.fm.notify("Need an octal number between 0 and 777!", bad=True)
            return

        for file in self.fm.thistab.get_selection():
            try:
                os.chmod(file.path, mode)
            except Exception as ex:
                self.fm.notify(ex)

        try:
            # reloading directory.  maybe its better to reload the selected
            # files only.
            self.fm.thisdir.load_content()
        except:
            pass

class bulkrename(Command):
    """:bulkrename

    This command opens a list of selected files in an external editor.
    After you edit and save the file, it will generate a shell script
    which does bulk renaming according to the changes you did in the file.

    This shell script is opened in an editor for you to review.
    After you close it, it will be executed.
    """

    def execute(self):
        import sys
        import tempfile
        from ranger.container.file import File
        from ranger.ext.shell_escape import shell_escape as esc
        py3 = sys.version > "3"

        # Create and edit the file list
        filenames = [f.basename for f in self.fm.thistab.get_selection()]
        listfile = tempfile.NamedTemporaryFile()

        if py3:
            listfile.write("\n".join(filenames).encode("utf-8"))
        else:
            listfile.write("\n".join(filenames))
        listfile.flush()
        self.fm.execute_file([File(listfile.name)], app='editor')
        listfile.seek(0)
        if py3:
            new_filenames = listfile.read().decode("utf-8").split("\n")
        else:
            new_filenames = listfile.read().split("\n")
        listfile.close()
        if all(a == b for a, b in zip(filenames, new_filenames)):
            self.fm.notify("No renaming to be done!")
            return

        # Generate and execute script
        cmdfile = tempfile.NamedTemporaryFile()
        cmdfile.write(b"# This file will be executed when you close the editor.\n")
        cmdfile.write(b"# Please double-check everything, clear the file to abort.\n")
        if py3:
            cmdfile.write("\n".join("mv -vi -- " + esc(old) + " " + esc(new)
                                    for old, new in zip(filenames, new_filenames)
                                    if old != new).encode("utf-8"))
        else:
            cmdfile.write("\n".join("mv -vi -- " + esc(old) + " " + esc(new)
                                    for old, new in zip(filenames, new_filenames) if old != new))
        cmdfile.flush()
        self.fm.execute_file([File(cmdfile.name)], app='editor')
        self.fm.run(['/bin/sh', cmdfile.name], flags='w')
        cmdfile.close()

class relink(Command):
    """:relink <newpath>

    Changes the linked path of the currently highlighted symlink to <newpath>
    """

    def execute(self):
        from ranger.container.file import File

        new_path = self.rest(1)
        cf = self.fm.thisfile

        if not new_path:
            return self.fm.notify('Syntax: relink <newpath>', bad=True)

        if not cf.is_link:
            return self.fm.notify('%s is not a symlink!' % cf.basename, bad=True)

        if new_path == os.readlink(cf.path):
            return

        try:
            os.remove(cf.path)
            os.symlink(new_path, cf.path)
        except OSError as err:
            self.fm.notify(err)

        self.fm.reset()
        self.fm.thisdir.pointed_obj = cf
        self.fm.thisfile = cf

    def tab(self):
        if not self.rest(1):
            return self.line + os.readlink(self.fm.thisfile.path)
        else:
            return self._tab_directory_content()

class help_(Command):
    """:help

    Display ranger's manual page.
    """
    name = 'help'

    def execute(self):
        if self.quantifier == 1:
            self.fm.dump_keybindings()
        elif self.quantifier == 2:
            self.fm.dump_commands()
        elif self.quantifier == 3:
            self.fm.dump_settings()
        else:
            self.fm.display_help()

class copymap(Command):
    """:copymap <keys> <newkeys1> [<newkeys2>...]

    Copies a "browser" keybinding from <keys> to <newkeys>
    """
    context = 'browser'

    def execute(self):
        if not self.arg(1) or not self.arg(2):
            return self.fm.notify("Not enough arguments", bad=True)

        for arg in self.args[2:]:
            self.fm.ui.keymaps.copy(self.context, self.arg(1), arg)

class copypmap(copymap):
    """:copypmap <keys> <newkeys1> [<newkeys2>...]

    Copies a "pager" keybinding from <keys> to <newkeys>
    """
    context = 'pager'

class copycmap(copymap):
    """:copycmap <keys> <newkeys1> [<newkeys2>...]

    Copies a "console" keybinding from <keys> to <newkeys>
    """
    context = 'console'

class copytmap(copymap):
    """:copycmap <keys> <newkeys1> [<newkeys2>...]

    Copies a "taskview" keybinding from <keys> to <newkeys>
    """
    context = 'taskview'

class unmap(Command):
    """:unmap <keys> [<keys2>, ...]

    Remove the given "browser" mappings
    """
    context = 'browser'

    def execute(self):
        for arg in self.args[1:]:
            self.fm.ui.keymaps.unbind(self.context, arg)

class cunmap(unmap):
    """:cunmap <keys> [<keys2>, ...]

    Remove the given "console" mappings
    """
    context = 'browser'

class punmap(unmap):
    """:punmap <keys> [<keys2>, ...]

    Remove the given "pager" mappings
    """
    context = 'pager'

class tunmap(unmap):
    """:tunmap <keys> [<keys2>, ...]

    Remove the given "taskview" mappings
    """
    context = 'taskview'

class map_(Command):
    """:map <keysequence> <command>

    Maps a command to a keysequence in the "browser" context.

    Example:
    map j move down
    map J move down 10
    """
    name = 'map'
    context = 'browser'
    resolve_macros = False

    def execute(self):
        self.fm.ui.keymaps.bind(self.context, self.arg(1), self.rest(2))

class cmap(map_):
    """:cmap <keysequence> <command>

    Maps a command to a keysequence in the "console" context.

    Example:
    cmap <ESC> console_close
    cmap <C-x> console_type test
    """
    context = 'console'

class tmap(map_):
    """:tmap <keysequence> <command>

    Maps a command to a keysequence in the "taskview" context.
    """
    context = 'taskview'

class pmap(map_):
    """:pmap <keysequence> <command>

    Maps a command to a keysequence in the "pager" context.
    """
    context = 'pager'

class scout(Command):
    """:scout [-FLAGS] <pattern>

    Swiss army knife command for searching, traveling and filtering files.
    The command takes various flags as arguments which can be used to
    influence its behaviour:

    -a = automatically open a file on unambiguous match
    -e = open the selected file when pressing enter
    -f = filter files that match the current search pattern
    -g = interpret pattern as a glob pattern
    -i = ignore the letter case of the files
    -k = keep the console open when changing a directory with the command
    -l = letter skipping; e.g. allow "rdme" to match the file "readme"
    -m = mark the matching files after pressing enter
    -M = unmark the matching files after pressing enter
    -p = permanent filter: hide non-matching files after pressing enter
    -s = smart case; like -i unless pattern contains upper case letters
    -t = apply filter and search pattern as you type
    -v = inverts the match

    Multiple flags can be combined.  For example, ":scout -gpt" would create
    a :filter-like command using globbing.
    """
    AUTO_OPEN = 'a'
    OPEN_ON_ENTER = 'e'
    FILTER = 'f'
    SM_GLOB = 'g'
    IGNORE_CASE = 'i'
    KEEP_OPEN = 'k'
    SM_LETTERSKIP = 'l'
    MARK = 'm'
    UNMARK = 'M'
    PERM_FILTER = 'p'
    SM_REGEX = 'r'
    SMART_CASE = 's'
    AS_YOU_TYPE = 't'
    INVERT = 'v'

    def __init__(self, *args, **kws):
        Command.__init__(self, *args, **kws)
        self._regex = None
        self.flags, self.pattern = self.parse_flags()

    def execute(self):
        thisdir = self.fm.thisdir
        flags = self.flags
        pattern = self.pattern
        regex = self._build_regex()
        count = self._count(move=True)

        self.fm.thistab.last_search = regex
        self.fm.set_search_method(order="search")

        if self.MARK in flags or self.UNMARK in flags:
            value = flags.find(self.MARK) > flags.find(self.UNMARK)
            if self.FILTER in flags:
                for f in thisdir.files:
                    thisdir.mark_item(f, value)
            else:
                for f in thisdir.files:
                    if regex.search(f.basename):
                        thisdir.mark_item(f, value)

        if self.PERM_FILTER in flags:
            thisdir.filter = regex if pattern else None

        # clean up:
        self.cancel()

        if self.OPEN_ON_ENTER in flags or \
                self.AUTO_OPEN in flags and count == 1:
            if os.path.exists(pattern):
                self.fm.cd(pattern)
            else:
                self.fm.move(right=1)

        if self.KEEP_OPEN in flags and thisdir != self.fm.thisdir:
            # reopen the console:
            self.fm.open_console(self.line[0:-len(pattern)])

        if thisdir != self.fm.thisdir and pattern != "..":
            self.fm.block_input(0.5)

    def cancel(self):
        self.fm.thisdir.temporary_filter = None
        self.fm.thisdir.refilter()

    def quick(self):
        asyoutype = self.AS_YOU_TYPE in self.flags
        if self.FILTER in self.flags:
            self.fm.thisdir.temporary_filter = self._build_regex()
        if self.PERM_FILTER in self.flags and asyoutype:
            self.fm.thisdir.filter = self._build_regex()
        if self.FILTER in self.flags or self.PERM_FILTER in self.flags:
            self.fm.thisdir.refilter()
        if self._count(move=asyoutype) == 1 and self.AUTO_OPEN in self.flags:
            return True
        return False

    def tab(self):
        self._count(move=True, offset=1)

    def _build_regex(self):
        if self._regex is not None:
            return self._regex

        frmat = "%s"
        flags = self.flags
        pattern = self.pattern

        if pattern == ".":
            return re.compile("")

        # Handle carets at start and dollar signs at end separately
        if pattern.startswith('^'):
            pattern = pattern[1:]
            frmat = "^" + frmat
        if pattern.endswith('$'):
            pattern = pattern[:-1]
            frmat += "$"

        # Apply one of the search methods
        if self.SM_REGEX in flags:
            regex = pattern
        elif self.SM_GLOB in flags:
            regex = re.escape(pattern).replace("\\*", ".*").replace("\\?", ".")
        elif self.SM_LETTERSKIP in flags:
            regex = ".*".join(re.escape(c) for c in pattern)
        else:
            regex = re.escape(pattern)

        regex = frmat % regex

        # Invert regular expression if necessary
        if self.INVERT in flags:
            regex = "^(?:(?!%s).)*$" % regex

        # Compile Regular Expression
        options = re.LOCALE | re.UNICODE
        if self.IGNORE_CASE in flags or self.SMART_CASE in flags and \
                pattern.islower():
            options |= re.IGNORECASE
        try:
            self._regex = re.compile(regex, options)
        except:
            self._regex = re.compile("")
        return self._regex

    def _count(self, move=False, offset=0):
        count = 0
        cwd = self.fm.thisdir
        pattern = self.pattern

        if not pattern:
            return 0
        if pattern == '.':
            return 0
        if pattern == '..':
            return 1

        deq = deque(cwd.files)
        deq.rotate(-cwd.pointer - offset)
        i = offset
        regex = self._build_regex()
        for fsobj in deq:
            if regex.search(fsobj.basename):
                count += 1
                if move and count == 1:
                    cwd.move(to=(cwd.pointer + i) % len(cwd.files))
                    self.fm.thisfile = cwd.pointed_obj
            if count > 1:
                return count
            i += 1

        return count == 1

class grep(Command):
    """:grep <string>

    Looks for a string in all marked files or directories
    """

    def execute(self):
        if self.rest(1):
            action = ['grep', '--line-number']
            action.extend(['-e', self.rest(1), '-r'])
            action.extend(f.path for f in self.fm.thistab.get_selection())
            self.fm.execute_command(action, flags='p')

# Version control commands
# --------------------------------
class stage(Command):
    """
    :stage

    Stage selected files for the corresponding version control system
    """

    def execute(self):
        from ranger.ext.vcs import VcsError

        filelist = [f.path for f in self.fm.thistab.get_selection()]
        self.fm.thisdir.vcs_outdated = True
#        for f in self.fm.thistab.get_selection():
#            f.vcs_outdated = True

        try:
            self.fm.thisdir.vcs.add(filelist)
        except VcsError:
            self.fm.notify("Could not stage files.")

        self.fm.reload_cwd()

class unstage(Command):
    """
    :unstage

    Unstage selected files for the corresponding version control system
    """

    def execute(self):
        from ranger.ext.vcs import VcsError

        filelist = [f.path for f in self.fm.thistab.get_selection()]
        self.fm.thisdir.vcs_outdated = True
#        for f in self.fm.thistab.get_selection():
#            f.vcs_outdated = True

        try:
            self.fm.thisdir.vcs.reset(filelist)
        except VcsError:
            self.fm.notify("Could not unstage files.")

        self.fm.reload_cwd()

class diff(Command):
    """
    :diff

    Displays a diff of selected files against the last committed version
    """

    def execute(self):
        from ranger.ext.vcs import VcsError
        import tempfile

        L = self.fm.thistab.get_selection()
        if len(L) == 0:
            return

        filelist = [f.path for f in L]
        vcs = L[0].vcs

        diff = vcs.get_raw_diff(filelist=filelist)
        if len(diff.strip()) > 0:
            tmp = tempfile.NamedTemporaryFile()
            tmp.write(diff.encode('utf-8'))
            tmp.flush()

            pager = os.environ.get('PAGER', ranger.DEFAULT_PAGER)
            self.fm.run([pager, tmp.name])
        else:
            raise Exception("diff is empty")

class log(Command):
    """
    :log

    Displays the log of the current repo or files
    """

    def execute(self):
        from ranger.ext.vcs import VcsError
        import tempfile

        L = self.fm.thistab.get_selection()
        if len(L) == 0:
            return

        filelist = [f.path for f in L]
        vcs = L[0].vcs

        log = vcs.get_raw_log(filelist=filelist)
        tmp = tempfile.NamedTemporaryFile()
        tmp.write(log.encode('utf-8'))
        tmp.flush()

        pager = os.environ.get('PAGER', ranger.DEFAULT_PAGER)
        self.fm.run([pager, tmp.name])

# Customizations
#------------------------

class empty(Command):
    """
    :empty

    Empties the trash directory ~/.local/share/Trash/files

    """

    def execute(self):
        self.fm.run("rm -rf ~/.local/share/Trash/files/{*,.[^.]*}")
        self.fm.run("rm -rf ~/.local/share/Trash/info/{*,.[^.]*}")
        self.fm.run("rm -rf ~/.local/share/Trash/expunged/{*,.[^.]*}")

class compress(Command):

    def execute(self):
        """ Compress marked files to current directory """
        cwd = self.fm.thisdir
        marked_files = cwd.get_selection()

        if not marked_files:
            return

        def refresh(_):
            cwd = self.fm.get_directory(original_path)
            cwd.load_content()

        original_path = cwd.path
        parts = self.line.split()
        au_flags = parts[1:]

        descr = "compressing files in: " + os.path.basename(parts[1])
        obj = CommandLoader(args=['apack'] + au_flags +
                            [os.path.relpath(f.path, cwd.path) for f in marked_files], descr=descr)

        obj.signal_bind('after', refresh)
        self.fm.loader.add(obj)

    def tab(self):
        """ Complete with current folder name """

        extension = ['.zip', '.tar.gz', '.rar', '.7z']
        return ['compress ' + os.path.basename(self.fm.thisdir.path) + ext for ext in extension]

class extracthere(Command):

    def execute(self):
        """ Extract copied files to current directory """
        copied_files = tuple(self.fm.copy_buffer)

        if not copied_files:
            return

        def refresh(_):
            cwd = self.fm.get_directory(original_path)
            cwd.load_content()

        one_file = copied_files[0]
        cwd = self.fm.thisdir
        original_path = cwd.path
        au_flags = ['-X', cwd.path]
        au_flags += self.line.split()[1:]
        au_flags += ['-e']

        self.fm.copy_buffer.clear()
        self.fm.cut_buffer = False
        if len(copied_files) == 1:
            descr = "extracting: " + os.path.basename(one_file.path)
        else:
            descr = "extracting files from: " + os.path.basename(one_file.dirname)
            obj = CommandLoader(args=['aunpack'] + au_flags
                                + [f.path for f in copied_files], descr=descr)

        obj.signal_bind('after', refresh)
        self.fm.loader.add(obj)


code:
# ===================================================================
# Compatible since ranger 1.7.0
#
# By copying this file to ~/.config/ranger/rc.conf, ranger will be
# controllable with emacs-like key bindings.
#
# While this works well in combination with the default VIM-like key bindings,
# you may want to disable them by setting the environment variable
# RANGER_LOAD_DEFAULT_RC to FALSE.  For example by adding this to your
# ~/.bashrc (if you use bash):
#
# export RANGER_LOAD_DEFAULT_RC=FALSE
#
# 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
# ===================================================================

set viewmode miller

# How many columns are there, and what are their relative widths?
set column_ratios 1,3,5

# Which files should be hidden? (regular expression)
set hidden_filter ^\.|\.(?:pyc|pyo|bak|swp)$|^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

# Use non-default path for file preview script?
# ranger ships with scope.sh, a script that calls external programs (see
# README.md for dependencies) to preview images, archives, etc.
#set preview_script ~/.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
# like feh or sxiv?  You can still open selected files by marking them.
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
# disabled, local (only show local info), enabled (show local and remote
# information).
set vcs_backend_git disabled
set vcs_backend_hg disabled
set vcs_backend_bzr disabled

# Use one of the supported image preview protocols
set preview_images true

# Set the preview image method. Supported methods:
#
# * w3m (default):
#   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.
#
# * iterm2:
#   Preview images in full color using iTerm2 image previews
#   (http://iterm2.com/images.html). This requires using iTerm2 compiled
#   with image preview support.
#
# * urxvt:
#   Preview images in full color using urxvt image backgrounds. This
#   requires using urxvt compiled with pixbuf support.
#
# * urxvt-full:
#   The same as urxvt but utilizing not only the preview pane but the
#   whole terminal window.
set preview_images_method urxvt

# Use a unicode "..." character to mark cut-off filenames?
set unicode_ellipsis false

# Show dotfiles in the bookmark preview box?
set show_hidden_bookmarks true

# Which colorscheme to use?  These colorschemes are available by default:
# default, jungle, snow, solarized
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

# Save the console history on exit?
set save_console_history 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 false

# Display the directory name in tabs?
set dirname_in_tabs true

# Enable the mouse support?
set mouse_enabled false

# Display the file size in the main column or status bar?
set display_size_in_main_column true
set display_size_in_status_bar true

# Display the free disk space in the status bar?
set display_free_space_in_status_bar true

# Display files tags in all columns or only in main column?
set display_tags_in_all_columns true

# Set a title for the window?
set update_title true

# 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

# Show hostname in titlebar?
set hostname_in_titlebar true

# 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

# 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 true

# You can display the "real" cumulative size of directories by using the
# command :get_cumulative_size or typing "dc".  The size is expensive to
# calculate and will not be updated automatically.  You can choose
# to update it automatically though by turning on this option:
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 true

# Avoid previewing files larger than this size, in bytes.  Use a value of 0 to
# disable this feature.
set preview_max_size 0

# 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

# ===================================================================
# == 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 qa   quitall
alias qall quitall
alias setl setlocal

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

# ===================================================================
# == Define keys for the browser
# ===================================================================

# Basic
map <C-x><C-c> quit!
map <C-x>k quit

map <C-x>R     reload_cwd
map <C-x><C-r> reset
map <C-l>      redraw_window
map <C-g>      chain abort; change_mode normal; mark_files all=True val=False

map <C-x>i display_file
map <C-h>  help
map <C-x>W display_log
map <C-x>w taskview_open

map <A-x>  console
map <A-!>  console shell%space
map <A-f> chain draw_possible_programs; console open_with%space

# Change the line mode
map <C-x>mf linemode filename
map <C-x>mi linemode fileinfo
map <C-x>mp linemode permissions
map <C-x>mt linemode metatitle

# Tagging / Marking
map <C-x>t<any> tag_toggle tag=%any
map <C-_>t      tag_remove
map <Space>     mark_files toggle=True
map <C-Space>   toggle_visual_mode

# For the nostalgics: Midnight Commander bindings
map <F1> help
map <F3> display_file
map <F4> edit
map <F5> copy
map <F6> cut
map <F7> console mkdir%space
map <F8> console delete
map <F10> exit

# Direction keys
map <UP>       move up=1
map <DOWN>     move down=1
map <LEFT>     move left=1
map <RIGHT>    move right=1
map <HOME>     move to=0
map <END>      move to=-1
map <PAGEDOWN> move down=1   pages=True
map <PAGEUP>   move up=1     pages=True
map <CR>       move right=1
#map <DELETE>   console delete
map <INSERT>   console touch%space

copymap <UP>       <C-p>
copymap <DOWN>     <C-n>
copymap <LEFT>     <C-b>
copymap <RIGHT>    <C-f>
copymap <HOME>     <A-LT>
copymap <END>      <A-GT>
copymap <PAGEDOWN> <A-v>
copymap <PAGEUP>   <C-v>

# Jumping around
map <C-u><C-space> history_go -1
map <A-}> move_parent 1
map <A-{> move_parent -1

map <C-x>gh cd ~
map <C-x>ge cd /etc
map <C-x>gu cd /usr
map <C-x>gd cd /dev
map <C-x>gl cd -r .
map <C-x>gL cd -r %f
map <C-x>go cd /opt
map <C-x>gv cd /var
map <C-x>gm cd /media
map <C-x>gM cd /mnt
map <C-x>gs cd /srv
map <C-x>gr cd /
map <C-x>gR eval fm.cd(ranger.RANGERDIR)
map <C-x>g/ cd /
map <C-x>g? cd /usr/share/doc/ranger

# External Programs
map <C-x><C-f>  edit
map <C-x>du shell -p du --max-depth=1 -h --apparent-size
map <C-x>dU shell -p du --max-depth=1 -h --apparent-size | sort -rh
map <C-x>wp shell -f echo -n %d/%f | xsel -i; xsel -o | xsel -i -b
map <C-x>wd shell -f echo -n %d    | xsel -i; xsel -o | xsel -i -b
map <C-x>wn shell -f echo -n %f    | xsel -i; xsel -o | xsel -i -b

# Filesystem Operations
map <C-x>= chmod

map <A-d>  console rename%space
map <C-e>  eval fm.open_console('rename ' + fm.thisfile.relative_path)
map <C-a>  eval fm.open_console('rename ' + fm.thisfile.relative_path, position=7)

map <C-y>y  paste
map <C-y>o  paste overwrite=True
map <C-y>l  paste_symlink relative=False
map <C-y>L  paste_symlink relative=True
map <C-y>hl paste_hardlink
map <C-y>ht paste_hardlinked_subtree

map <C-w>  cut
map <C-_>w uncut
map <C-x><C-w>a cut mode=add
map <C-x><C-w>r cut mode=remove

map <A-w>  copy
map <C-x><A-w>a copy mode=add
map <C-x><A-w>r copy mode=remove

# Searching
map <C-x>s console search_inc%space
map <C-s> search_next
map <C-r> search_next forward=False

# Tabs
#map <C-n>     tab_new ~
map <C-x>b    tab_move 1
map <A-Right> tab_move 1
map <A-Left>  tab_move -1
map <C-x><C-f> tab_new ~
map <C-_>k    tab_restore
map <a-1>     tab_open 1
map <a-2>     tab_open 2
map <a-3>     tab_open 3
map <a-4>     tab_open 4
map <a-5>     tab_open 5
map <a-6>     tab_open 6
map <a-7>     tab_open 7
map <a-8>     tab_open 8
map <a-9>     tab_open 9

# Sorting
map <C-x>or toggle_option sort_reverse
map <C-x>oz set sort=random
map <C-x>os chain set sort=size;      set sort_reverse=False
map <C-x>ob chain set sort=basename;  set sort_reverse=False
map <C-x>on chain set sort=natural;   set sort_reverse=False
map <C-x>om chain set sort=mtime;     set sort_reverse=False
map <C-x>oc chain set sort=ctime;     set sort_reverse=False
map <C-x>oa chain set sort=atime;     set sort_reverse=False
map <C-x>ot chain set sort=type;      set sort_reverse=False
map <C-x>oe chain set sort=extension; set sort_reverse=False

map <C-x>oS chain set sort=size;      set sort_reverse=True
map <C-x>oB chain set sort=basename;  set sort_reverse=True
map <C-x>oN chain set sort=natural;   set sort_reverse=True
map <C-x>oM chain set sort=mtime;     set sort_reverse=True
map <C-x>oC chain set sort=ctime;     set sort_reverse=True
map <C-x>oA chain set sort=atime;     set sort_reverse=True
map <C-x>oT chain set sort=type;      set sort_reverse=True
map <C-x>oE chain set sort=extension; set sort_reverse=True

map <C-x>dc get_cumulative_size

# Settings
map <C-x>zc    toggle_option collapse_preview
map <C-x>zd    toggle_option sort_directories_first
map <C-x>zh    toggle_option show_hidden
map <C-x>zi    toggle_option flushinput
map <C-x>zm    toggle_option mouse_enabled
map <C-x>zp    toggle_option preview_files
map <C-x>zP    toggle_option preview_directories
map <C-x>zs    toggle_option sort_case_insensitive
map <C-x>zu    toggle_option autoupdate_cumulative_size
map <C-x>zv    toggle_option use_preview_script
map <C-x>zf    console filter%space
map <C-x>nn    narrow

# Bookmarks
map <C-x>rb<any> enter_bookmark %any
map <C-x>rm<any> set_bookmark %any
map <C-x>ru<any> unset_bookmark %any

map <C-x>rb<bg>   draw_bookmarks
copymap <C-x>rb<bg>  <C-x>rm<bg> <C-x>ru<bg>

map <C-x>u shell -d udiskie-umount %d/%f

# Generate all the chmod bindings with some python help:
eval for arg in "rwxXst": cmd("map <C-x>+u{0} shell -f chmod u+{0} %s".format(arg))
eval for arg in "rwxXst": cmd("map <C-x>+g{0} shell -f chmod g+{0} %s".format(arg))
eval for arg in "rwxXst": cmd("map <C-x>+o{0} shell -f chmod o+{0} %s".format(arg))
eval for arg in "rwxXst": cmd("map <C-x>+a{0} shell -f chmod a+{0} %s".format(arg))
eval for arg in "rwxXst": cmd("map <C-x>+{0}  shell -f chmod u+{0} %s".format(arg))

eval for arg in "rwxXst": cmd("map <C-x>-u{0} shell -f chmod u-{0} %s".format(arg))
eval for arg in "rwxXst": cmd("map <C-x>-g{0} shell -f chmod g-{0} %s".format(arg))
eval for arg in "rwxXst": cmd("map <C-x>-o{0} shell -f chmod o-{0} %s".format(arg))
eval for arg in "rwxXst": cmd("map <C-x>-a{0} shell -f chmod a-{0} %s".format(arg))
eval for arg in "rwxXst": cmd("map <C-x>-{0}  shell -f chmod u-{0} %s".format(arg))

# Search for letters as you type them
#eval for arg in "abcdefghijklmnopqrstuvwxyz": cmd("map {0} console search_inc {0}".format(arg))
map <allow_quantifiers> false

# ===================================================================
# == Define keys for the console
# ===================================================================
# Note: Unmapped keys are passed directly to the console.

# Basic
cmap <tab>   eval fm.ui.console.tab()
cmap <s-tab> eval fm.ui.console.tab(-1)
cmap <C-g>   eval fm.ui.console.close()
cmap <CR>    eval fm.ui.console.execute()
cmap <C-l>   redraw_window

copycmap <C-g> <esc>
copycmap <CR>  <C-j>

# Move around
cmap <up>    eval fm.ui.console.history_move(-1)
cmap <down>  eval fm.ui.console.history_move(1)
cmap <left>  eval fm.ui.console.move(left=1)
cmap <right> eval fm.ui.console.move(right=1)
cmap <home>  eval fm.ui.console.move(right=0, absolute=True)
cmap <end>   eval fm.ui.console.move(right=-1, absolute=True)

# Line Editing
cmap <backspace>  eval fm.ui.console.delete(-1)
cmap <delete>     eval fm.ui.console.delete(0)
cmap <C-w>        eval fm.ui.console.delete_word()
cmap <C-k>        eval fm.ui.console.delete_rest(1)
cmap <C-u>        eval fm.ui.console.delete_rest(-1)
cmap <C-y>        eval fm.ui.console.paste()

# And of course the emacs way
copycmap <up>        <C-p>
copycmap <down>      <C-n>
copycmap <left>      <C-b>
copycmap <right>     <C-f>
copycmap <home>      <C-a>
copycmap <end>       <C-e>
copycmap <delete>    <C-d>
copycmap <backspace> <C-h>

# Note: There are multiple ways to express backspaces.  <backspace> (code 263)
# and <backspace2> (code 127).  To be sure, use both.
copycmap <backspace> <backspace2>

# This special expression allows typing in numerals:
cmap <allow_quantifiers> false

# ===================================================================
# == Pager Keybindings
# ===================================================================

# Movement
pmap  <down>      pager_move  down=1
pmap  <up>        pager_move  up=1
pmap  <left>      pager_move  left=4
pmap  <right>     pager_move  right=4
pmap  <home>      pager_move  to=0
pmap  <end>       pager_move  to=-1
pmap  <pagedown>  pager_move  down=1.0  pages=True
pmap  <pageup>    pager_move  up=1.0    pages=True

copypmap <UP>       <C-p>
copypmap <DOWN>     <C-n> <CR>
copypmap <LEFT>     <C-b>
copypmap <RIGHT>    <C-f>
copypmap <HOME>     <A-LT>
copypmap <END>      <A-GT>
copypmap <PAGEDOWN> <C-F> <A-v> <Space>
copypmap <PAGEUP>   <C-B> <C-v>

# Basic
pmap     <C-l> redraw_window
pmap     <C-g> pager_close
copypmap <C-g> q Q i <F3>
pmap E      edit_file

# ===================================================================
# == Taskview Keybindings
# ===================================================================

# Movement
tmap <up>        taskview_move up=1
tmap <down>      taskview_move down=1
tmap <home>      taskview_move to=0
tmap <end>       taskview_move to=-1
tmap <pagedown>  taskview_move down=1.0  pages=True
tmap <pageup>    taskview_move up=1.0    pages=True
tmap <C-d>       taskview_move down=0.5  pages=True
tmap <C-u>       taskview_move up=0.5    pages=True

copytmap <UP>       k  <C-p>
copytmap <DOWN>     j  <C-n> <CR>
copytmap <HOME>     g
copytmap <END>      G
copytmap <C-u>      u
copytmap <PAGEDOWN> n  f  <C-F>  <Space>
copytmap <PAGEUP>   p  b  <C-B>

# Changing priority and deleting tasks
tmap <A-n>      eval -q fm.ui.taskview.task_move(-1)
tmap <A-p>      eval -q fm.ui.taskview.task_move(0)
tmap <C-d>      eval -q fm.ui.taskview.task_remove()
tmap <pagedown> eval -q fm.ui.taskview.task_move(-1)
tmap <pageup>   eval -q fm.ui.taskview.task_move(0)
tmap <delete>   eval -q fm.ui.taskview.task_remove()

# Basic
tmap <C-l> redraw_window
tmap <C-g> taskview_close

#MPD
map <C-x>go eval from ranger.ext.spawn import spawn; fm.select_file(spawn("grep ^music_directory ~/.config/mpd/mpd.conf | grep -oP '(?<=\").*(?=\")'").strip() + "/" + spawn("mpc -f %file% | head -1"))

# Start shell
map <C-x>mm shell $SHELL -c "cd %d; $SHELL"


code:
# 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:
#   <condition1> , <condition2> , ... = 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 <regexp> | The regexp matches $1
#   ext <regexp>   | The regexp matches the extension of $1
#   mime <regexp>  | The regexp matches the mime type of $1
#   name <regexp>  | The regexp matches the basename of $1
#   path <regexp>  | The regexp matches the absolute path of $1
#   has <program>  | The program is installed (i.e. located in $PATH)
#   env <variable> | The environment variable "variable" is non-empty
#   file           | $1 is a file
#   directory      | $1 is a directory
#   number <n>     | 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 <flags>  | Change how the program is run. See below.
#   label <label> | Assign a label or name to the command so it can
#                 | be started with :open_with <label> in ranger
#                 | or `rifle -p <label>` 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 >& /dev/null &
#   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 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 "$@"

#-------------------------------------------
# Misc
#-------------------------------------------
# Define the "editor" for text files as first action
mime ^text,  label editor = emacsclient -t "$@"
mime ^text,  label pager  = less "$@"
!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"

#--------------------------------------------
# Audio without X
#-------------------------------------------
mime ^audio|ogg$, terminal, has mpv      = mpv -- "$@"
mime ^audio|ogg$, terminal, has mplayer2 = mplayer2 -- "$@"
mime ^audio|ogg$, terminal, has mplayer  = mplayer -- "$@"
ext midi?,        terminal, has wildmidi = wildmidi -- "$@"

#--------------------------------------------
# Video/Audio with a GUI
#-------------------------------------------
mime ^video|audio, has gmplayer, X, flag f = gmplayer -- "$@"
mime ^video|audio, has smplayer, X, flag f = smplayer "$@"
mime ^video,       has mpv,      X, flag f = mpv -- "$@"
mime ^video,       has mpv,      X, flag f = mpv --fs -- "$@"
mime ^video,       has mplayer2, X, flag f = mplayer2 -- "$@"
mime ^video,       has mplayer2, X, flag f = mplayer2 -fs -- "$@"
mime ^video,       has mplayer,  X, flag f = mplayer -- "$@"
mime ^video,       has mplayer,  X, flag f = mplayer -fs -- "$@"
mime ^video|audio, has vlc,      X, flag f = vlc -- "$@"
mime ^video|audio, has totem,    X, flag f = totem -- "$@"
mime ^video|audio, has totem,    X, flag f = totem --fullscreen -- "$@"

#--------------------------------------------
# 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-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 docx?, has catdoc,       terminal = catdoc -- "$@" | "$PAGER"

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]|fod[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has libreoffice, X, flag f = libreoffice "$@"
ext pptx?|od[dfgpst]|fod[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has soffice,     X, flag f = soffice "$@"
ext pptx?|od[dfgpst]|fod[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, has pqiv,      X, flag f = pqiv -- "$@"
mime ^image, has sxiv,      X, flag f = sxiv -- "$@"
mime ^image, has feh,       X, flag f = feh -- "$@"
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 -- "$@"
ext xcf,                    X, flag f = gimp -- "$@"

#-------------------------------------------
# Archives
#-------------------------------------------

# avoid password prompt by providing empty password
ext 7z, has 7z = 7z -p l "$@" | "$PAGER"
# This requires atool
ext 7z|ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz,  has als     = als -- "$@" | "$PAGER"
ext iso|jar|msi|pkg|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|shar|tar|tgz|xar|xpi|xz|zip,     has aunpack = aunpack -- "$@"

# RAR Archives
ext rar,                                             has lsar   = lsar -l "$@" | "$PAGER"
ext rar,                                             has unar   = unar -D -f "$@"

# 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" -- "$@"

# The very last action, so that it's never triggered accidentally, is to execute a program:
mime application/x-executable = "$1"


code:
#!/usr/bin/env sh
# ranger supports enhanced previews.  If the option "use_preview_script"
# is set to True and this file exists, this script will be called and its
# output is displayed in ranger.  ANSI color codes are supported.

# NOTES: This script is considered a configuration file.  If you upgrade
# ranger, it will be left untouched. (You must update it yourself.)
# Also, ranger disables STDIN here, so interactive scripts won't work properly

# Meanings of exit codes:
# code | meaning    | action of ranger
# -----+------------+-------------------------------------------
# 0    | success    | success. display stdout as preview
# 1    | no preview | failure. display no preview at all
# 2    | plain text | display the plain content of the file
# 3    | fix width  | success. Don't reload when width changes
# 4    | fix height | success. Don't reload when height changes
# 5    | fix both   | success. Don't ever reload
# 6    | image      | success. display the image $cached points to as an image preview
# 7    | image      | success. display the file directly as an image

# Meaningful aliases for arguments:
path="$1"            # Full path of the selected file
width="$2"           # Width of the preview pane (number of fitting characters)
height="$3"          # Height of the preview pane (number of fitting characters)
cached="$4"          # Path that should be used to cache image previews
preview_images="$5"  # "True" if image previews are enabled, "False" otherwise.

maxln=200    # Stop after $maxln lines.  Can be used like ls | head -n $maxln

# Find out something about the file:
mimetype=$(file --mime-type -Lb "$path")
extension=$(/bin/echo "${path##*.}" | awk '{print tolower($0)}')

# Functions:
# runs a command and saves its output into $output.  Useful if you need
# the return value AND want to use the output in a pipe
try() { output=$(eval '"$@"'); }

# writes the output of the previously used "try" command
dump() { /bin/echo "$output"; }

# a common post-processing function used after most commands
trim() { head -n "$maxln"; }

# wraps highlight to treat exit code 141 (killed by SIGPIPE) as success
safepipe() { "$@"; test $? = 0 -o $? = 141; }

# Image previews, if enabled in ranger.
if [ "$preview_images" = "True" ]; then
    case "$mimetype" in
        # Image previews for SVG files, disabled by default.
        ###image/svg+xml)
        ###   convert "$path" "$cached" && exit 6 || exit 1;;
        # Image previews for image files. w3mimgdisplay will be called for all
        # image files (unless overriden as above), but might fail for
        # unsupported types.
        image/*)
            exit 7;;
        # Image preview for video, disabled by default.:
        ###video/*)
        ###    ffmpegthumbnailer -i "$path" -o "$cached" -s 0 && exit 6 || exit 1;;
    esac
fi

case "$extension" in
    # Archive extensions:
    a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|\
    rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z|zip)
      try als "$path" && { dump | trim; exit 0; }
      try acat "$path" && { dump | trim; exit 3; }
      try bsdtar -lf "$path" && { dump | trim; exit 0; }
      exit 1;;
    rar)
      # avoid password prompt by providing empty password
      try lsar -l "$path" && { dump | trim; exit 0; } || exit 1;;
    7z)
      # avoid password prompt by providing empty password
      try 7z -p l "$path" && { dump | trim; exit 0; } || exit 1;;
    # PDF documents:
    pdf)
      try pdftotext -l 10 -nopgbrk -q "$path" - && \
        { dump | trim | fmt -s -w $width; exit 0; } || exit 1;;
    # BitTorrent Files
    torrent)
      try transmission-show "$path" && { dump | trim; exit 5; } || exit 1;;
    # ODT Files
    odt|ods|odp|sxw)
      try odt2txt "$path" && { dump | trim; exit 5; } || exit 1;;
    # HTML Pages:
    htm|html|xhtml)
      try w3m    -dump "$path" && { dump | trim | fmt -s -w $width; exit 4; }
      try lynx   -dump "$path" && { dump | trim | fmt -s -w $width; exit 4; }
      try elinks -dump "$path" && { dump | trim | fmt -s -w $width; exit 4; }
      ;; # fall back to highlight/cat if the text browsers fail
esac

case "$mimetype" in
    # Syntax highlight for text files:
    text/* | */xml)
        if [ "$(tput colors)" -ge 256 ]; then
            pygmentize_format=terminal256
            highlight_format=xterm256
        else
            pygmentize_format=terminal
            highlight_format=ansi
        fi
        try safepipe highlight --out-format=${highlight_format} "$path" && { dump | trim; exit 5; }
        try safepipe pygmentize -f ${pygmentize_format} "$path" && { dump | trim; exit 5; }
        exit 2;;
    # Ascii-previews of images:
    image/*)
        img2txt --gamma=0.6 --width="$width" "$path" && exit 4 || exit 1;;
    # Image preview for videos, disabled by default:
    video/*)
        ffmpegthumbnailer -i "$path" -o "$cached" -s 0 && exit 6 || exit 1;;
    # Display information about media files:
    video/* | audio/*)
        exiftool "$path" && exit 5
        # Use sed to remove spaces so the output fits into the narrow window
        try mediainfo "$path" && { dump | trim | sed 's/  \+:/: /;';  exit 5; } || exit 1;;
esac

exit 1


code:
[dmenu]
dmenu_command = /usr/bin/rofi -width 22

[dmenu_passphrase]
nf = #222222
nb = #222222
rofi_obscure = True

[editor]
terminal = urxvtcd
gui_if_available = True


code:
# permanently set alternative root dir
# root=/path/to/root

# rofi command. Make sure to have "$@" as last argument
_rofi () {
    rofi -width 22 -i -no-auto-select "$@"
}

# xdotool needs the keyboard layout to be set using setxkbmap
# You can do this in your autostart scripts (e.g. xinitrc)

# If for some reason, you cannot do this, you can set the command here.
# and set fix_layout to true
fix_layout=false

layout_cmd () {
  setxkbmap us
}

# fields to be used
URL_field='url'
USERNAME_field='user'
AUTOTYPE_field='autotype'

# delay to be used for :delay keyword
delay=2

# rofi-pass needs to close itself before it can type passwords. Set delay here.
wait=0.2

## Programs to be used
# Editor
EDITOR='emacs'

# Browser
BROWSER='firefox'

## Misc settings

default_do='menu' # menu, autotype, copyPass, typeUser, typePass, copyUser, copyUrl, viewEntry, typeMenu, actionMenu, copyMenu, openUrl
auto_enter='false'
notify='false'
default_autotype='user :tab pass'

# color of the help messages
# leave empty for autodetection
help_color="#4872FF"

# Clipboard settings
# Possible options: primary, clipboard, both
clip=clipboard

# show help header
help_header="false"

# Options for generating new password entries
# default_user is also used for password files that have no user field.
#default_user=john_doe
#default_user2=mary_ann
#password_length=12

# Custom Keybindings
autotype="Alt+1"
type_user="Alt+2"
type_pass="Alt+3"
open_url="Alt+4"
copy_name="Alt+u"
copy_url="Alt+l"
copy_pass="Alt+p"
show="Alt+o"
copy_entry="Alt+2"
type_entry="Alt+1"
copy_menu="Alt+c"
action_menu="Alt+a"
type_menu="Alt+t"
help="Alt+h"
switch="Alt+x"
insert_pass="Alt+n"


code:
# This is an example resource file for rTorrent. Copy to
# ~/.rtorrent.rc and enable/modify the options as needed. Remember to
# uncomment the options you wish to enable.

# Maximum and minimum number of peers to connect to per torrent.
#min_peers = 40
max_peers = 100

# Same as above but for seeding completed torrents (-1 = same as downloading)
#min_peers_seed = 10
max_peers_seed = -1

# Maximum number of simultanious uploads per torrent.
max_uploads = 15

# Global upload and download rate in KiB. "0" for unlimited.
download_rate = 0
upload_rate = 0

# Default directory to save the downloaded torrents.
directory = ~/rtorrent/download

# Default session directory. Make sure you don't run multiple instance
# of rtorrent using the same session directory. Perhaps using a
# relative path?
session = ~/rtorrent/session

# Watch a directory for new torrents, and stop those that have been
# deleted.
schedule = watch_directory,5,5,load_start=~/rtorrent/watch/*.torrent
# schedule = untied_directory,5,5,stop_untied=~/rtorrent/complete

# Close torrents when diskspace is low.
#schedule = low_diskspace,5,60,close_low_diskspace=100M

# The ip address reported to the tracker.
#ip = 127.0.0.1
#ip = rakshasa.no

# The ip address the listening socket and outgoing connections is
# bound to.
#bind = 127.0.0.1
#bind = rakshasa.no

# Port range to use for listening.
port_range = 49164-49164

# Start opening ports at a random position within the port range.
#port_random = no

# Check hash for finished torrents. Might be usefull until the bug is
# fixed that causes lack of diskspace not to be properly reported.
check_hash = no

# Set whether the client should try to connect to UDP trackers.
use_udp_trackers = yes

# Alternative calls to bind and ip that should handle dynamic ip's.
#schedule = ip_tick,0,1800,ip=rakshasa
#schedule = bind_tick,0,1800,bind=rakshasa

# Encryption options, set to none (default) or any combination of the following:
# allow_incoming, try_outgoing, require, require_RC4, enable_retry, prefer_plaintext
#
# The example value allows incoming encrypted connections, starts unencrypted
# outgoing connections but retries with encryption if they fail, preferring
# plaintext to RC4 encryption after the encrypted handshake
#
# encryption = allow_incoming,enable_retry,prefer_plaintext

# Enable DHT support for trackerless torrents or when all trackers are down.
# May be set to "disable" (completely disable DHT), "off" (do not start DHT),
# "auto" (start and stop DHT as needed), or "on" (start DHT immediately).
# The default is "off". For DHT to work, a session directory must be defined.
#
dht = auto

# UDP port to use for DHT.
#
# dht_port = 6881

# Enable peer exchange (for torrents not marked private)
#
peer_exchange = yes

system.method.set_key = event.download.finished,move_complete,"execute=mv,-u,$d.get_base_path=,~/rtorrent/share/;d.set_directory=~/rtorrent/share/"