Update
This commit is contained in:
parent
cbc8fcebb3
commit
bc83789790
465
home/.config/ranger/rc.conf
Normal file
465
home/.config/ranger/rc.conf
Normal file
@ -0,0 +1,465 @@
|
|||||||
|
# ===================================================================
|
||||||
|
# == Options
|
||||||
|
# ===================================================================
|
||||||
|
set viewmode miller
|
||||||
|
set column_ratios 1,2,4
|
||||||
|
|
||||||
|
set scroll_offset 8
|
||||||
|
set show_cursor false
|
||||||
|
set mouse_enabled true
|
||||||
|
set confirm_on_delete always
|
||||||
|
set colorscheme default
|
||||||
|
|
||||||
|
set shorten_title 4
|
||||||
|
set update_title true
|
||||||
|
set update_tmux_title true
|
||||||
|
set tilde_in_titlebar true
|
||||||
|
set hostname_in_titlebar true
|
||||||
|
set max_history_size 20
|
||||||
|
set max_console_history_size 50
|
||||||
|
set save_console_history true
|
||||||
|
|
||||||
|
set open_all_images false
|
||||||
|
set preview_images false
|
||||||
|
set use_preview_script true
|
||||||
|
set preview_images_method w3m
|
||||||
|
set preview_script ~/.config/ranger/scope.sh
|
||||||
|
|
||||||
|
set automatically_count_files true
|
||||||
|
set preview_max_size 0
|
||||||
|
set preview_files true
|
||||||
|
set preview_directories true
|
||||||
|
set collapse_preview true
|
||||||
|
|
||||||
|
set unicode_ellipsis true
|
||||||
|
set padding_right false
|
||||||
|
set draw_borders true
|
||||||
|
set dirname_in_tabs true
|
||||||
|
set status_bar_on_top false
|
||||||
|
set draw_progress_bar_in_status_bar true
|
||||||
|
|
||||||
|
set display_size_in_main_column true
|
||||||
|
set display_size_in_status_bar false
|
||||||
|
set display_tags_in_all_columns true
|
||||||
|
set flushinput true
|
||||||
|
set autosave_bookmarks true
|
||||||
|
set autoupdate_cumulative_size false
|
||||||
|
|
||||||
|
# Enable this if key combinations with the Alt Key don't work for you. (Especially on xterm)
|
||||||
|
set xterm_alt_key false
|
||||||
|
|
||||||
|
set sort natural
|
||||||
|
set sort_reverse false
|
||||||
|
set sort_unicode false
|
||||||
|
set sort_case_insensitive true
|
||||||
|
set sort_directories_first true
|
||||||
|
|
||||||
|
set vcs_aware true
|
||||||
|
set vcs_backend_git enabled
|
||||||
|
set vcs_backend_hg disabled
|
||||||
|
set vcs_backend_bzr disabled
|
||||||
|
set vcs_backend_svn disabled
|
||||||
|
|
||||||
|
set cd_bookmarks true
|
||||||
|
set cd_tab_case sensitive
|
||||||
|
set cd_tab_fuzzy true
|
||||||
|
set show_selection_in_titlebar true
|
||||||
|
|
||||||
|
set idle_delay 2000
|
||||||
|
set metadata_deep_search false
|
||||||
|
set clear_filters_on_dir_change true
|
||||||
|
set line_numbers false
|
||||||
|
set one_indexed false
|
||||||
|
set save_tabs_on_exit true
|
||||||
|
set wrap_scroll true
|
||||||
|
set global_inode_type_filter
|
||||||
|
set show_hidden true
|
||||||
|
set show_hidden_bookmarks true
|
||||||
|
set hidden_filter ^\.|\.(?:pyc|pyo|bak|old|swp)$|^lost\+found$|^__(py)?cache__$
|
||||||
|
|
||||||
|
# ===================================================================
|
||||||
|
# == Local Options
|
||||||
|
# ===================================================================
|
||||||
|
# You can set local options that only affect a single directory.
|
||||||
|
|
||||||
|
# Examples:
|
||||||
|
# setlocal path=~/downloads sort mtime
|
||||||
|
|
||||||
|
|
||||||
|
# ===================================================================
|
||||||
|
# == Command Aliases in the Console
|
||||||
|
# ===================================================================
|
||||||
|
|
||||||
|
# aliases
|
||||||
|
alias e edit
|
||||||
|
alias q quit
|
||||||
|
alias q! quit!
|
||||||
|
alias qa quitall
|
||||||
|
alias qa! quitall!
|
||||||
|
alias qall 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 -aefklst
|
||||||
|
|
||||||
|
# ===================================================================
|
||||||
|
# == Define keys for the browser
|
||||||
|
# ===================================================================
|
||||||
|
|
||||||
|
# Basic
|
||||||
|
map Q quitall
|
||||||
|
map q quit
|
||||||
|
copymap q ZZ ZQ
|
||||||
|
|
||||||
|
map R reload_cwd
|
||||||
|
map F set freeze_files!
|
||||||
|
map <C-r> reset
|
||||||
|
map <C-l> redraw_window
|
||||||
|
map <C-c> abort
|
||||||
|
map <Esc> change_mode normal
|
||||||
|
map ~ set viewmode!
|
||||||
|
|
||||||
|
map i display_file
|
||||||
|
map ? help
|
||||||
|
map W display_log
|
||||||
|
map w taskview_open
|
||||||
|
map S shell $SHELL
|
||||||
|
|
||||||
|
map : console
|
||||||
|
map ; console
|
||||||
|
map ! console shell%space
|
||||||
|
map @ console -p6 shell %%s
|
||||||
|
map # console shell -p%space
|
||||||
|
map s console shell%space
|
||||||
|
map f console find%space
|
||||||
|
map r chain draw_possible_programs; console open_with%%space
|
||||||
|
map cd console cd%space
|
||||||
|
|
||||||
|
# Tagging / Marking
|
||||||
|
map t tag_toggle
|
||||||
|
map ut tag_remove
|
||||||
|
map "<any> tag_toggle tag=%any
|
||||||
|
map <Space> mark_files toggle=True
|
||||||
|
map v toggle_visual_mode
|
||||||
|
map uv toggle_visual_mode reverse=True
|
||||||
|
map V mark_files all=True toggle=True
|
||||||
|
map uV mark_files all=True val=False
|
||||||
|
|
||||||
|
# For the nostalgics: Midnight Commander bindings
|
||||||
|
map <F1> help
|
||||||
|
map <F2> rename_append
|
||||||
|
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
|
||||||
|
|
||||||
|
# In case you work on a keyboard with dvorak layout
|
||||||
|
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
|
||||||
|
|
||||||
|
# VIM like
|
||||||
|
copymap <Up> k
|
||||||
|
copymap <Down> j
|
||||||
|
copymap <Left> h
|
||||||
|
copymap <Right> l
|
||||||
|
copymap <Home> gg
|
||||||
|
copymap <End> G
|
||||||
|
copymap <PAGEDOWN> <C-F>
|
||||||
|
copymap <PAGEUP> <C-B>
|
||||||
|
map J move down=0.5 pages=True
|
||||||
|
map K move up=0.5 pages=True
|
||||||
|
|
||||||
|
# Jumping around
|
||||||
|
map L history_go 1
|
||||||
|
map H history_go -1
|
||||||
|
map ] move_parent 1
|
||||||
|
map [ move_parent -1
|
||||||
|
map } traverse
|
||||||
|
map ) jump_non
|
||||||
|
|
||||||
|
map E edit
|
||||||
|
|
||||||
|
# Better file renaming
|
||||||
|
map a rename_append
|
||||||
|
map cw eval fm.execute_console("bulkrename") if fm.thisdir.marked_items else fm.execute_console("rename_append")
|
||||||
|
map A eval fm.open_console('rename ' + fm.thisfile.relative_path.replace("%", "%%"))
|
||||||
|
map I eval fm.open_console('rename ' + fm.thisfile.relative_path.replace("%", "%%"), position=7)
|
||||||
|
|
||||||
|
# Open file in a new tmux pane
|
||||||
|
map eh eval import shlex; fm.run("tmux splitw -h rifle " + shlex.quote(fm.thisfile.basename))
|
||||||
|
map ev eval import shlex; fm.run("tmux splitw -v rifle " + shlex.quote(fm.thisfile.basename))
|
||||||
|
map ew eval import shlex; fm.run("tmux new-window rifle " + shlex.quote(fm.thisfile.basename))
|
||||||
|
|
||||||
|
map pp paste
|
||||||
|
map phl paste_hardlink
|
||||||
|
map pP paste append=True
|
||||||
|
map pr shell sudo cp %c %d
|
||||||
|
map po paste overwrite=True
|
||||||
|
map pht paste_hardlinked_subtree
|
||||||
|
map pL paste_symlink relative=True
|
||||||
|
map pl paste_symlink relative=False
|
||||||
|
map pO paste overwrite=True append=True
|
||||||
|
|
||||||
|
map dd cut
|
||||||
|
map ud uncut
|
||||||
|
map da cut mode=add
|
||||||
|
map dr cut mode=remove
|
||||||
|
map dt cut mode=toggle
|
||||||
|
map dc get_cumulative_size
|
||||||
|
map dD console delete
|
||||||
|
map DD shell rm -rf %s
|
||||||
|
|
||||||
|
# External Programs
|
||||||
|
map E edit
|
||||||
|
map du shell -p du --max-depth=1 -h --apparent-size
|
||||||
|
map dU shell -p du --max-depth=1 -h --apparent-size | sort -rh
|
||||||
|
map yp yank path
|
||||||
|
map yd yank dir
|
||||||
|
map yn yank name
|
||||||
|
|
||||||
|
map yy copy
|
||||||
|
map uy uncut
|
||||||
|
map ya copy mode=add
|
||||||
|
map yr copy mode=remove
|
||||||
|
map yt copy mode=toggle
|
||||||
|
map yd shell -f echo -n %d | xsel -i; xsel -o | xsel -i -b
|
||||||
|
map yn shell -f echo -n %f | xsel -i; xsel -o | xsel -i -b
|
||||||
|
map yp shell -f echo -n %d/%f | xsel -i; xsel -o | xsel -i -b
|
||||||
|
|
||||||
|
# Searching
|
||||||
|
map n search_next
|
||||||
|
map / console search%space
|
||||||
|
map f console scout -ftsea%space
|
||||||
|
|
||||||
|
# Sorting
|
||||||
|
map or set sort_reverse!
|
||||||
|
map os chain set sort=size; set sort_reverse=False
|
||||||
|
map ob chain set sort=basename; set sort_reverse=False
|
||||||
|
map on chain set sort=natural; set sort_reverse=False
|
||||||
|
map ot chain set sort=type; set sort_reverse=False
|
||||||
|
map oe chain set sort=extension; set sort_reverse=False
|
||||||
|
|
||||||
|
# Settings
|
||||||
|
map zi set preview_images!
|
||||||
|
map zp set preview_files!
|
||||||
|
map zP set preview_directories!
|
||||||
|
map zv set use_preview_script!
|
||||||
|
map zd set sort_directories_first!
|
||||||
|
map zc set collapse_preview!
|
||||||
|
map zI set flushinput!
|
||||||
|
map zm set mouse_enabled!
|
||||||
|
map zh set show_hidden!
|
||||||
|
map zf console filter%space
|
||||||
|
|
||||||
|
# Bookmarks
|
||||||
|
map `<any> enter_bookmark %any
|
||||||
|
map '<any> enter_bookmark %any
|
||||||
|
map \<any> set_bookmark %any
|
||||||
|
map u\<any> unset_bookmark %any
|
||||||
|
map \<bg> draw_bookmarks
|
||||||
|
copymap \<bg> u\<bg> `<bg> '<bg>
|
||||||
|
|
||||||
|
# Tabs
|
||||||
|
map tq tab_close
|
||||||
|
map tr tab_restore
|
||||||
|
map <TAB> tab_move 1
|
||||||
|
map <S-TAB> tab_move -1
|
||||||
|
map <A-Right> tab_move 1
|
||||||
|
map <A-Left> tab_move -1
|
||||||
|
map <A-l> tab_move 1
|
||||||
|
map <A-h> tab_move -1
|
||||||
|
map <C-n> tab_new
|
||||||
|
map <C-w> tab_close
|
||||||
|
map tn eval fm.tab_new('%d')
|
||||||
|
map uq 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
|
||||||
|
|
||||||
|
# Generate all the chmod bindings with some python help
|
||||||
|
eval for arg in "rwxXst": cmd("map +u{0} shell -f chmod u+{0} %s".format(arg))
|
||||||
|
eval for arg in "rwxXst": cmd("map +g{0} shell -f chmod g+{0} %s".format(arg))
|
||||||
|
eval for arg in "rwxXst": cmd("map +o{0} shell -f chmod o+{0} %s".format(arg))
|
||||||
|
eval for arg in "rwxXst": cmd("map +a{0} shell -f chmod a+{0} %s".format(arg))
|
||||||
|
eval for arg in "rwxXst": cmd("map +{0} shell -f chmod u+{0} %s".format(arg))
|
||||||
|
eval for arg in "rwxXst": cmd("map -u{0} shell -f chmod u-{0} %s".format(arg))
|
||||||
|
eval for arg in "rwxXst": cmd("map -g{0} shell -f chmod g-{0} %s".format(arg))
|
||||||
|
eval for arg in "rwxXst": cmd("map -o{0} shell -f chmod o-{0} %s".format(arg))
|
||||||
|
eval for arg in "rwxXst": cmd("map -a{0} shell -f chmod a-{0} %s".format(arg))
|
||||||
|
eval for arg in "rwxXst": cmd("map -{0} shell -f chmod u-{0} %s".format(arg))
|
||||||
|
|
||||||
|
# ===================================================================
|
||||||
|
# == Define keys for the console
|
||||||
|
# ===================================================================
|
||||||
|
|
||||||
|
# Basic
|
||||||
|
cmap <C-l> redraw_window
|
||||||
|
cmap <Tab> eval fm.ui.console.tab()
|
||||||
|
cmap <ESC> eval fm.ui.console.close()
|
||||||
|
cmap <CR> eval fm.ui.console.execute()
|
||||||
|
cmap <S-Tab> eval fm.ui.console.tab(-1)
|
||||||
|
copycmap <CR> <C-j>
|
||||||
|
copycmap <ESC> <C-c>
|
||||||
|
|
||||||
|
# Move around
|
||||||
|
cmap <Left> eval fm.ui.console.move(left=1)
|
||||||
|
cmap <Right> eval fm.ui.console.move(right=1)
|
||||||
|
cmap <Up> eval fm.ui.console.history_move(-1)
|
||||||
|
cmap <Down> eval fm.ui.console.history_move(1)
|
||||||
|
cmap <A-left> eval fm.ui.console.move_word(left=1)
|
||||||
|
cmap <A-right> eval fm.ui.console.move_word(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 <C-y> eval fm.ui.console.paste()
|
||||||
|
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 <Backspace> eval fm.ui.console.delete(-1)
|
||||||
|
cmap <A-d> eval fm.ui.console.delete_word(backward=False)
|
||||||
|
|
||||||
|
cmap <allow_quantifiers> false
|
||||||
|
copycmap <Backspace> <Backspace2>
|
||||||
|
|
||||||
|
# ===================================================================
|
||||||
|
# == Pager Keybindings
|
||||||
|
# ===================================================================
|
||||||
|
|
||||||
|
# Movement
|
||||||
|
pmap <Up> pager_move up=1
|
||||||
|
pmap <Home> pager_move to=0
|
||||||
|
pmap <End> pager_move to=-1
|
||||||
|
pmap <Down> pager_move down=1
|
||||||
|
pmap <Left> pager_move left=4
|
||||||
|
pmap <Right> pager_move right=4
|
||||||
|
pmap <C-u> pager_move up=0.5 pages=True
|
||||||
|
pmap <C-d> pager_move down=0.5 pages=True
|
||||||
|
pmap <Pageup> pager_move up=1.0 pages=True
|
||||||
|
pmap <Pagedown> pager_move down=1.0 pages=True
|
||||||
|
|
||||||
|
copypmap <End> G
|
||||||
|
copypmap <C-d> d
|
||||||
|
copypmap <C-u> u
|
||||||
|
copypmap <Home> g
|
||||||
|
copypmap <Left> h
|
||||||
|
copypmap <Right> l
|
||||||
|
copypmap <Up> k <C-p>
|
||||||
|
copypmap <Down> j <C-n> <CR>
|
||||||
|
copypmap <Pageup> p b <C-B>
|
||||||
|
copypmap <Pagedown> n f <C-F> <Space>
|
||||||
|
|
||||||
|
# Basic
|
||||||
|
pmap E edit_file
|
||||||
|
pmap <ESC> pager_close
|
||||||
|
pmap <C-l> redraw_window
|
||||||
|
copypmap <ESC> q Q i <F3>
|
||||||
|
|
||||||
|
# ===================================================================
|
||||||
|
# == 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 J eval -q fm.ui.taskview.task_move(-1)
|
||||||
|
tmap K eval -q fm.ui.taskview.task_move(0)
|
||||||
|
tmap dd 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 <ESC> taskview_close
|
||||||
|
copytmap <ESC> q Q w <C-c>
|
||||||
|
|
||||||
|
# ===================================================================
|
||||||
|
# == Additional Keybinds
|
||||||
|
# ===================================================================
|
||||||
|
|
||||||
|
## New
|
||||||
|
map Nf console touch%space
|
||||||
|
map Nd console mkdir%space
|
||||||
|
|
||||||
|
## Set background
|
||||||
|
map sZ shell nitrogen --set-zoom-fill --head=0 --save %f
|
||||||
|
map sz shell nitrogen --set-zoom-fill --head=1 --save %f
|
||||||
|
map sS shell nitrogen --set-scaled --head=0 --save %f
|
||||||
|
map ss shell nitrogen --set-scaled --head=1 --save %f
|
||||||
|
map sF shell nitrogen --set-zoom-fill --head=-1 --save %f
|
||||||
|
map sf shell nitrogen --set-scaled --head=-1 --save %f
|
||||||
|
|
||||||
|
## Go / cd
|
||||||
|
map gh cd ~
|
||||||
|
map g/ cd /
|
||||||
|
map gE cd /etc
|
||||||
|
map gu cd /usr
|
||||||
|
map gb cd ~/bin
|
||||||
|
map gm cd ~/Music
|
||||||
|
map g. cd ~/.config
|
||||||
|
map gp cd ~/Pictures
|
||||||
|
map gd cd ~/Downloads
|
||||||
|
map gr cd ~/.config/ranger
|
||||||
|
map g? cd /usr/share/doc/ranger
|
||||||
|
|
||||||
|
## Move
|
||||||
|
map mD shell mv %s ~/Documents/
|
||||||
|
map md shell mv %s ~/Downloads/
|
||||||
|
map mp shell mv %s ~/Pictures/
|
||||||
|
map m. shell mv %s ~/.config/
|
||||||
|
map mv shell mv %s ~/Videos/
|
||||||
|
map mm shell mv %s ~/Music/
|
||||||
|
map mb shell mv %s ~/bin/
|
||||||
|
map mh shell mv %s ~/
|
||||||
|
|
||||||
|
## Copy
|
||||||
|
map YD shell cp -r %s ~/Documents/
|
||||||
|
map Yd shell cp -r %s ~/Downloads/
|
||||||
|
map Yp shell cp -r %s ~/Pictures/
|
||||||
|
map Y. shell cp -r %s ~/.config/
|
||||||
|
map Yv shell cp -r %s ~/Videos/
|
||||||
|
map Ym shell cp -r %s ~/Music/
|
||||||
|
map Yb shell cp -r %s ~/bin/
|
||||||
|
map Yh shell cp -r %s ~/
|
143
home/.config/ranger/rifle.conf
Normal file
143
home/.config/ranger/rifle.conf
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
#-------------------------------------------
|
||||||
|
# Text
|
||||||
|
#
|
||||||
|
mime ^text, label editor = $EDITOR -- "$@"
|
||||||
|
mime ^text, label pager = $PAGER -- "$@"
|
||||||
|
!mime ^text, label editor, ext xml|json|csv|tex|py|pl|rb|js|sh|php = $EDITOR -- "$@"
|
||||||
|
!mime ^text, label pager, ext xml|json|csv|tex|py|pl|rb|js|sh|php = $PAGER -- "$@"
|
||||||
|
|
||||||
|
#-------------------------------------------
|
||||||
|
# Webpages
|
||||||
|
#
|
||||||
|
ext x?html?, X, flag f = firefox -- "$@"
|
||||||
|
ext x?html?, terminal = w3m "$@"
|
||||||
|
|
||||||
|
#-------------------------------------------
|
||||||
|
# Code
|
||||||
|
#
|
||||||
|
ext 1|5 = man "$1"
|
||||||
|
ext exe = wine "$1"
|
||||||
|
ext py = python -- "$1"
|
||||||
|
ext pl = perl -- "$1"
|
||||||
|
ext rb = ruby -- "$1"
|
||||||
|
ext js = node -- "$1"
|
||||||
|
ext sh = bash -- "$1"
|
||||||
|
ext php = php -- "$1"
|
||||||
|
name ^[mM]akefile$ = make
|
||||||
|
name ^PKGBUILD$ = makepkg --printsrcinfo >.SRCINFO && makepkg -f
|
||||||
|
|
||||||
|
#--------------------------------------------
|
||||||
|
# Audio without X
|
||||||
|
#
|
||||||
|
mime ^audio|ogg$, terminal, flag f, has mplayer2 = mplayer2 -- "$@"
|
||||||
|
mime ^audio|ogg$, terminal, flag f, has mpv = mpv -- "$@"
|
||||||
|
mime ^audio|ogg$, terminal, flag f, has mplayer = mplayer -- "$@"
|
||||||
|
ext midi?, terminal, flag f, has wildmidi = wildmidi -- "$@"
|
||||||
|
|
||||||
|
#--------------------------------------------
|
||||||
|
# Video/Audio with a GUI
|
||||||
|
#
|
||||||
|
ext gif, has mpv, X, flag f = mpv --loop -- "$1"
|
||||||
|
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 -- "$@"
|
||||||
|
|
||||||
|
# Without GUI:
|
||||||
|
ext gif, terminal, !X, has mpv, flag f = mpv --loop -- "$1"
|
||||||
|
mime ^video, terminal, !X, has mpv, flag f = mpv -- "$@"
|
||||||
|
mime ^video, terminal, !X, has mplayer2, flag f = mplayer2 -- "$@"
|
||||||
|
mime ^video, terminal, !X, has mplayer, flag f = mplayer -- "$@"
|
||||||
|
|
||||||
|
#-------------------------------------------
|
||||||
|
# Documents
|
||||||
|
#
|
||||||
|
ext pdf|djvu, has zathura, X, flag f = zathura -- "$@"
|
||||||
|
ext pdf|djvu, has evince, X, flag f = evince -- "$@"
|
||||||
|
ext pdf|djvu, has mupdf, X, flag f = mupdf "$@"
|
||||||
|
ext pdf|djvu, has mupdf-x11, X, flag f = mupdf-x11 "$@"
|
||||||
|
ext docx?, has catdoc, terminal = catdoc -- "$@" | "$PAGER"
|
||||||
|
ext sxc|xlsx?|xlt|xlw|gnm|gnumeric, has gnumeric, X, flag f = gnumeric -- "$@"
|
||||||
|
ext pptx?|od[dfgpst]|docx?|sxc, has libreoffice, X, flag f = libreoffice "$@"
|
||||||
|
ext xlsx?|xlt|xlw|gnm|gnumeric, has libreoffice, X, flag f = libreoffice "$@"
|
||||||
|
ext pptx?|od[dfgpst]|docx?|sxc, has soffice, X, flag f = soffice "$@"
|
||||||
|
ext xlsx?|xlt|xlw|gnm|gnumeric, has soffice, X, flag f = soffice "$@"
|
||||||
|
ext pptx?|od[dfgpst]|docx?|sxc, has ooffice, X, flag f = ooffice "$@"
|
||||||
|
ext xlsx?|xlt|xlw|gnm|gnumeric, has ooffice, X, flag f = ooffice "$@"
|
||||||
|
|
||||||
|
#-------------------------------------------
|
||||||
|
# Image Viewing:
|
||||||
|
#
|
||||||
|
mime ^image, has gpicview, X, flag f = gpicview -- "$@"
|
||||||
|
mime ^image, has feh, X, flag f = feh -- "$@"
|
||||||
|
mime ^image, has gimp, X, flag f = gimp -- "$@"
|
||||||
|
mime ^image/svg, has inkscape, X, flag f = inkscape -- "$@"
|
||||||
|
mime ^image/svg, has display, X, flag f = display -- "$@"
|
||||||
|
ext xcf, has gimp, X, flag f = gimp -- "$@"
|
||||||
|
|
||||||
|
#-------------------------------------------
|
||||||
|
# Archives
|
||||||
|
#
|
||||||
|
ext to|torrent, flag f, has deluge = deluge "$1"
|
||||||
|
ext 7z|ace|ar|arc|xar|xpi|xz|zip|gz, has aunpack = aunpack -- "$@"
|
||||||
|
ext bz2?|cab|cpio|cpt|deb|dgc|dmg, has aunpack = aunpack -- "$@"
|
||||||
|
ext iso|jar|msi|pkg|rar|shar|tar|tgz, has aunpack = aunpack -- "$@"
|
||||||
|
|
||||||
|
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 -- "$@"
|
||||||
|
|
||||||
|
mime application/x-executable = "$1"
|
161
home/.config/ranger/scope.sh
Executable file
161
home/.config/ranger/scope.sh
Executable file
@ -0,0 +1,161 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -o noclobber -o noglob -o nounset -o pipefail
|
||||||
|
IFS=$'\n'
|
||||||
|
|
||||||
|
# If the option `use_preview_script` is set to `true`,
|
||||||
|
# then this script will be called and its output will be displayed in ranger.
|
||||||
|
# ANSI color codes are supported.
|
||||||
|
# STDIN is disabled, so interactive scripts won't work properly
|
||||||
|
|
||||||
|
# This script is considered a configuration file and must be updated manually.
|
||||||
|
# It will be left untouched if you upgrade ranger.
|
||||||
|
|
||||||
|
# Meanings of exit codes:
|
||||||
|
# code | meaning | action of ranger
|
||||||
|
# -----+------------+-------------------------------------------
|
||||||
|
# 0 | success | Display stdout as preview
|
||||||
|
# 1 | no preview | Display no preview at all
|
||||||
|
# 2 | plain text | Display the plain content of the file
|
||||||
|
# 3 | fix width | Don't reload when width changes
|
||||||
|
# 4 | fix height | Don't reload when height changes
|
||||||
|
# 5 | fix both | Don't ever reload
|
||||||
|
# 6 | image | Display the image `$IMAGE_CACHE_PATH` points to as an image preview
|
||||||
|
# 7 | image | Display the file directly as an image
|
||||||
|
|
||||||
|
# script arguments
|
||||||
|
FILE_PATH="${1}" # Full path of the highlighted file
|
||||||
|
PV_WIDTH="${2}" # Width of the preview pane (number of fitting characters)
|
||||||
|
PV_HEIGHT="${3}" # Height of the preview pane (number of fitting characters)
|
||||||
|
IMAGE_CACHE_PATH="${4}" # Full path that should be used to cache image preview
|
||||||
|
PV_IMAGE_ENABLED="${5}" # 'True' if image previews are enabled, 'False' otherwise.
|
||||||
|
|
||||||
|
FILE_EXTENSION="${FILE_PATH##*.}"
|
||||||
|
FILE_EXTENSION_LOWER="${FILE_EXTENSION,,}"
|
||||||
|
|
||||||
|
# Settings
|
||||||
|
HIGHLIGHT_SIZE_MAX=262143 # 256KiB
|
||||||
|
HIGHLIGHT_TABWIDTH=4
|
||||||
|
HIGHLIGHT_STYLE='pablo'
|
||||||
|
PYGMENTIZE_STYLE='autumn'
|
||||||
|
|
||||||
|
handle_extension() {
|
||||||
|
case "${FILE_EXTENSION_LOWER}" in
|
||||||
|
ace|arc|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|tar|tbz|tbz2|tgz|tlz|txz|tzo|zip)
|
||||||
|
atool --list -- "${FILE_PATH}" && exit 5
|
||||||
|
bsdtar --list --file "${FILE_PATH}" && exit 5
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
xz|rpm)
|
||||||
|
bsdtar --list --file "${FILE_PATH}" && exit 5
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
rar)
|
||||||
|
unrar lt -p- -- "${FILE_PATH}" && exit 5
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
7z)
|
||||||
|
7z l -p -- "${FILE_PATH}" && exit 5
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
pdf)
|
||||||
|
pdftoppm -jpeg -singlefile "${FILE_PATH}" "${IMAGE_CACHE_PATH}" && exit 6
|
||||||
|
pdftotext -l 10 -nopgbrk -q -- "${FILE_PATH}" - && exit 5
|
||||||
|
exiftool "${FILE_PATH}" && exit 5
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
torrent)
|
||||||
|
transmission-show -- "${FILE_PATH}" && exit 5
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
odt|ods|odp|sxw)
|
||||||
|
odt2txt "${FILE_PATH}" && exit 5
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
htm|html|xhtml)
|
||||||
|
w3m -dump "${FILE_PATH}" && exit 5
|
||||||
|
lynx -dump -- "${FILE_PATH}" && exit 5
|
||||||
|
elinks -dump "${FILE_PATH}" && exit 5
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
handle_image() {
|
||||||
|
local mimetype="${1}"
|
||||||
|
case "${mimetype}" in
|
||||||
|
image/svg+xml)
|
||||||
|
convert "${FILE_PATH}" "${IMAGE_CACHE_PATH}" && exit 6
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
image/*)
|
||||||
|
local orientation
|
||||||
|
orientation="$( identify -format '%[EXIF:Orientation]\n' -- "${FILE_PATH}" )"
|
||||||
|
if [[ -n "$orientation" && "$orientation" != 1 ]]; then
|
||||||
|
convert -- "${FILE_PATH}" -auto-orient "${IMAGE_CACHE_PATH}" && exit 6
|
||||||
|
fi
|
||||||
|
exit 7
|
||||||
|
;;
|
||||||
|
video/*)
|
||||||
|
ffmpegthumbnailer -i "${FILE_PATH}" -o "${IMAGE_CACHE_PATH}" -s 0 && exit 6
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
application/pdf)
|
||||||
|
pdftoppm -f 1 -l 1 -scale-to-x 1920 -scale-to-y -1 -singlefile -jpeg -tiffcompression \
|
||||||
|
jpeg -- "${FILE_PATH}" "${IMAGE_CACHE_PATH%.*}" && exit 6 || exit 1
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
handle_mime() {
|
||||||
|
local mimetype="${1}"
|
||||||
|
case "${mimetype}" in
|
||||||
|
text/*|*/xml)
|
||||||
|
if [[ "$(stat --printf='%s' -- "${FILE_PATH}")" -gt "${HIGHLIGHT_SIZE_MAX}" ]]; then
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
if [[ "$(tput colors)" -ge 256 ]]; then
|
||||||
|
local highlight_format='xterm256'
|
||||||
|
else
|
||||||
|
local highlight_format='ansi'
|
||||||
|
fi
|
||||||
|
highlight --replace-tabs="${HIGHLIGHT_TABWIDTH}" --out-format="${highlight_format}" \
|
||||||
|
--style="${HIGHLIGHT_STYLE}" --force -- "${FILE_PATH}" && exit 5
|
||||||
|
exit 2
|
||||||
|
;;
|
||||||
|
image/*)
|
||||||
|
local orientation
|
||||||
|
orientation="$(identify -format '%[EXIF:Orientation]\n' -- "${FILE_PATH}")"
|
||||||
|
if [[ -n "$orientation" && "$orientation" != 1 ]]; then
|
||||||
|
convert -- "${FILE_PATH}" -auto-orient "${IMAGE_CACHE_PATH}" && exit 6
|
||||||
|
fi
|
||||||
|
exiftool "${FILE_PATH}" && exit 5
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
video/*)
|
||||||
|
ffmpegthumbnailer -i "${FILE_PATH}" -o "${IMAGE_CACHE_PATH}" -s 0 && exit 6
|
||||||
|
mediainfo "${FILE_PATH}" && exit 5
|
||||||
|
exiftool "${FILE_PATH}" && exit 5
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
audio/*)
|
||||||
|
mediainfo "${FILE_PATH}" && exit 5
|
||||||
|
exiftool "${FILE_PATH}" && exit 5
|
||||||
|
exit 1
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
handle_fallback() {
|
||||||
|
echo '----- File Type Classification -----' && file --dereference --brief -- "${FILE_PATH}" && exit 5
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MIMETYPE="$( file --dereference --brief --mime-type -- "${FILE_PATH}" )"
|
||||||
|
|
||||||
|
if [[ "${PV_IMAGE_ENABLED}" == 'True' ]]; then
|
||||||
|
handle_image "${MIMETYPE}"
|
||||||
|
fi
|
||||||
|
handle_extension
|
||||||
|
handle_mime "${MIMETYPE}"
|
||||||
|
handle_fallback
|
||||||
|
|
||||||
|
|
||||||
|
exit 1
|
@ -1,5 +1,17 @@
|
|||||||
# .zprofile
|
# .zprofile
|
||||||
# sourced by zsh when used as a login shell
|
# sourced by zsh when used as a login shell
|
||||||
|
|
||||||
|
# Uncomment the below example for multiple sessions
|
||||||
|
#
|
||||||
|
# using Ctrl-Alt-F2 will switch you to tty2, and i3 will be started
|
||||||
|
# using Ctrl-Alt-F1 will switch back to tty1 and openbox
|
||||||
|
#
|
||||||
|
# if [[ -z $DISPLAY && $XDG_VTNR -eq 1 ]]; then
|
||||||
|
# exec startx ~/.xinitrc openbox
|
||||||
|
# elif [[ -z $DISPLAY && $XDG_VTNR -eq 2 ]]; then
|
||||||
|
# exec startx ~/.xinitrc i3
|
||||||
|
# fi
|
||||||
|
|
||||||
|
|
||||||
# automatically run startx when logging in on tty1
|
# automatically run startx when logging in on tty1
|
||||||
[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx -- vt1 &>/dev/null
|
[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx -- vt1 &>/dev/null
|
||||||
|
Reference in New Issue
Block a user