aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/%HOME%
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2020-12-11 03:56:12 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2020-12-11 03:56:12 +0300
commit9d36d8d3bbf50715d226965d6c54c53d5ce0d5b6 (patch)
treeada945c842402959531bc9bdffb698238ab97230 /%HOME%
parent.bashrc: prevent nested ranger instances (diff)
downloadlinux-home-9d36d8d3bbf50715d226965d6c54c53d5ce0d5b6.tar.gz
linux-home-9d36d8d3bbf50715d226965d6c54c53d5ce0d5b6.zip
add ranger configuration
Diffstat (limited to '%HOME%')
-rw-r--r--%HOME%/.config/ranger/commands.py41
-rw-r--r--%HOME%/.config/ranger/rc.conf15
2 files changed, 56 insertions, 0 deletions
diff --git a/%HOME%/.config/ranger/commands.py b/%HOME%/.config/ranger/commands.py
new file mode 100644
index 0000000..4bc8a14
--- /dev/null
+++ b/%HOME%/.config/ranger/commands.py
@@ -0,0 +1,41 @@
+# This I borrowed from the default Manjaro setup, which in turn borrowed it
+# from somewhere else.
+
+from ranger.api.commands import Command
+
+class paste_as_root(Command):
+ def execute(self):
+ if self.fm.do_cut:
+ self.fm.execute_console('shell sudo mv %c .')
+ else:
+ self.fm.execute_console('shell sudo cp -r %c .')
+
+class fzf_select(Command):
+ """
+ :fzf_select
+
+ Find a file using fzf.
+
+ With a prefix argument select only directories.
+
+ See: https://github.com/junegunn/fzf
+ """
+ def execute(self):
+ import subprocess
+ import os.path
+ if self.quantifier:
+ # match only directories
+ command="find -L . \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) -prune \
+ -o -type d -print 2> /dev/null | sed 1d | cut -b3- | fzf +m --reverse --header='Jump to file'"
+ else:
+ # match files and directories
+ command="find -L . \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) -prune \
+ -o -print 2> /dev/null | sed 1d | cut -b3- | fzf +m --reverse --header='Jump to filemap <C-f> fzf_select'"
+ fzf = self.fm.execute_command(command, universal_newlines=True, stdout=subprocess.PIPE)
+ stdout, stderr = fzf.communicate()
+ if fzf.returncode == 0:
+ fzf_file = os.path.abspath(stdout.rstrip('\n'))
+ if os.path.isdir(fzf_file):
+ self.fm.cd(fzf_file)
+ else:
+ self.fm.select_file(fzf_file)
diff --git a/%HOME%/.config/ranger/rc.conf b/%HOME%/.config/ranger/rc.conf
new file mode 100644
index 0000000..47ddc8e
--- /dev/null
+++ b/%HOME%/.config/ranger/rc.conf
@@ -0,0 +1,15 @@
+set automatically_count_files false
+set confirm_on_delete never
+set draw_borders true
+set preview_images false
+set show_hidden true
+set tilde_in_titlebar true
+set vcs_aware true
+
+default_linemode filename
+
+map <F8> console delete
+map <DELETE> console delete
+
+map pr paste_as_root
+map <C-f> fzf_select