Last active
March 3, 2024 04:16
-
-
Save snuffop/1706122f8fcc4f3575bebe37abab1a21 to your computer and use it in GitHub Desktop.
Use with fasd(command) plugin for ranger to give a list of fasd directories fuzzy search with fzf and change directory on enter.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class fasd_dir(Command): | |
def execute(self): | |
import subprocess | |
import os.path | |
fzf = self.fm.execute_command("fasd -dl | grep -iv cache | fzf 2>/dev/tty", universal_newlines=True, stdout=subprocess.PIPE) | |
stdout, stderr = fzf.communicate() | |
if fzf.returncode == 0: | |
fzf_file = os.path.abspath(stdout.rstrip('\n')) | |
print(fzf_file) | |
if os.path.isdir(fzf_file): | |
self.fm.cd(fzf_file) | |
else: | |
self.fm.select_file(fzf_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment