diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2020-12-14 04:55:41 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2020-12-14 04:55:41 +0300 |
commit | eecabc8425eaa3bd6a888e6f109e08b8058015da (patch) | |
tree | b13d910b0adaae2b74c72617c763cf4042296c0b | |
parent | add tmux configuration (diff) | |
download | linux-home-eecabc8425eaa3bd6a888e6f109e08b8058015da.tar.gz linux-home-eecabc8425eaa3bd6a888e6f109e08b8058015da.zip |
ranger: fuzzy-search hidden files also
-rw-r--r-- | %HOME%/.config/ranger/commands.py | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/%HOME%/.config/ranger/commands.py b/%HOME%/.config/ranger/commands.py index 4bc8a14..bcf0642 100644 --- a/%HOME%/.config/ranger/commands.py +++ b/%HOME%/.config/ranger/commands.py @@ -11,26 +11,25 @@ class paste_as_root(Command): 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'" + # Trigger this by prefixing the command hotkey with e.g. a number. + command = "find -L . \ + \( -fstype 'dev' -o -fstype 'proc' \) -prune \ + -o -type d -print 2> /dev/null \ +| sed 1d \ +| cut -b3- \ +| fzf +m --reverse" 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'" + # Match files and directories. + command = "find -L . \ + \( -fstype 'dev' -o -fstype 'proc' \) -prune \ + -o -print 2> /dev/null \ +| sed 1d \ +| cut -b3- \ +| fzf +m --reverse" fzf = self.fm.execute_command(command, universal_newlines=True, stdout=subprocess.PIPE) stdout, stderr = fzf.communicate() if fzf.returncode == 0: |