mirror of
https://github.com/zedsalim/debian-z.git
synced 2025-12-06 19:39:28 +00:00
Updates
This commit is contained in:
parent
8524f1496d
commit
bfe8b96c91
17 changed files with 1027 additions and 84 deletions
38
config/ranger/commands.py
Normal file
38
config/ranger/commands.py
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue